RolesAllowedHandlerpublic class RolesAllowedHandler extends AbstractAttributeHandler implements PostProcessorThis handler is responsible for handling the
javax.annotation.security.RolesAllowed. |
Constructors Summary |
---|
public RolesAllowedHandler()
|
Methods Summary |
---|
private void | addMethodPermissions(javax.annotation.security.RolesAllowed rolesAllowedAn, com.sun.enterprise.deployment.EjbDescriptor ejbDesc, com.sun.enterprise.deployment.MethodDescriptor md)Add roles and permissions to given method in EjbDescriptor.
for (String roleName : rolesAllowedAn.value()) {
Role role = new Role(roleName);
// add role if not exists
ejbDesc.getEjbBundleDescriptor().addRole(role);
ejbDesc.addPermissionedMethod(new MethodPermission(role), md);
}
| public java.lang.Class | getAnnotationType()
return RolesAllowed.class;
| public java.lang.Class[] | getTypeDependencies()
return getEjbAnnotationTypes();
| public void | postProcessAnnotation(com.sun.enterprise.deployment.annotation.AnnotationInfo ainfo, com.sun.enterprise.deployment.annotation.AnnotatedElementHandler aeHandler)
EjbContext ejbContext = (EjbContext)aeHandler;
EjbDescriptor ejbDesc = ejbContext.getDescriptor();
RolesAllowed rolesAllowedAn = (RolesAllowed)ainfo.getAnnotation();
if (!ejbContext.isInherited() &&
(ejbDesc.getMethodPermissionsFromDD() == null ||
ejbDesc.getMethodPermissionsFromDD().size() == 0)) {
for (MethodDescriptor md : getMethodAllDescriptors(ejbDesc)) {
addMethodPermissions(rolesAllowedAn, ejbDesc, md);
}
} else {
Class classAn = (Class)ainfo.getAnnotatedElement();
for (Object next : ejbDesc.getSecurityBusinessMethodDescriptors()) {
MethodDescriptor md = (MethodDescriptor)next;
Method m = md.getMethod(ejbDesc);
// override by existing info
if (classAn.equals(ejbContext.getDeclaringClass(md)) &&
!hasMethodPermissionsFromDD(md, ejbDesc)) {
addMethodPermissions(rolesAllowedAn, ejbDesc, md);
}
}
}
| protected com.sun.enterprise.deployment.annotation.HandlerProcessingResult | processAnnotation(com.sun.enterprise.deployment.annotation.AnnotationInfo ainfo, com.sun.enterprise.deployment.annotation.context.EjbContext[] ejbContexts)
AnnotatedElement ae = (AnnotatedElement)ainfo.getAnnotatedElement();
if (ae.isAnnotationPresent(DenyAll.class) ||
ae.isAnnotationPresent(PermitAll.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();
}
RolesAllowed rolesAllowedAn = (RolesAllowed)ainfo.getAnnotation();
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 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)) {
addMethodPermissions(rolesAllowedAn, ejbDesc, md);
}
}
}
}
}
return getDefaultProcessedResult();
| protected boolean | supportTypeInheritance()
return true;
|
|