Search in sources :

Example 1 with PrincipalNameDescriptor

use of com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor in project Payara by payara.

the class EjbBundleRuntimeNode method addDescriptor.

@Override
public void addDescriptor(Object newDescriptor) {
    if (newDescriptor instanceof SecurityRoleMapping) {
        SecurityRoleMapping roleMap = (SecurityRoleMapping) newDescriptor;
        descriptor.addSecurityRoleMapping(roleMap);
        Application app = descriptor.getApplication();
        if (app != null) {
            Role role = new Role(roleMap.getRoleName());
            SecurityRoleMapper rm = app.getRoleMapper();
            if (rm != null) {
                List<PrincipalNameDescriptor> principals = roleMap.getPrincipalNames();
                for (int i = 0; i < principals.size(); i++) {
                    rm.assignRole(principals.get(i).getPrincipal(), role, descriptor);
                }
                List<String> groups = roleMap.getGroupNames();
                for (int i = 0; i < groups.size(); i++) {
                    rm.assignRole(new Group(groups.get(i)), role, descriptor);
                }
            }
        }
    } else if (newDescriptor instanceof ResourcePropertyDescriptor) {
        ResourcePropertyDescriptor desc = (ResourcePropertyDescriptor) newDescriptor;
        if ("default-role-mapping".equals(desc.getName())) {
            descriptor.setDefaultGroupPrincipalMapping(ConfigBeansUtilities.toBoolean(desc.getValue()));
        }
    }
}
Also used : Role(org.glassfish.security.common.Role) Group(org.glassfish.security.common.Group) SecurityRoleMapping(com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping) SecurityRoleMapper(org.glassfish.deployment.common.SecurityRoleMapper) ResourcePropertyDescriptor(com.sun.enterprise.deployment.ResourcePropertyDescriptor) PrincipalNameDescriptor(com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor) Application(com.sun.enterprise.deployment.Application)

Example 2 with PrincipalNameDescriptor

use of com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor in project Payara by payara.

the class SecurityRoleMappingNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param node name
 * @param the descriptor to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, String nodeName, SecurityRoleMapping descriptor) {
    Node roleMapping = appendChild(parent, nodeName);
    // role-name
    appendTextChild(roleMapping, RuntimeTagNames.ROLE_NAME, descriptor.getRoleName());
    // principal-name+
    PrincipalNameNode principal = new PrincipalNameNode();
    List<PrincipalNameDescriptor> principals = descriptor.getPrincipalNames();
    for (int i = 0; i < principals.size(); i++) {
        principal.writeDescriptor(roleMapping, RuntimeTagNames.PRINCIPAL_NAME, principals.get(i));
    }
    // group+
    List<String> groups = descriptor.getGroupNames();
    for (int i = 0; i < groups.size(); i++) {
        appendTextChild(roleMapping, RuntimeTagNames.GROUP_NAME, groups.get(i));
    }
    return roleMapping;
}
Also used : Node(org.w3c.dom.Node) RuntimeDescriptorNode(com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode) PrincipalNameDescriptor(com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor)

Example 3 with PrincipalNameDescriptor

use of com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor in project Payara by payara.

the class PrincipalNameNode method setElementValue.

/**
 * receives notiification of the value for a particular tag
 *
 * @param element the xml element
 * @param value it's associated value
 */
public void setElementValue(XMLElement element, String value) {
    PrincipalNameDescriptor principal = (PrincipalNameDescriptor) getDescriptor();
    if (RuntimeTagNames.PRINCIPAL_NAME.equals(element.getQName())) {
        principal.setName(value);
        Object rootDesc = getParentNode().getParentNode().getDescriptor();
        if (rootDesc instanceof RootDeploymentDescriptor) {
            principal.setClassLoader(((RootDeploymentDescriptor) rootDesc).getClassLoader());
        }
    } else
        super.setElementValue(element, value);
}
Also used : RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) PrincipalNameDescriptor(com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor)

Example 4 with PrincipalNameDescriptor

use of com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor in project Payara by payara.

the class SecurityRoleMappingNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param node name
 * @param the descriptor to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, String nodeName, SecurityRoleMapping descriptor) {
    Node roleMapping = appendChild(parent, nodeName);
    // role-name
    appendTextChild(roleMapping, RuntimeTagNames.ROLE_NAME, descriptor.getRoleName());
    // principal-name+
    PrincipalNameNode principal = new PrincipalNameNode();
    List<PrincipalNameDescriptor> principals = descriptor.getPrincipalNames();
    for (int i = 0; i < principals.size(); i++) {
        principal.writeDescriptor(roleMapping, RuntimeTagNames.PRINCIPAL_NAME, principals.get(i));
    }
    // group+
    List<String> groups = descriptor.getGroupNames();
    for (int i = 0; i < groups.size(); i++) {
        appendTextChild(roleMapping, RuntimeTagNames.GROUP_NAME, groups.get(i));
    }
    return roleMapping;
}
Also used : Node(org.w3c.dom.Node) RuntimeDescriptorNode(com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode) PrincipalNameDescriptor(com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor)

Example 5 with PrincipalNameDescriptor

use of com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor in project Payara by payara.

the class WebBundleRuntimeNode method addDescriptor.

/**
 * Adds  a new DOL descriptor instance to the descriptor instance associated with
 * this XMLNode
 *
 * @param newDescriptor the new descriptor
 */
