Search in sources :

Example 1 with ResourcePropertyDescriptor

use of com.sun.enterprise.deployment.ResourcePropertyDescriptor 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 ResourcePropertyDescriptor

use of com.sun.enterprise.deployment.ResourcePropertyDescriptor 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

ResourcePropertyDescriptor (com.sun.enterprise.deployment.ResourcePropertyDescriptor)2 PrincipalNameDescriptor (com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor)2 SecurityRoleMapping (com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping)2 SecurityRoleMapper (org.glassfish.deployment.common.SecurityRoleMapper)2 Group (org.glassfish.security.common.Group)2 Role (org.glassfish.security.common.Role)2 Application (com.sun.enterprise.deployment.Application)1