Search in sources :

Example 11 with RunAsIdentityDescriptor

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();
}
Also used : Role(org.glassfish.security.common.Role) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) WebComponentContext(com.sun.enterprise.deployment.annotation.context.WebComponentContext) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) RunAs(javax.annotation.security.RunAs)

Example 12 with RunAsIdentityDescriptor

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;
}
Also used : Enumeration(java.util.Enumeration) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) Node(org.w3c.dom.Node) MultipartConfigDescriptor(org.glassfish.web.deployment.descriptor.MultipartConfigDescriptor)

Aggregations

RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)12 Role (org.glassfish.security.common.Role)7 RunAs (javax.annotation.security.RunAs)5 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)4 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)3 EjbIORConfigurationDescriptor (com.sun.enterprise.deployment.EjbIORConfigurationDescriptor)2 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)2 WebComponentContext (com.sun.enterprise.deployment.annotation.context.WebComponentContext)2 Result (com.sun.enterprise.tools.verifier.Result)2 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)2 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)2 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)1 MessageDestinationReferenceDescriptor (com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor)1 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)1 MethodPermission (com.sun.enterprise.deployment.MethodPermission)1 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 XMLElement (com.sun.enterprise.deployment.node.XMLElement)1 EjbRefNode (com.sun.enterprise.deployment.node.runtime.EjbRefNode)1