1 23 24 package com.sun.enterprise.security.jauth; 25 26 import javax.security.auth.Subject ; 27 import javax.security.auth.callback.CallbackHandler ; 28 29 86 public abstract class AuthConfig { 87 88 91 public static final String HTTP = "HTTP"; 92 93 96 public static final String EJB = "EJB"; 97 98 101 public static final String SOAP = "SOAP"; 102 103 private static final String AUTHCONFIG_PROPERTY = "authconfig.provider"; 105 106 private static final String DEFAULT_CLASS = 108 "com.sun.enterprise.security.jauth.ConfigFile"; 109 110 private static AuthConfig config; 111 112 static ClassLoader getClassLoader() { 114 115 final ClassLoader rvalue; 116 117 rvalue = (ClassLoader ) java.security.AccessController.doPrivileged 118 (new java.security.PrivilegedAction () { 119 public Object run() { 120 return Thread.currentThread().getContextClassLoader(); 121 } 122 }); 123 124 return rvalue; 125 }; 126 127 131 protected AuthConfig() { } 132 133 147 public static synchronized AuthConfig getAuthConfig() { 148 154 155 if (config == null) { 156 String config_class = null; 157 config_class = (String ) 158 java.security.AccessController.doPrivileged 159 (new java.security.PrivilegedAction () { 160 public Object run() { 161 return java.security.Security.getProperty 162 (AUTHCONFIG_PROPERTY); 163 } 164 }); 165 if (config_class == null) { 166 config_class = DEFAULT_CLASS; 167 } 168 169 try { 170 final String finalClass = config_class; 171 config = (AuthConfig) 172 java.security.AccessController.doPrivileged 173 (new java.security.PrivilegedExceptionAction () { 174 public Object run() throws ClassNotFoundException , 175 InstantiationException , 176 IllegalAccessException { 177 return Class.forName 178 (finalClass, 179 true, 180 getClassLoader()).newInstance(); 181 } 182 }); 183 } catch (java.security.PrivilegedActionException e) { 184 throw (SecurityException ) 185 new SecurityException ().initCause(e.getException()); 186 } 187 } 188 return config; 189 } 190 191 199 public static void setAuthConfig(AuthConfig config) { 200 207 208 AuthConfig.config = config; 209 } 210 211 255 public abstract ClientAuthContext getClientAuthContext(String intercept, 256 String id, 257 AuthPolicy requestPolicy, 258 AuthPolicy responsePolicy, 259 CallbackHandler handler) 260 throws AuthException; 261 262 306 public abstract ServerAuthContext getServerAuthContext(String intercept, 307 String id, 308 AuthPolicy requestPolicy, 309 AuthPolicy responsePolicy, 310 CallbackHandler handler) 311 throws AuthException; 312 313 317 public abstract void refresh() throws AuthException; 318 } 319 | Popular Tags |