use of com.sun.enterprise.deployment.RunAsIdentityDescriptor 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 com.sun.enterprise.deployment.RunAsIdentityDescriptor 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 com.sun.enterprise.deployment.RunAsIdentityDescriptor 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 com.sun.enterprise.deployment.RunAsIdentityDescriptor in project Payara by payara.
the class RealmAdapter method initializeRealm.
@Override
public void initializeRealm(Object descriptor, boolean isSystemApp, String realmName) {
this.isSystemApp = isSystemApp;
webDescriptor = (WebBundleDescriptor) descriptor;
computeRealmName(webDescriptor, realmName);
CONTEXT_ID = WebSecurityManager.getContextID(webDescriptor);
runAsPrincipals = new HashMap<String, String>();
for (WebComponentDescriptor componentDescriptor : webDescriptor.getWebComponentDescriptors()) {
RunAsIdentityDescriptor runAsDescriptor = componentDescriptor.getRunAsIdentity();
if (runAsDescriptor != null) {
String principal = runAsDescriptor.getPrincipal();
String servlet = componentDescriptor.getCanonicalName();
if (principal == null || servlet == null) {
logger.warning("web.realmadapter.norunas");
} else {
runAsPrincipals.put(servlet, principal);
logger.fine("Servlet " + servlet + " will run-as: " + principal);
}
}
}
this.moduleID = webDescriptor.getModuleID();
}
use of com.sun.enterprise.deployment.RunAsIdentityDescriptor in project Payara by payara.
the class ASEjbPrincipal method check.
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
boolean oneFailed = false;
try {
if (descriptor.getUsesCallerIdentity() == false) {
RunAsIdentityDescriptor runAsIdDesc = descriptor.getRunAsIdentity();
if (runAsIdDesc != null) {
String principal = runAsIdDesc.getPrincipal();
if (principal == null) {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] : principal element not defined"));
} else {
if (principal.length() == 0) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB principal] : name cannot be an empty String"));
} else {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB principal] : name is {0}", new Object[] { principal }));
}
}
}
} else {
addNaDetails(result, compName);
result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] run-as Element is not defined"));
}
} catch (Exception ex) {
addErrorDetails(result, compName);
result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
}
return result;
}
Aggregations