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 ServletNode method writeDescriptor.
/**
* write the descriptor class to a DOM tree and return it
*
* @param parent node in the DOM tree
* @param descriptor the descriptor to write
* @return the DOM tree top node
*/
@Override
public Node writeDescriptor(Node parent, WebComponentDescriptor descriptor) {
Node myNode = super.writeDescriptor(parent, descriptor);
appendTextChild(myNode, WebTagNames.SERVLET_NAME, descriptor.getCanonicalName());
if (descriptor.isServlet()) {
appendTextChild(myNode, WebTagNames.SERVLET_CLASS, descriptor.getWebComponentImplementation());
} else {
appendTextChild(myNode, WebTagNames.JSP_FILENAME, descriptor.getWebComponentImplementation());
}
// init-param*
WebCommonNode.addInitParam(myNode, WebTagNames.INIT_PARAM, descriptor.getInitializationParameters());
if (descriptor.getLoadOnStartUp() != null) {
appendTextChild(myNode, WebTagNames.LOAD_ON_STARTUP, String.valueOf(descriptor.getLoadOnStartUp()));
}
appendTextChild(myNode, WebTagNames.ENABLED, String.valueOf(descriptor.isEnabled()));
if (descriptor.isAsyncSupported() != null) {
appendTextChild(myNode, WebTagNames.ASYNC_SUPPORTED, String.valueOf(descriptor.isAsyncSupported()));
}
// run-as
RunAsIdentityDescriptor runAs = descriptor.getRunAsIdentity();
if (runAs != null) {
RunAsNode runAsNode = new RunAsNode();
runAsNode.writeDescriptor(myNode, WebTagNames.RUNAS_SPECIFIED_IDENTITY, runAs);
}
// sercurity-role-ref*
Enumeration roleRefs = descriptor.getSecurityRoleReferences();
SecurityRoleRefNode roleRefNode = new SecurityRoleRefNode();
while (roleRefs.hasMoreElements()) {
roleRefNode.writeDescriptor(myNode, WebTagNames.ROLE_REFERENCE, (RoleReference) roleRefs.nextElement());
}
// multipart-config
MultipartConfigDescriptor multipartConfigDesc = (MultipartConfigDescriptor) descriptor.getMultipartConfig();
if (multipartConfigDesc != null) {
MultipartConfigNode multipartConfigNode = new MultipartConfigNode();
multipartConfigNode.writeDescriptor(myNode, WebTagNames.MULTIPART_CONFIG, multipartConfigDesc);
}
return myNode;
}
Aggregations