* This is the InvocationHandler callback for the Context interface that was created by our getObjectInstance() method. We
* handle the java:jboss/jaas/domain level operations here.
*/
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Context ctx = new InitialContext();
NameParser parser = ctx.getNameParser("");
String securityDomain = null;
Name name = null;
final JNDIBasedSecurityManagement securityManagement = JNDIBasedSecurityManagement.class.cast(securityManagementValue
.getValue());
final ConcurrentHashMap<String, SecurityDomainContext> securityManagerMap = securityManagement.getSecurityManagerMap();
String methodName = method.getName();
if (methodName.equals("toString"))
return SecurityConstants.JAAS_CONTEXT_ROOT + " Context proxy";
if (methodName.equals("list"))
return new DomainEnumeration(securityManagerMap.keys(), securityManagerMap);
if (methodName.equals("bind") || methodName.equals("rebind")) {
if (args[0] instanceof String)
name = parser.parse((String) args[0]);
else
name = (Name) args[0];
securityDomain = name.get(0);
SecurityDomainContext val = (SecurityDomainContext) args[1];
securityManagerMap.put(securityDomain, val);
return proxy;
}
if (!methodName.equals("lookup"))
throw new OperationNotSupportedException("Operation not supported: " + method);
if (args[0] instanceof String)
name = parser.parse((String) args[0]);
else
name = (Name) args[0];
securityDomain = name.get(0);
SecurityDomainContext securityDomainCtx = lookupSecurityDomain(securityManagement, securityManagerMap, securityDomain);
Object binding = securityDomainCtx.getAuthenticationManager();