1 26 package org.objectweb.jonas.security.jacc; 27 28 import java.util.HashMap ; 29 import java.util.Map ; 30 31 37 public class JPolicyUserRoleMapping { 38 39 42 public static final String GLOBAL_CTXID = "global"; 43 44 48 private static Map jaccIdMappings = new HashMap (); 49 50 53 private JPolicyUserRoleMapping() { 54 } 55 56 62 public static void addUserToRoleMapping(String contextId, String principalName, String [] roles) { 63 Map mapping = (Map ) jaccIdMappings.get(contextId); 64 if (mapping == null) { 65 mapping = new HashMap (); 66 jaccIdMappings.put(contextId, mapping); 67 } 68 mapping.put(principalName, roles); 69 } 70 71 76 public static void addGlobalUserToRoleMapping(String principalName, String [] roles) { 77 addUserToRoleMapping(GLOBAL_CTXID, principalName, roles); 78 } 79 80 87 public static String [] getMappingForPrincipal(String contextId, String principalName) { 88 Map mapping = (Map ) jaccIdMappings.get(contextId); 89 if (mapping == null) { 90 mapping = new HashMap (); 91 jaccIdMappings.put(contextId, mapping); 92 } 93 return (String []) mapping.get(principalName); 94 } 95 96 102 public static String [] getGlobalMappingForPrincipal(String principalName) { 103 return getMappingForPrincipal(GLOBAL_CTXID, principalName); 104 } 105 106 110 public static void removeUserToRoleMapping(String contextId) { 111 jaccIdMappings.remove(contextId); 112 } 113 114 } | Popular Tags |