@Override
public void addDescriptor(Object newDescriptor) {
    SunWebAppImpl sunWebApp = (SunWebAppImpl) descriptor.getSunDescriptor();
    if (newDescriptor instanceof WebComponentDescriptor) {
        WebComponentDescriptor servlet = (WebComponentDescriptor) newDescriptor;
        // for backward compatibility with s1as schema2beans generated desc
        Servlet s1descriptor = new Servlet();
        s1descriptor.setServletName(servlet.getCanonicalName());
        if (servlet.getRunAsIdentity() != null) {
            s1descriptor.setPrincipalName(servlet.getRunAsIdentity().getPrincipal());
        }
        sunWebApp.addServlet(s1descriptor);
    } else if (newDescriptor instanceof ServiceReferenceDescriptor) {
        descriptor.addServiceReferenceDescriptor((ServiceReferenceDescriptor) newDescriptor);
    } else if (newDescriptor instanceof SecurityRoleMapping) {
        SecurityRoleMapping srm = (SecurityRoleMapping) newDescriptor;
        sunWebApp.addSecurityRoleMapping(srm);
        // store it in the application using pure DOL descriptors...
        Application app = descriptor.getApplication();
        if (app != null) {
            Role role = new Role(srm.getRoleName());
            SecurityRoleMapper rm = app.getRoleMapper();
            if (rm != null) {
                List<PrincipalNameDescriptor> principals = srm.getPrincipalNames();
                for (int i = 0; i < principals.size(); i++) {
                    rm.assignRole(principals.get(i).getPrincipal(), role, descriptor);
                }
                List<String> groups = srm.getGroupNames();
                for (int i = 0; i < groups.size(); i++) {
                    rm.assignRole(new Group(groups.get(i)), role, descriptor);
                }
            }
        }
    } else if (newDescriptor instanceof IdempotentUrlPattern) {
        sunWebApp.addIdempotentUrlPattern((IdempotentUrlPattern) newDescriptor);
    } else if (newDescriptor instanceof SessionConfig) {
        sunWebApp.setSessionConfig((SessionConfig) newDescriptor);
    } else if (newDescriptor instanceof Cache) {
        sunWebApp.setCache((Cache) newDescriptor);
    } else if (newDescriptor instanceof ClassLoader) {
        sunWebApp.setClassLoader((ClassLoader) newDescriptor);
    } else if (newDescriptor instanceof JspConfig) {
        sunWebApp.setJspConfig((JspConfig) newDescriptor);
    } else if (newDescriptor instanceof LocaleCharsetInfo) {
        sunWebApp.setLocaleCharsetInfo((LocaleCharsetInfo) newDescriptor);
    } else if (newDescriptor instanceof WebProperty) {
        sunWebApp.addWebProperty((WebProperty) newDescriptor);
    } else if (newDescriptor instanceof Valve) {
        sunWebApp.addValve((Valve) newDescriptor);
    } else
        super.addDescriptor(descriptor);
}
Also used : SunWebAppImpl(org.glassfish.web.deployment.runtime.SunWebAppImpl) Group(org.glassfish.security.common.Group) JspConfig(org.glassfish.web.deployment.runtime.JspConfig) WebProperty(org.glassfish.web.deployment.runtime.WebProperty) SecurityRoleMapping(com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping) SecurityRoleMapper(org.glassfish.deployment.common.SecurityRoleMapper) IdempotentUrlPattern(com.sun.enterprise.deployment.runtime.web.IdempotentUrlPattern) PrincipalNameDescriptor(com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor) SessionConfig(org.glassfish.web.deployment.runtime.SessionConfig) ServiceReferenceDescriptor(com.sun.enterprise.deployment.ServiceReferenceDescriptor) Role(org.glassfish.security.common.Role) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) Servlet(org.glassfish.web.deployment.runtime.Servlet) ClassLoader(org.glassfish.web.deployment.runtime.ClassLoader) Valve(org.glassfish.web.deployment.runtime.Valve) Application(com.sun.enterprise.deployment.Application) LocaleCharsetInfo(org.glassfish.web.deployment.runtime.LocaleCharsetInfo) Cache(org.glassfish.web.deployment.runtime.Cache)

Aggregations

PrincipalNameDescriptor (com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor)7 SecurityRoleMapping (com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping)3 SecurityRoleMapper (org.glassfish.deployment.common.SecurityRoleMapper)3 Group (org.glassfish.security.common.Group)3 Role (org.glassfish.security.common.Role)3 Application (com.sun.enterprise.deployment.Application)2 ResourcePropertyDescriptor (com.sun.enterprise.deployment.ResourcePropertyDescriptor)2 RuntimeDescriptorNode (com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode)2 RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)2 Node (org.w3c.dom.Node)2 ServiceReferenceDescriptor (com.sun.enterprise.deployment.ServiceReferenceDescriptor)1 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)1 IdempotentUrlPattern (com.sun.enterprise.deployment.runtime.web.IdempotentUrlPattern)1 Cache (org.glassfish.web.deployment.runtime.Cache)1 ClassLoader (org.glassfish.web.deployment.runtime.ClassLoader)1 JspConfig (org.glassfish.web.deployment.runtime.JspConfig)1 LocaleCharsetInfo (org.glassfish.web.deployment.runtime.LocaleCharsetInfo)1 Servlet (org.glassfish.web.deployment.runtime.Servlet)1 SessionConfig (org.glassfish.web.deployment.runtime.SessionConfig)1 SunWebAppImpl (org.glassfish.web.deployment.runtime.SunWebAppImpl)1