新增动态表单权限验证器

This commit is contained in:
周浩
2016-05-16 16:48:02 +08:00
parent 8fac17e53c
commit 16b62714bc
2 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
package org.hsweb.web.controller;
import org.hsweb.web.bean.po.user.User;
/**
* Created by zhouhao on 16-5-16.
*/
public interface DynamicFormAuthorizeValidator {
boolean validate(String formName, User user, String... actions);
}

View File

@@ -0,0 +1,30 @@
package org.hsweb.web.controller;
import org.hsweb.web.bean.po.user.User;
import org.hsweb.web.core.authorize.ExpressionScopeBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* Created by zhouhao on 16-5-16.
*/
@Component("dynamicFormAuthorizeValidator")
public class DynamicFormAuthorizeValidatorConfiguration implements ExpressionScopeBean {
@Autowired(required = false)
private List<DynamicFormAuthorizeValidator> dynamicFormAuthorizeValidators;
public boolean validate(String formName, User user, String... actions) {
if (dynamicFormAuthorizeValidators != null) {
for (DynamicFormAuthorizeValidator validator : dynamicFormAuthorizeValidators) {
if (validator.validate(formName, user, actions)) {
return true;
}
}
return false;
}
return true;
}
}