1 23 24 package com.sun.enterprise.security.provider; 25 26 import javax.security.jacc.*; 27 28 import java.util.logging.*; 29 import com.sun.logging.LogDomains; 30 31 import java.util.*; 32 import java.io.File ; 33 34 40 public class PolicyConfigurationFactoryImpl 41 extends PolicyConfigurationFactory{ 42 43 static Map polConfTable = new HashMap(); 45 46 private static Logger logger = 47 Logger.getLogger(LogDomains.SECURITY_LOGGER); 48 49 public PolicyConfigurationFactoryImpl(){ 50 } 51 52 103 public PolicyConfiguration getPolicyConfiguration(String contextId, boolean remove) 104 throws PolicyContextException { 105 106 PolicyConfigurationImpl.checkSetPolicyPermission(); 107 108 if(logger.isLoggable(Level.FINE)){ 109 logger.fine("JACC Policy Provider: Getting PolicyConfiguration object with id = "+ contextId); 110 } 111 112 PolicyConfiguration pc = (PolicyConfiguration)polConfTable.get(contextId); 113 114 if (pc == null){ 117 pc = getPolicyConfigurationImplFromDirectory(contextId,true,remove); 118 if (pc == null) { 119 pc = new PolicyConfigurationImpl(contextId); 120 polConfTable.put(contextId,pc); 121 } 122 } else { 123 ((PolicyConfigurationImpl) pc).initialize(true,remove,false); 126 } 127 return pc; 128 } 129 130 150 public boolean inService(String contextID) throws PolicyContextException{ 151 PolicyConfigurationImpl.checkSetPolicyPermission(); 152 PolicyConfiguration pc = (PolicyConfiguration)polConfTable.get(contextID); 153 154 if (pc == null) { 157 pc = getPolicyConfigurationImplFromDirectory(contextID,false,false); 158 } 159 return pc == null ? false : pc.inService(); 160 } 161 162 166 private static PolicyConfigurationImpl 167 getPolicyConfigurationImplFromDirectory(String contextId, boolean open, boolean remove){ 168 PolicyConfigurationImpl pci = null; 169 File f = new File (PolicyConfigurationImpl.getContextDirectoryName(contextId)); 170 if (f.exists()) { 171 pci = new PolicyConfigurationImpl(f,open,remove); 172 if (pci != null) { 173 polConfTable.put(contextId,pci); 174 } 175 } 176 return pci; 177 } 178 179 182 protected static Collection getPolicyConfigurationImpls() { 183 return polConfTable.values(); 184 } 185 186 protected static PolicyConfigurationImpl 187 putPolicyConfigurationImpl(String contextID, PolicyConfigurationImpl pc) { 188 return (PolicyConfigurationImpl) polConfTable.put(contextID,pc); 189 } 190 191 protected static PolicyConfigurationImpl getPolicyConfigurationImpl(String contextId) { 193 PolicyConfigurationImpl pci = 194 (PolicyConfigurationImpl)polConfTable.get(contextId); 195 if (pci == null) { 196 pci = getPolicyConfigurationImplFromDirectory(contextId,false,false); 199 if (pci == null) { 200 logger.log(Level.WARNING,"pc.unknown_policy_context", 201 new Object []{contextId}); 202 } 203 } 204 return pci; 205 } 206 207 } 208 | Popular Tags |