Commit f2df85f1 authored by 雍欢's avatar 雍欢

默认对附件密级进行校验

parent c79079f1
...@@ -23,7 +23,11 @@ public class UserTaskConverter extends AbstractElementConverter implements Eleme ...@@ -23,7 +23,11 @@ public class UserTaskConverter extends AbstractElementConverter implements Eleme
public final static String CUSTOM_PROPERTY_PREVIEW_HANDLER = "previewHandler"; public final static String CUSTOM_PROPERTY_PREVIEW_HANDLER = "previewHandler";
public final static String CUSTOM_PROPERTY_ASSISTANT_MUST_APPROVE = "assistantMustApprove"; public final static String CUSTOM_PROPERTY_ASSISTANT_MUST_APPROVE = "assistantMustApprove";
public final static String CUSTOM_PROPERTY_MERGE_HANDLER_KIND = "mergeHandlerKind"; public final static String CUSTOM_PROPERTY_MERGE_HANDLER_KIND = "mergeHandlerKind";
public final static List<String> CUSTOM_PROPERTIES = Arrays.asList(CUSTOM_PROPERTY_NEED_TIMING, CUSTOM_PROPERTY_LIMIT_TIME, CUSTOM_PROPERTY_PREVIEW_HANDLER, CUSTOM_PROPERTY_ASSISTANT_MUST_APPROVE, CUSTOM_PROPERTY_MERGE_HANDLER_KIND); /**
* 用户任务描述表达式
*/
public final static String CUSTOM_PROPERTY_USER_TASK_DESCRIPTION_EXPRESSION = "descriptionExpression";
public final static List<String> CUSTOM_PROPERTIES = Arrays.asList(CUSTOM_PROPERTY_NEED_TIMING, CUSTOM_PROPERTY_LIMIT_TIME, CUSTOM_PROPERTY_PREVIEW_HANDLER, CUSTOM_PROPERTY_ASSISTANT_MUST_APPROVE, CUSTOM_PROPERTY_MERGE_HANDLER_KIND, CUSTOM_PROPERTY_USER_TASK_DESCRIPTION_EXPRESSION);
public UserTaskConverter() { public UserTaskConverter() {
super(Collections.singletonList(Shape.USER_TASK)); super(Collections.singletonList(Shape.USER_TASK));
......
...@@ -21,6 +21,14 @@ public abstract class AbstractAttachmentSecretInfoResolver implements Attachment ...@@ -21,6 +21,14 @@ public abstract class AbstractAttachmentSecretInfoResolver implements Attachment
private AttachmentConfigurationRepository attachmentConfigurationRepository; private AttachmentConfigurationRepository attachmentConfigurationRepository;
private OrgApplication orgApplication; private OrgApplication orgApplication;
private SecrecyLevelComparator secrecyLevelComparator; private SecrecyLevelComparator secrecyLevelComparator;
/**
* 默认开启密级检查
*/
private boolean defaultEnableSecret;
public void setDefaultEnableSecret(boolean defaultEnableSecret) {
this.defaultEnableSecret = defaultEnableSecret;
}
@Autowired @Autowired
public void setAttachmentConfigurationRepository(AttachmentConfigurationRepository attachmentConfigurationRepository) { public void setAttachmentConfigurationRepository(AttachmentConfigurationRepository attachmentConfigurationRepository) {
...@@ -40,13 +48,10 @@ public abstract class AbstractAttachmentSecretInfoResolver implements Attachment ...@@ -40,13 +48,10 @@ public abstract class AbstractAttachmentSecretInfoResolver implements Attachment
@Override @Override
public String resolve(FileInfo fileInfo) { public String resolve(FileInfo fileInfo) {
AttachmentConfiguration attachmentConfiguration = attachmentConfigurationRepository.findByCode(fileInfo.getBizCode()); AttachmentConfiguration attachmentConfiguration = attachmentConfigurationRepository.findByCode(fileInfo.getBizCode());
if (attachmentConfiguration == null) { if (attachmentConfiguration == null && !defaultEnableSecret) {
return null;
}
if (!Objects.equals(attachmentConfiguration.getEnableSecret(), 1)) {
// 未启用密级
return null; return null;
} }
if (enableSecret(attachmentConfiguration)) {
// 1、解析附件密级 // 1、解析附件密级
String attachmentSecurityLevel = resolveAttachmentSecurityLevel(fileInfo); String attachmentSecurityLevel = resolveAttachmentSecurityLevel(fileInfo);
// 2、校验附件密级是否与人员密级匹配 // 2、校验附件密级是否与人员密级匹配
...@@ -60,6 +65,23 @@ public abstract class AbstractAttachmentSecretInfoResolver implements Attachment ...@@ -60,6 +65,23 @@ public abstract class AbstractAttachmentSecretInfoResolver implements Attachment
// 4、返回附件密级 // 4、返回附件密级
return attachmentSecurityLevel; return attachmentSecurityLevel;
} }
// 未启用密级
return null;
}
private boolean enableSecret(AttachmentConfiguration attachmentConfiguration) {
boolean enableSecret;
if (attachmentConfiguration == null) {
enableSecret = defaultEnableSecret;
} else {
if (attachmentConfiguration.getEnableSecret() == null) {
enableSecret = defaultEnableSecret;
} else {
enableSecret = Objects.equals(attachmentConfiguration.getEnableSecret(), 1);
}
}
return enableSecret;
}
/** /**
* 解析附件密级。 * 解析附件密级。
......
...@@ -34,7 +34,7 @@ public class TestAttachmentSecretInfoResolver extends AbstractAttachmentSecretIn ...@@ -34,7 +34,7 @@ public class TestAttachmentSecretInfoResolver extends AbstractAttachmentSecretIn
@Override @Override
protected String resolveAttachmentSecurityLevel(FileInfo fileInfo) { protected String resolveAttachmentSecurityLevel(FileInfo fileInfo) {
Matcher matcher = FILE_NAME_PATTERN.matcher(fileInfo.getName()); Matcher matcher = FILE_NAME_PATTERN.matcher(fileInfo.getName());
Assert.isTrue(matcher.matches(), "附件名不合法"); Assert.isTrue(matcher.matches(), "附件名不合法,合法的附件名为:【密级】文件名,如:【非密】报销单.pdf");
String attachmentSecurityGradeName = matcher.group(1); String attachmentSecurityGradeName = matcher.group(1);
Assert.hasText(attachmentSecurityGradeName, "附件名中未包含附件密级信息"); Assert.hasText(attachmentSecurityGradeName, "附件名中未包含附件密级信息");
DictionaryDesc attachmentSecurityGrade = SystemCache.getDictionary(securityGradeDictionaryCode).values() DictionaryDesc attachmentSecurityGrade = SystemCache.getDictionary(securityGradeDictionaryCode).values()
......
...@@ -112,11 +112,11 @@ ...@@ -112,11 +112,11 @@
<artifactId>huigou-explorer</artifactId> <artifactId>huigou-explorer</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <!-- <dependency>
<groupId>com.huigou</groupId> <groupId>com.huigou</groupId>
<artifactId>huigou-bpm</artifactId> <artifactId>huigou-bpm</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>-->
<dependency> <dependency>
<groupId>com.huigou</groupId> <groupId>com.huigou</groupId>
<artifactId>huigou-rule</artifactId> <artifactId>huigou-rule</artifactId>
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
<module>huigou-demo</module> <module>huigou-demo</module>
<module>huigou-xt</module> <module>huigou-xt</module>
<module>query-spring</module> <module>query-spring</module>
<module>huigou-form</module> <!-- <module>huigou-form</module>-->
<module>huigou-bpm</module> <!-- <module>huigou-bpm</module>-->
<module>huigou-webservice</module> <module>huigou-webservice</module>
<module>huigou-rule</module> <module>huigou-rule</module>
</modules> </modules>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment