| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package javax.security.auth.message.config; |
| 18 | |
|
| 19 | |
import java.security.PrivilegedActionException; |
| 20 | |
import java.util.Map; |
| 21 | |
|
| 22 | |
import javax.security.auth.AuthPermission; |
| 23 | |
import javax.security.auth.message.AuthException; |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | 0 | public abstract class AuthConfigFactory { |
| 29 | |
|
| 30 | |
public static final String DEFAULT_FACTORY_SECURITY_PROPERTY = "authconfigprovider.factory"; |
| 31 | |
private static final String DEFAULT_JASPI_AUTHCONFIGFACTORYIMPL = "org.apache.geronimo.components.jaspi.AuthConfigFactoryImpl"; |
| 32 | |
|
| 33 | |
private static AuthConfigFactory factory; |
| 34 | |
private static ClassLoader contextClassLoader; |
| 35 | |
|
| 36 | |
static { |
| 37 | 0 | contextClassLoader = (ClassLoader) java.security.AccessController |
| 38 | 0 | .doPrivileged(new java.security.PrivilegedAction() { |
| 39 | |
public Object run() { |
| 40 | 0 | return Thread.currentThread().getContextClassLoader(); |
| 41 | |
} |
| 42 | |
}); |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
public static AuthConfigFactory getFactory() { |
| 46 | 0 | SecurityManager sm = System.getSecurityManager(); |
| 47 | 0 | if (sm != null) { |
| 48 | 0 | sm.checkPermission(new AuthPermission("getAuthConfigFactory")); |
| 49 | |
} |
| 50 | 0 | if (factory == null) { |
| 51 | 0 | String className = (String) java.security.AccessController |
| 52 | 0 | .doPrivileged(new java.security.PrivilegedAction() { |
| 53 | |
public Object run() { |
| 54 | 0 | return java.security.Security.getProperty(DEFAULT_FACTORY_SECURITY_PROPERTY); |
| 55 | |
} |
| 56 | |
}); |
| 57 | 0 | if (className == null) { |
| 58 | 0 | className = DEFAULT_JASPI_AUTHCONFIGFACTORYIMPL; |
| 59 | |
} |
| 60 | |
try { |
| 61 | 0 | final String finalClassName = className; |
| 62 | 0 | factory = (AuthConfigFactory) java.security.AccessController |
| 63 | 0 | .doPrivileged(new java.security.PrivilegedExceptionAction() { |
| 64 | |
public Object run() throws ClassNotFoundException, InstantiationException, |
| 65 | |
IllegalAccessException { |
| 66 | 0 | return Class.forName(finalClassName, true, contextClassLoader).newInstance(); |
| 67 | |
} |
| 68 | |
}); |
| 69 | 0 | } catch (PrivilegedActionException e) { |
| 70 | 0 | Exception inner = e.getException(); |
| 71 | 0 | if (inner instanceof InstantiationException) { |
| 72 | 0 | throw (SecurityException) new SecurityException("AuthConfigFactory error:" |
| 73 | |
+ inner.getCause().getMessage()).initCause(inner.getCause()); |
| 74 | |
} else { |
| 75 | 0 | throw (SecurityException) new SecurityException("AuthConfigFactory error: " + inner).initCause(inner); |
| 76 | |
} |
| 77 | 0 | } |
| 78 | |
} |
| 79 | 0 | return factory; |
| 80 | |
} |
| 81 | |
|
| 82 | |
public static void setFactory(AuthConfigFactory factory) { |
| 83 | 0 | SecurityManager sm = System.getSecurityManager(); |
| 84 | 0 | if (sm != null) { |
| 85 | 0 | sm.checkPermission(new AuthPermission("setAuthConfigFactory")); |
| 86 | |
} |
| 87 | 0 | AuthConfigFactory.factory = factory; |
| 88 | 0 | } |
| 89 | |
|
| 90 | |
|
| 91 | 0 | public AuthConfigFactory() { |
| 92 | 0 | } |
| 93 | |
|
| 94 | |
public abstract String[] detachListener(RegistrationListener listener, String layer, String appContext); |
| 95 | |
|
| 96 | |
public abstract AuthConfigProvider getConfigProvider(String layer, String appContext, RegistrationListener listener); |
| 97 | |
|
| 98 | |
public abstract RegistrationContext getRegistrationContext(String registrationID); |
| 99 | |
|
| 100 | |
public abstract String[] getRegistrationIDs(AuthConfigProvider provider); |
| 101 | |
|
| 102 | |
public abstract void refresh(); |
| 103 | |
|
| 104 | |
public abstract String registerConfigProvider(AuthConfigProvider provider, String layer, String appContext, String description); |
| 105 | |
|
| 106 | |
public abstract String registerConfigProvider(String className, Map properties, String layer, String appContext, String description); |
| 107 | |
|
| 108 | |
public abstract boolean removeRegistration(String registrationID); |
| 109 | |
|
| 110 | |
public static interface RegistrationContext { |
| 111 | |
|
| 112 | |
String getAppContext(); |
| 113 | |
|
| 114 | |
String getDescription(); |
| 115 | |
|
| 116 | |
String getMessageLayer(); |
| 117 | |
|
| 118 | |
boolean isPersistent(); |
| 119 | |
|
| 120 | |
} |
| 121 | |
|
| 122 | |
} |