use of javax.annotation.security.DeclareRoles in project tomcat70 by apache.
the class WebAnnotationSet method loadClassAnnotation.
/**
* Process the annotations on a context for a given className.
*
* @param context The context which will have its annotations processed
* @param clazz The class to examine for Servlet annotations
*/
protected static void loadClassAnnotation(Context context, Class<?> clazz) {
/* Process Resource annotation.
* Ref JSR 250
*/
Resource resourceAnnotation = clazz.getAnnotation(Resource.class);
if (resourceAnnotation != null) {
addResource(context, resourceAnnotation);
}
/* Process Resources annotation.
* Ref JSR 250
*/
Resources resourcesAnnotation = clazz.getAnnotation(Resources.class);
if (resourcesAnnotation != null && resourcesAnnotation.value() != null) {
for (Resource resource : resourcesAnnotation.value()) {
addResource(context, resource);
}
}
/* Process EJB annotation.
* Ref JSR 224, equivalent to the ejb-ref or ejb-local-ref
* element in the deployment descriptor.
{
EJB annotation = clazz.getAnnotation(EJB.class);
if (annotation != null) {
if ((annotation.mappedName().length() == 0)
|| annotation.mappedName().equals("Local")) {
ContextLocalEjb ejb = new ContextLocalEjb();
ejb.setName(annotation.name());
ejb.setType(annotation.beanInterface().getCanonicalName());
ejb.setDescription(annotation.description());
ejb.setHome(annotation.beanName());
context.getNamingResources().addLocalEjb(ejb);
} else if (annotation.mappedName().equals("Remote")) {
ContextEjb ejb = new ContextEjb();
ejb.setName(annotation.name());
ejb.setType(annotation.beanInterface().getCanonicalName());
ejb.setDescription(annotation.description());
ejb.setHome(annotation.beanName());
context.getNamingResources().addEjb(ejb);
}
}
}
*/
/* Process WebServiceRef annotation.
* Ref JSR 224, equivalent to the service-ref element in
* the deployment descriptor.
* The service-ref registration is not implemented
{
WebServiceRef annotation = clazz
.getAnnotation(WebServiceRef.class);
if (annotation != null) {
ContextService service = new ContextService();
service.setName(annotation.name());
service.setWsdlfile(annotation.wsdlLocation());
service.setType(annotation.type().getCanonicalName());
if (annotation.value() == null)
service.setServiceinterface(annotation.type()
.getCanonicalName());
if (annotation.type().getCanonicalName().equals("Service"))
service.setServiceinterface(annotation.type()
.getCanonicalName());
if (annotation.value().getCanonicalName().equals("Endpoint"))
service.setServiceendpoint(annotation.type()
.getCanonicalName());
service.setPortlink(annotation.type().getCanonicalName());
context.getNamingResources().addService(service);
}
}
*/
/* Process DeclareRoles annotation.
* Ref JSR 250, equivalent to the security-role element in
* the deployment descriptor
*/
DeclareRoles declareRolesAnnotation = clazz.getAnnotation(DeclareRoles.class);
if (declareRolesAnnotation != null && declareRolesAnnotation.value() != null) {
for (String role : declareRolesAnnotation.value()) {
context.addSecurityRole(role);
}
}
}
use of javax.annotation.security.DeclareRoles in project Payara by payara.
the class DeclareRolesHandler method processAnnotation.
private HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, WebBundleDescriptor webBundleDesc) {
DeclareRoles rolesRefAn = (DeclareRoles) ainfo.getAnnotation();
for (String roleName : rolesRefAn.value()) {
Role role = new Role(roleName);
webBundleDesc.addRole(role);
}
return getDefaultProcessedResult();
}
use of javax.annotation.security.DeclareRoles in project wildfly by wildfly.
the class DeclareRolesMergingProcessor method handleAnnotations.
@Override
protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException {
final EEModuleClassDescription clazz = applicationClasses.getClassByName(componentClass.getName());
// we only care about annotations on the bean class itself
if (clazz == null) {
return;
}
final ClassAnnotationInformation<DeclareRoles, String[]> declareRoles = clazz.getAnnotationInformation(DeclareRoles.class);
if (declareRoles == null) {
return;
}
if (!declareRoles.getClassLevelAnnotations().isEmpty()) {
description.addDeclaredRoles(declareRoles.getClassLevelAnnotations().get(0));
}
}
Aggregations