use of javax.annotation.security.RunAs in project Payara by payara.
the class RunAsHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
RunAs runAsAn = (RunAs) ainfo.getAnnotation();
for (EjbContext ejbContext : ejbContexts) {
EjbDescriptor ejbDesc = ejbContext.getDescriptor();
// override by xml
if (ejbDesc.getUsesCallerIdentity() != null) {
continue;
}
String roleName = runAsAn.value();
Role role = new Role(roleName);
// add Role if not exists
ejbDesc.getEjbBundleDescriptor().addRole(role);
RunAsIdentityDescriptor runAsDesc = new RunAsIdentityDescriptor();
runAsDesc.setRoleName(roleName);
ejbDesc.setUsesCallerIdentity(false);
if (ejbDesc.getRunAsIdentity() == null) {
ejbDesc.setRunAsIdentity(runAsDesc);
}
}
return getDefaultProcessedResult();
}
use of javax.annotation.security.RunAs in project wildfly by wildfly.
the class RunAsMergingProcessor method handleAnnotations.
@Override
protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentConfiguration) 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<RunAs, String> runAs = clazz.getAnnotationInformation(RunAs.class);
final ClassAnnotationInformation<RunAsPrincipal, String> runAsPrincipal = clazz.getAnnotationInformation(RunAsPrincipal.class);
if (runAs == null) {
if (runAsPrincipal != null) {
EjbLogger.DEPLOYMENT_LOGGER.missingRunAsAnnotation(componentClass.getName());
}
return;
}
if (!runAs.getClassLevelAnnotations().isEmpty()) {
componentConfiguration.setRunAs(runAs.getClassLevelAnnotations().get(0));
}
String principal = DEFAULT_RUN_AS_PRINCIPAL;
if (runAsPrincipal != null && !runAsPrincipal.getClassLevelAnnotations().isEmpty()) {
principal = runAsPrincipal.getClassLevelAnnotations().get(0);
}
componentConfiguration.setRunAsPrincipal(principal);
}
use of javax.annotation.security.RunAs in project Payara by payara.
the class DynamicWebServletRegistrationImpl method postProcessAnnotations.
void postProcessAnnotations() {
Class<? extends Servlet> clazz = wrapper.getServletClass();
if (clazz == null) {
return;
}
// Process RunAs
if (wcd.getRunAsIdentity() == null) {
String roleName = runAsRoleName;
if (roleName == null && clazz.isAnnotationPresent(RunAs.class)) {
RunAs runAs = clazz.getAnnotation(RunAs.class);
roleName = runAs.value();
}
if (roleName != null) {
super.setRunAsRole(roleName);
wbd.addRole(new Role(roleName));
RunAsIdentityDescriptor runAsDesc = new RunAsIdentityDescriptor();
runAsDesc.setRoleName(roleName);
wcd.setRunAsIdentity(runAsDesc);
}
}
// Process ServletSecurity
ServletSecurityElement ssElement = servletSecurityElement;
if (servletSecurityElement == null && clazz.isAnnotationPresent(ServletSecurity.class)) {
ServletSecurity servletSecurity = clazz.getAnnotation(ServletSecurity.class);
ssElement = new ServletSecurityElement(servletSecurity);
}
if (ssElement != null) {
webModule.processServletSecurityElement(ssElement, wbd, wcd);
}
}
use of javax.annotation.security.RunAs in project Payara by payara.
the class RunAsHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, WebComponentContext[] webCompContexts) throws AnnotationProcessorException {
RunAs runAsAn = (RunAs) ainfo.getAnnotation();
for (WebComponentContext webCompContext : webCompContexts) {
WebComponentDescriptor webDesc = webCompContext.getDescriptor();
// override by xml
if (webDesc.getRunAsIdentity() != null) {
continue;
}
String roleName = runAsAn.value();
Role role = new Role(roleName);
// add Role if not exists
webDesc.getWebBundleDescriptor().addRole(role);
RunAsIdentityDescriptor runAsDesc = new RunAsIdentityDescriptor();
runAsDesc.setRoleName(roleName);
webDesc.setRunAsIdentity(runAsDesc);
}
return getDefaultProcessedResult();
}
use of javax.annotation.security.RunAs in project Payara by payara.
the class RunAsHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
RunAs runAsAn = (RunAs) ainfo.getAnnotation();
for (EjbContext ejbContext : ejbContexts) {
EjbDescriptor ejbDesc = ejbContext.getDescriptor();
// override by xml
if (ejbDesc.getUsesCallerIdentity() != null) {
continue;
}
String roleName = runAsAn.value();
Role role = new Role(roleName);
// add Role if not exists
ejbDesc.getEjbBundleDescriptor().addRole(role);
RunAsIdentityDescriptor runAsDesc = new RunAsIdentityDescriptor();
runAsDesc.setRoleName(roleName);
ejbDesc.setUsesCallerIdentity(false);
if (ejbDesc.getRunAsIdentity() == null) {
ejbDesc.setRunAsIdentity(runAsDesc);
}
}
return getDefaultProcessedResult();
}
Aggregations