FileDocCategorySizeDatePackage
SecurityMapUtils.javaAPI DocGlassfish v2 API6235Fri May 04 22:34:26 BST 2007com.sun.enterprise.connectors.util

SecurityMapUtils

public class SecurityMapUtils extends Object
This is class performs the task of adding/deleting and updating the security maps to the connector registry.
author
Srikanth P

Fields Summary
private static com.sun.enterprise.connectors.ConnectorRegistry
_registry
public static final String
USERMAP
public static final String
GROUPMAP
Constructors Summary
Methods Summary
private static com.sun.enterprise.connectors.authentication.ConnectorSecurityMapconvertSecurityMapConfigBeanToSecurityMap(com.sun.enterprise.config.serverbeans.SecurityMap securityMap)


        String name = securityMap.getName();
        String[] principal = securityMap.getPrincipal();
        String[] userGroup = securityMap.getUserGroup();
        EisBackendPrincipal backendPrincipal = transformBackendPrincipal(securityMap
                .getBackendPrincipal());
        ConnectorSecurityMap convertedSecurityMap = new ConnectorSecurityMap(
                name, principal, userGroup, backendPrincipal);

        return convertedSecurityMap;
    
private static com.sun.enterprise.deployment.ResourcePrincipalgenerateResourcePrincipal(com.sun.enterprise.connectors.authentication.ConnectorSecurityMap securityMap)
Creates the ResourcePrincipal object from the given securityMap

param
securityMap SecurityMap
return
created ResourcePrincipal object


        EisBackendPrincipal backendPrincipal = securityMap.getBackendPrincipal();
        String userName = backendPrincipal.getUserName();
        String password = backendPrincipal.getPassword();
        ResourcePrincipal resPrincipal = 
                      new ResourcePrincipal(userName,password);
        return resPrincipal;
    
public static com.sun.enterprise.connectors.authentication.ConnectorSecurityMap[]getConnectorSecurityMaps(com.sun.enterprise.config.serverbeans.SecurityMap[] securityMaps)


        ConnectorSecurityMap[] maps = new ConnectorSecurityMap[securityMaps.length];
        for (int i = 0; i < securityMaps.length; i++) {
            maps[i] = convertSecurityMapConfigBeanToSecurityMap(securityMaps[i]);
        }
        return maps;
    
public static com.sun.enterprise.connectors.authentication.RuntimeSecurityMapprocessSecurityMaps(com.sun.enterprise.connectors.authentication.ConnectorSecurityMap[] securityMaps)
Updates the registry with the security map. If a security map already exists it deletes that map completely before adding the mew security map.

param
securityMaps Array of securityMaps to be updated.
return
Hash Map containing 1 - 1 mappings of principal and Resource Principal


                                                       		       
  
       
              
        if (securityMaps == null || securityMaps.length == 0) {
            return new RuntimeSecurityMap();
        }

        HashMap userMap = new HashMap();
        HashMap groupMap = new HashMap();
        // Add user-backendPrincipal mappings to Map1
        for (int i = 0; i < securityMaps.length; i++) {
            ConnectorSecurityMap map = securityMaps[i];
            ResourcePrincipal principal = generateResourcePrincipal(map);

            String[] principalNames = map.getPrincipals();
            for (int j = 0; j < principalNames.length; j++) {
                userMap.put(principalNames[j], principal);
            }

            String[] groupNames = map.getUserGroups();
            for (int j = 0; j < groupNames.length; j++) {
                groupMap.put(groupNames[j], principal);
            }
        }

        RuntimeSecurityMap runtimeSecurityMap = new RuntimeSecurityMap(userMap,
                groupMap);

        return runtimeSecurityMap;
    
private static com.sun.enterprise.connectors.authentication.EisBackendPrincipaltransformBackendPrincipal(com.sun.enterprise.config.serverbeans.BackendPrincipal principal)

    	String userName = principal.getUserName();
        String password = principal.getPassword();
        EisBackendPrincipal backendPrincipal = 
        			  new EisBackendPrincipal(userName, password);
    	return backendPrincipal;