FileDocCategorySizeDatePackage
PermitAllHandler.javaAPI DocGlassfish v2 API6996Fri May 04 22:31:34 BST 2007com.sun.enterprise.deployment.annotation.handlers

PermitAllHandler

public class PermitAllHandler extends AbstractAttributeHandler implements PostProcessor
This handler is responsible for handling the javax.annotation.security.PermitAll.
author
Shing Wai Chan

Fields Summary
Constructors Summary
public PermitAllHandler()

    
Methods Summary
public java.lang.ClassgetAnnotationType()

return
the annoation type this annotation handler is handling

        return PermitAll.class;
    
public java.lang.Class[]getTypeDependencies()

return
an array of annotation types this annotation handler would require to be processed (if present) before it processes it's own annotation type.

        return getEjbAnnotationTypes();
    
public voidpostProcessAnnotation(com.sun.enterprise.deployment.annotation.AnnotationInfo ainfo, com.sun.enterprise.deployment.annotation.AnnotatedElementHandler aeHandler)

        EjbContext ejbContext = (EjbContext)aeHandler;
        EjbDescriptor ejbDesc = ejbContext.getDescriptor();
        if (!ejbContext.isInherited() &&
                (ejbDesc.getMethodPermissionsFromDD() == null ||
                ejbDesc.getMethodPermissionsFromDD().size() == 0)) {
            for (MethodDescriptor md : getMethodAllDescriptors(ejbDesc)) {
                ejbDesc.addPermissionedMethod(
                    MethodPermission.getUncheckedMethodPermission(), md);
            }
        } else {
            Class classAn = (Class)ainfo.getAnnotatedElement();
            for (Object next : ejbDesc.getSecurityBusinessMethodDescriptors()) {
                MethodDescriptor md = (MethodDescriptor)next;
                if (classAn.equals(ejbContext.getDeclaringClass(md)) &&
                        !hasMethodPermissionsFromDD(md, ejbDesc)) {
                    ejbDesc.addPermissionedMethod(
                        MethodPermission.getUncheckedMethodPermission(),
                        md);
                }
            }
        }
    
protected com.sun.enterprise.deployment.annotation.HandlerProcessingResultprocessAnnotation(com.sun.enterprise.deployment.annotation.AnnotationInfo ainfo, com.sun.enterprise.deployment.annotation.context.EjbContext[] ejbContexts)
Process Annotation with given EjbContexts.

param
ainfo
param
ejbContexts
return
HandlerProcessingResult


        AnnotatedElement ae = (AnnotatedElement)ainfo.getAnnotatedElement();
        if (ae.isAnnotationPresent(DenyAll.class) ||
                ae.isAnnotationPresent(RolesAllowed.class)) {
            log(Level.SEVERE, ainfo,
                localStrings.getLocalString(
                "enterprise.deployment.annotation.handlers.inconsistentsecannotation",
                "This annotation is not consistent with other annotations.  One cannot have more than one of @RolesAllowed, @PermitAll, @DenyAll in the same AnnotatedElement."));
            return getDefaultFailedResult();
        }

        for (EjbContext ejbContext : ejbContexts) {
            EjbDescriptor ejbDesc = ejbContext.getDescriptor();

            if (ElementType.TYPE.equals(ainfo.getElementType())) {
                // postpone the processing at the end
                ejbContext.addPostProcessInfo(ainfo, this);
            } else { // METHOD
                Method annMethod = (Method)ainfo.getAnnotatedElement();
                for (Object next : ejbDesc.getSecurityBusinessMethodDescriptors()) {
                    MethodDescriptor md = (MethodDescriptor)next;
                    Method m = md.getMethod(ejbDesc);
                    if (TypeUtil.sameMethodSignature(m, annMethod)) {
                        // override by xml
                        if (!hasMethodPermissionsFromDD(md, ejbDesc)) {
                            ejbDesc.addPermissionedMethod(
                                MethodPermission.getUncheckedMethodPermission(),
                                md);
                        }
                    }
                }
            }
        }

        return getDefaultProcessedResult();
    
protected booleansupportTypeInheritance()

        return true;