Search in sources :

Example 6 with ServiceContainer

use of org.jboss.msc.service.ServiceContainer in project wildfly by wildfly.

the class ElytronSecurityIntegration method createCallbackHandler.

@Override
public CallbackHandler createCallbackHandler(final Callback callback) {
    assert callback != null;
    // TODO switch to use the elytron security domain once the callback has that info available.
    final String securityDomainName = callback.getDomain();
    // get domain reference from the service container and create the callback handler using the domain.
    if (securityDomainName != null) {
        final ServiceContainer container = this.currentServiceContainer();
        final ServiceName securityDomainServiceName = SECURITY_DOMAIN_RUNTIME_CAPABILITY.getCapabilityServiceName(securityDomainName);
        final SecurityDomain securityDomain = (SecurityDomain) container.getRequiredService(securityDomainServiceName).getValue();
        return new ElytronCallbackHandler(securityDomain, callback);
    }
    // TODO use subsystem logger for the exception.
    throw ConnectorLogger.ROOT_LOGGER.invalidCallbackSecurityDomain();
}
Also used : ServiceContainer(org.jboss.msc.service.ServiceContainer) CurrentServiceContainer(org.jboss.as.server.CurrentServiceContainer) ServiceName(org.jboss.msc.service.ServiceName) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain)

Example 7 with ServiceContainer

use of org.jboss.msc.service.ServiceContainer in project wildfly by wildfly.

the class ElytronSubjectFactory method createSubject.

/**
     * {@inheritDoc}
     */
public Subject createSubject(final String authenticationContextName) {
    AuthenticationContext context;
    if (authenticationContextName != null && !authenticationContextName.isEmpty()) {
        final ServiceContainer container = this.currentServiceContainer();
        final ServiceName authContextServiceName = AUTHENTICATION_CONTEXT_RUNTIME_CAPABILITY.getCapabilityServiceName(authenticationContextName);
        context = (AuthenticationContext) container.getRequiredService(authContextServiceName).getValue();
    } else {
        context = getAuthenticationContext();
    }
    final Subject subject = this.createSubject(context);
    if (ROOT_LOGGER.isTraceEnabled()) {
        ROOT_LOGGER.subject(subject, Integer.toHexString(System.identityHashCode(subject)));
    }
    return subject;
}
Also used : AuthenticationContext(org.wildfly.security.auth.client.AuthenticationContext) ServiceContainer(org.jboss.msc.service.ServiceContainer) CurrentServiceContainer(org.jboss.as.server.CurrentServiceContainer) ServiceName(org.jboss.msc.service.ServiceName) Subject(javax.security.auth.Subject)

Example 8 with ServiceContainer

use of org.jboss.msc.service.ServiceContainer in project wildfly by wildfly.

the class InfinispanCacheDeploymentListener method startCache.

@Override
public Wrapper startCache(Classification classification, Properties properties) throws Exception {
    String cache_type = properties.getProperty(CACHE_TYPE);
    String container = properties.getProperty(CONTAINER);
    // TODO Figure out how to access CapabilityServiceSupport from here
    ServiceName containerServiceName = ServiceName.parse(InfinispanRequirement.CONTAINER.resolve(container));
    EmbeddedCacheManager embeddedCacheManager;
    ServiceName serviceName;
    if (CACHE_PRIVATE.equals(cache_type)) {
        // need a private cache for non-jpa application use
        String name = properties.getProperty(NAME);
        serviceName = ServiceName.JBOSS.append(DEFAULT_CACHE_CONTAINER, (name != null) ? name : UUID.randomUUID().toString());
        ServiceContainer target = currentServiceContainer();
        // Create a mock service that represents this session factory instance
        ServiceBuilder<EmbeddedCacheManager> builder = new AliasServiceBuilder<>(serviceName, containerServiceName, EmbeddedCacheManager.class).build(target).setInitialMode(ServiceController.Mode.ACTIVE);
        embeddedCacheManager = ServiceContainerHelper.getValue(builder.install());
    } else {
        // need a shared cache for jpa applications
        serviceName = containerServiceName;
        ServiceRegistry registry = currentServiceContainer();
        embeddedCacheManager = (EmbeddedCacheManager) registry.getRequiredService(serviceName).getValue();
    }
    return new CacheWrapper(embeddedCacheManager, serviceName);
}
Also used : ServiceContainer(org.jboss.msc.service.ServiceContainer) CurrentServiceContainer(org.jboss.as.server.CurrentServiceContainer) ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) AliasServiceBuilder(org.wildfly.clustering.service.AliasServiceBuilder)

Example 9 with ServiceContainer

use of org.jboss.msc.service.ServiceContainer in project wildfly by wildfly.

the class ModClusterResource method service.

static ModClusterService service(String name) {
    final ServiceContainer serviceContainer = CurrentServiceContainer.getServiceContainer();
    if (serviceContainer == null) {
        //for tests
        return null;
    }
    ServiceController<?> cluster = serviceContainer.getService(UndertowService.FILTER.append(name));
    if (cluster == null) {
        return null;
    }
    return (ModClusterService) cluster.getService();
}
Also used : ServiceContainer(org.jboss.msc.service.ServiceContainer) CurrentServiceContainer(org.jboss.as.server.CurrentServiceContainer)

Aggregations

ServiceContainer (org.jboss.msc.service.ServiceContainer)9 CurrentServiceContainer (org.jboss.as.server.CurrentServiceContainer)6 ServiceName (org.jboss.msc.service.ServiceName)5 StartException (org.jboss.msc.service.StartException)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 Subject (javax.security.auth.Subject)1 DataSource (javax.sql.DataSource)1 ActiveMQPrincipal (org.apache.activemq.artemis.core.security.ActiveMQPrincipal)1 ActivateCallback (org.apache.activemq.artemis.core.server.ActivateCallback)1 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 SetupAction (org.jboss.as.server.deployment.SetupAction)1 CommonDataSource (org.jboss.jca.common.api.metadata.ds.CommonDataSource)1 XaDataSource (org.jboss.jca.common.api.metadata.ds.XaDataSource)1 AbstractServiceListener (org.jboss.msc.service.AbstractServiceListener)1 ServiceController (org.jboss.msc.service.ServiceController)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1 AliasServiceBuilder (org.wildfly.clustering.service.AliasServiceBuilder)1 ActiveMQActivationService (org.wildfly.extension.messaging.activemq.ActiveMQActivationService)1 AuthenticationContext (org.wildfly.security.auth.client.AuthenticationContext)1