Search in sources :

Example 6 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 7 with PrincipalNameDescriptor

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

the class ApplicationRuntimeNode method addDescriptor.

/**
 * Adds  a new DOL descriptor instance to the descriptor instance associated with
 * this XMLNode
 *
 * @param newDescriptor the new descriptor
 */
public void addDescriptor(Object newDescriptor) {
    if (newDescriptor instanceof SecurityRoleMapping) {
        SecurityRoleMapping roleMap = (SecurityRoleMapping) newDescriptor;
        if (descriptor != null && !descriptor.isVirtual()) {
            descriptor.addSecurityRoleMapping(roleMap);
            Role role = new Role(roleMap.getRoleName());
            SecurityRoleMapper rm = descriptor.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)

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