1 25 26 package org.objectweb.easybeans.container.info.security; 27 28 import java.util.Collection ; 29 import java.util.List ; 30 31 import javax.security.jacc.EJBMethodPermission ; 32 33 import org.objectweb.easybeans.api.bean.info.IMethodSecurityInfo; 34 import org.objectweb.easybeans.api.bean.info.ISecurityInfo; 35 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 36 import org.objectweb.easybeans.deployment.annotations.metadata.MethodAnnotationMetadata; 37 38 42 public final class SecurityInfoHelper { 43 44 47 private SecurityInfoHelper() { 48 49 } 50 51 56 public static ISecurityInfo getSecurityInfo(final ClassAnnotationMetadata bean) { 57 ISecurityInfo securityInfo = new SecurityInfo(); 58 59 securityInfo.setDeclaredRole(bean.getDeclareRoles()); 61 62 String runAsRole = bean.getRunAs(); 64 if (runAsRole != null) { 65 securityInfo.setRunAsRole(runAsRole); 66 } 67 68 69 Collection <MethodAnnotationMetadata> methods = bean.getMethodAnnotationMetadataCollection(); 71 if (methods == null) { 73 return securityInfo; 74 } 75 76 for (MethodAnnotationMetadata method : methods) { 77 if (!method.isBusinessMethod()) { 79 continue; 80 } 81 82 IMethodSecurityInfo methodSecurityInfo = new MethodSecurityInfo(); 83 securityInfo.addMethodSecurityInfo(methodSecurityInfo); 84 85 methodSecurityInfo.setExcluded(method.hasDenyAll()); 87 methodSecurityInfo.setUnchecked(method.hasPermitAll()); 88 List <String > roles = method.getRolesAllowed(); 89 if (roles != null) { 90 for (String role : roles) { 91 methodSecurityInfo.addRole(role); 92 } 93 } 94 95 String ejbName = bean.getJCommonBean().getName(); 97 String methodName = method.getMethodName(); 98 String methodInterface = null; 100 String [] methodParams = null; 102 103 EJBMethodPermission permission = new EJBMethodPermission (ejbName, methodName, methodInterface, methodParams); 104 methodSecurityInfo.setPermission(permission); 105 } 106 107 return securityInfo; 108 } 109 } 110 | Popular Tags |