1 7 8 package javax.security.auth; 9 10 138 @Deprecated 139 public abstract class Policy { 140 141 private static Policy policy; 142 private static ClassLoader contextClassLoader; 143 144 static { 145 contextClassLoader = 146 (ClassLoader )java.security.AccessController.doPrivileged 147 (new java.security.PrivilegedAction () { 148 public Object run() { 149 return Thread.currentThread().getContextClassLoader(); 150 } 151 }); 152 }; 153 154 158 protected Policy() { } 159 160 177 public static Policy getPolicy() { 178 java.lang.SecurityManager sm = System.getSecurityManager(); 179 if (sm != null) sm.checkPermission(new AuthPermission ("getPolicy")); 180 return getPolicyNoCheck(); 181 } 182 183 189 static Policy getPolicyNoCheck() { 190 if (policy == null) { 191 192 synchronized(Policy .class) { 193 194 if (policy == null) { 195 String policy_class = null; 196 policy_class = (String ) 197 java.security.AccessController.doPrivileged 198 (new java.security.PrivilegedAction () { 199 public Object run() { 200 return java.security.Security.getProperty 201 ("auth.policy.provider"); 202 } 203 }); 204 if (policy_class == null) { 205 policy_class = "com.sun.security.auth.PolicyFile"; 206 } 207 208 try { 209 final String finalClass = policy_class; 210 policy = (Policy ) 211 java.security.AccessController.doPrivileged 212 (new java.security.PrivilegedExceptionAction () { 213 public Object run() throws ClassNotFoundException , 214 InstantiationException , 215 IllegalAccessException { 216 return Class.forName 217 (finalClass, 218 true, 219 contextClassLoader).newInstance(); 220 } 221 }); 222 } catch (Exception e) { 223 throw new SecurityException 224 (sun.security.util.ResourcesMgr.getString 225 ("unable to instantiate Subject-based policy")); 226 } 227 } 228 } 229 } 230 return policy; 231 } 232 233 234 249 public static void setPolicy(Policy policy) { 250 java.lang.SecurityManager sm = System.getSecurityManager(); 251 if (sm != null) sm.checkPermission(new AuthPermission ("setPolicy")); 252 Policy.policy = policy; 253 } 254 255 279 public abstract java.security.PermissionCollection getPermissions 280 (Subject subject, 281 java.security.CodeSource cs); 282 283 296 public abstract void refresh(); 297 } 298 | Popular Tags |