use of org.jboss.as.security.plugins.JNDIBasedSecurityManagement in project wildfly by wildfly.
the class SecurityDomainJndiInjectable method invoke.
/**
* 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 SecurityLogger.ROOT_LOGGER.operationNotSupported(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();
// Look for requests against the security domain context
if (name.size() == 2) {
String request = name.get(1);
binding = securityDomainCtx.lookup(request);
}
return binding;
}
use of org.jboss.as.security.plugins.JNDIBasedSecurityManagement in project wildfly by wildfly.
the class SecurityDomainService method stop.
/** {@inheritDoc} */
@Override
public void stop(StopContext context) {
SecurityLogger.ROOT_LOGGER.debugf("Stopping security domain service %s", name);
final JNDIBasedSecurityManagement securityManagement = (JNDIBasedSecurityManagement) securityManagementValue.getValue();
securityManagement.removeSecurityDomain(name);
// TODO clear auth cache?
final ApplicationPolicyRegistration applicationPolicyRegistration = (ApplicationPolicyRegistration) configurationValue.getValue();
applicationPolicyRegistration.removeApplicationPolicy(name);
}
use of org.jboss.as.security.plugins.JNDIBasedSecurityManagement in project wildfly by wildfly.
the class SecurityDomainService method start.
/** {@inheritDoc} */
@Override
public void start(StartContext context) throws StartException {
SecurityLogger.ROOT_LOGGER.debugf("Starting SecurityDomainService(%s)", name);
if (applicationPolicy != null) {
final ApplicationPolicyRegistration applicationPolicyRegistration = (ApplicationPolicyRegistration) configurationValue.getValue();
applicationPolicyRegistration.addApplicationPolicy(applicationPolicy.getName(), applicationPolicy);
}
final JNDIBasedSecurityManagement securityManagement = (JNDIBasedSecurityManagement) securityManagementValue.getValue();
AuthenticationCacheFactory cacheFactory = null;
if ("infinispan".equals(cacheType)) {
cacheFactory = new InfinispanAuthenticationCacheFactory(cacheManagerValue.getValue(), name);
} else if ("default".equals(cacheType)) {
cacheFactory = new DefaultAuthenticationCacheFactory();
}
try {
securityDomainContext = securityManagement.createSecurityDomainContext(name, cacheFactory);
} catch (Exception e) {
throw SecurityLogger.ROOT_LOGGER.unableToStartException("SecurityDomainService", e);
}
if (jsseSecurityDomain != null) {
try {
jsseSecurityDomain.reloadKeyAndTrustStore();
securityDomainContext.setJSSE(jsseSecurityDomain);
} catch (Exception e) {
throw SecurityLogger.ROOT_LOGGER.unableToStartException("SecurityDomainService", e);
}
}
securityManagement.getSecurityManagerMap().put(name, securityDomainContext);
}
use of org.jboss.as.security.plugins.JNDIBasedSecurityManagement in project wildfly by wildfly.
the class SecurityManagementService method start.
/** {@inheritDoc} */
@Override
public void start(StartContext context) throws StartException {
SecurityLogger.ROOT_LOGGER.debugf("Starting SecurityManagementService");
// set properties of JNDIBasedSecurityManagement
JNDIBasedSecurityManagement securityManagement = new JNDIBasedSecurityManagement(serviceModuleLoaderValue.getValue());
securityManagement.setAuthenticationManagerClassName(authenticationManagerClassName);
securityManagement.setDeepCopySubjectMode(deepCopySubjectMode);
securityManagement.setCallbackHandlerClassName(callbackHandlerClassName);
securityManagement.setAuthorizationManagerClassName(authorizationManagerClassName);
securityManagement.setAuditManagerClassName(auditManagerClassName);
securityManagement.setIdentityTrustManagerClassName(identityTrustManagerClassName);
securityManagement.setMappingManagerClassName(mappingManagerClassName);
this.securityManagement = securityManagement;
previousSecurityManagement = SecurityFactory.getSecurityManagement();
SecurityFactory.setSecurityManagement(securityManagement);
}
Aggregations