Search in sources :

Example 1 with JNDIBasedSecurityManagement

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;
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) SecurityDomainContext(org.jboss.as.security.plugins.SecurityDomainContext) InitialContext(javax.naming.InitialContext) NameParser(javax.naming.NameParser) SecurityDomainContext(org.jboss.as.security.plugins.SecurityDomainContext) Name(javax.naming.Name) JNDIBasedSecurityManagement(org.jboss.as.security.plugins.JNDIBasedSecurityManagement)

Example 2 with JNDIBasedSecurityManagement

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);
}
Also used : ApplicationPolicyRegistration(org.jboss.security.config.ApplicationPolicyRegistration) JNDIBasedSecurityManagement(org.jboss.as.security.plugins.JNDIBasedSecurityManagement)

Example 3 with JNDIBasedSecurityManagement

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);
}
Also used : InfinispanAuthenticationCacheFactory(org.jboss.as.security.plugins.InfinispanAuthenticationCacheFactory) DefaultAuthenticationCacheFactory(org.jboss.as.security.plugins.DefaultAuthenticationCacheFactory) InfinispanAuthenticationCacheFactory(org.jboss.as.security.plugins.InfinispanAuthenticationCacheFactory) AuthenticationCacheFactory(org.jboss.as.security.plugins.AuthenticationCacheFactory) DefaultAuthenticationCacheFactory(org.jboss.as.security.plugins.DefaultAuthenticationCacheFactory) ApplicationPolicyRegistration(org.jboss.security.config.ApplicationPolicyRegistration) StartException(org.jboss.msc.service.StartException) JNDIBasedSecurityManagement(org.jboss.as.security.plugins.JNDIBasedSecurityManagement)

Example 4 with JNDIBasedSecurityManagement

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);
}
Also used : JNDIBasedSecurityManagement(org.jboss.as.security.plugins.JNDIBasedSecurityManagement)

Aggregations

JNDIBasedSecurityManagement (org.jboss.as.security.plugins.JNDIBasedSecurityManagement)4 ApplicationPolicyRegistration (org.jboss.security.config.ApplicationPolicyRegistration)2 Context (javax.naming.Context)1 InitialContext (javax.naming.InitialContext)1 Name (javax.naming.Name)1 NameParser (javax.naming.NameParser)1 AuthenticationCacheFactory (org.jboss.as.security.plugins.AuthenticationCacheFactory)1 DefaultAuthenticationCacheFactory (org.jboss.as.security.plugins.DefaultAuthenticationCacheFactory)1 InfinispanAuthenticationCacheFactory (org.jboss.as.security.plugins.InfinispanAuthenticationCacheFactory)1 SecurityDomainContext (org.jboss.as.security.plugins.SecurityDomainContext)1 StartException (org.jboss.msc.service.StartException)1