1 23 package com.sun.enterprise.deployment.annotation.handlers; 24 25 import java.lang.annotation.Annotation ; 26 import java.lang.annotation.ElementType ; 27 import java.lang.reflect.AnnotatedElement ; 28 import java.lang.reflect.Method ; 29 import java.util.logging.Level ; 30 31 import javax.annotation.security.DenyAll; 32 import javax.annotation.security.PermitAll; 33 import javax.annotation.security.RolesAllowed; 34 35 import com.sun.enterprise.deployment.EjbDescriptor; 36 import com.sun.enterprise.deployment.MethodDescriptor; 37 import com.sun.enterprise.deployment.MethodPermission; 38 import com.sun.enterprise.deployment.Role; 39 import com.sun.enterprise.deployment.annotation.AnnotationInfo; 40 import com.sun.enterprise.deployment.annotation.AnnotationProcessorException; 41 import com.sun.enterprise.deployment.annotation.HandlerProcessingResult; 42 import com.sun.enterprise.deployment.annotation.context.EjbContext; 43 import com.sun.enterprise.util.TypeUtil; 44 45 50 public class DenyAllHandler extends AbstractAttributeHandler { 51 52 public DenyAllHandler() { 53 } 54 55 58 public Class <? extends Annotation > getAnnotationType() { 59 return DenyAll.class; 60 } 61 62 68 protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, 69 EjbContext[] ejbContexts) throws AnnotationProcessorException { 70 71 AnnotatedElement ae = (AnnotatedElement )ainfo.getAnnotatedElement(); 72 Method annMethod = (Method ) ainfo.getAnnotatedElement(); 73 if (ae.isAnnotationPresent(PermitAll.class) || 74 ae.isAnnotationPresent(RolesAllowed.class)) { 75 log(Level.SEVERE, ainfo, 76 localStrings.getLocalString( 77 "enterprise.deployment.annotation.handlers.inconsistentsecannotation", 78 "This annotation is not consistent with other annotations. One cannot have more than one of @RolesAllowed, @PermitAll, @DenyAll in the same AnnotatedElement.")); 79 return getDefaultFailedResult(); 80 } 81 82 for (EjbContext ejbContext : ejbContexts) { 83 EjbDescriptor ejbDesc = ejbContext.getDescriptor(); 84 85 for (Object next : ejbDesc.getSecurityBusinessMethodDescriptors()) { 86 MethodDescriptor md = (MethodDescriptor)next; 87 if (!hasMethodPermissionsFromDD(md, ejbDesc)) { 89 Method m = md.getMethod(ejbDesc); 90 if (TypeUtil.sameMethodSignature(m, annMethod)) { 91 ejbDesc.addPermissionedMethod( 92 MethodPermission.getExcludedMethodPermission(), md); 93 } 94 } 95 } 96 } 97 98 return getDefaultProcessedResult(); 99 } 100 } 101 | Popular Tags |