Search in sources :

Example 1 with ServiceMethodType

use of com.netsteadfast.greenstep.base.model.ServiceMethodType in project bamboobsc by billchen198318.

the class ServiceAuthorityCheckAspect method isServiceMethodAuthority.

private boolean isServiceMethodAuthority(String serviceId, Annotation[] annotations, Subject subject) {
    if (annotations == null || annotations.length < 1) {
        // 沒有 @ServiceMethodAuthority 不要檢查權限
        return true;
    }
    boolean status = false;
    boolean foundServiceMethodAuthority = false;
    for (Annotation anno : annotations) {
        if (anno instanceof ServiceMethodAuthority) {
            foundServiceMethodAuthority = true;
            ServiceMethodType[] types = ((ServiceMethodAuthority) anno).type();
            for (int i = 0; types != null && !status && i < types.length; i++) {
                ServiceMethodType type = types[i];
                // 如 core.service.logic.ApplicationSystemLogicService#INSERT
                String methodPerm = serviceId + Constants.SERVICE_ID_TYPE_DISTINGUISH_SYMBOL + type.toString();
                if (subject.isPermitted(methodPerm)) {
                    status = true;
                }
            }
        }
    }
    if (!foundServiceMethodAuthority) {
        // 沒有 @ServiceMethodAuthority 不要檢查權限 
        return true;
    }
    return status;
}
Also used : ServiceMethodType(com.netsteadfast.greenstep.base.model.ServiceMethodType) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Annotation(java.lang.annotation.Annotation) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint)

Aggregations

ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)1 ServiceMethodType (com.netsteadfast.greenstep.base.model.ServiceMethodType)1 Annotation (java.lang.annotation.Annotation)1 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)1