Search in sources :

Example 1 with SecurityMetadata

use of org.jboss.as.connector.metadata.api.common.SecurityMetadata in project wildfly by wildfly.

the class RaOperationUtil method installRaServices.

public static ServiceName installRaServices(OperationContext context, String name, ModifiableResourceAdapter resourceAdapter, final List<ServiceController<?>> newControllers) {
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final ServiceController<?> resourceAdaptersService = context.getServiceRegistry(false).getService(ConnectorServices.RESOURCEADAPTERS_SERVICE);
    if (resourceAdaptersService == null) {
        newControllers.add(serviceTarget.addService(ConnectorServices.RESOURCEADAPTERS_SERVICE, new ResourceAdaptersService()).setInitialMode(ServiceController.Mode.ACTIVE).install());
    }
    ServiceName raServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, name);
    final ServiceController<?> service = context.getServiceRegistry(true).getService(raServiceName);
    if (service == null) {
        ResourceAdapterService raService = new ResourceAdapterService(resourceAdapter, name);
        ServiceBuilder builder = serviceTarget.addService(raServiceName, raService).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(ConnectorServices.RESOURCEADAPTERS_SERVICE, ResourceAdaptersService.ModifiableResourceAdaptors.class, raService.getResourceAdaptersInjector()).addDependency(ConnectorServices.RESOURCEADAPTERS_SUBSYSTEM_SERVICE, CopyOnWriteArrayListMultiMap.class, raService.getResourceAdaptersMapInjector());
        // add dependency on security domain service if applicable for recovery config
        for (ConnectionDefinition cd : resourceAdapter.getConnectionDefinitions()) {
            Security security = cd.getSecurity();
            if (security != null) {
                final boolean elytronEnabled = (security instanceof SecurityMetadata && ((SecurityMetadata) security).isElytronEnabled());
                if (security.getSecurityDomain() != null) {
                    if (!elytronEnabled) {
                        builder.addDependency(SecurityDomainService.SERVICE_NAME.append(security.getSecurityDomain()));
                    } else {
                        builder.addDependency(context.getCapabilityServiceName(AUTHENTICATION_CONTEXT_CAPABILITY, security.getSecurityDomain(), AuthenticationContext.class));
                    }
                }
                if (security.getSecurityDomainAndApplication() != null) {
                    if (!elytronEnabled) {
                        builder.addDependency(SecurityDomainService.SERVICE_NAME.append(security.getSecurityDomainAndApplication()));
                    } else {
                        builder.addDependency(context.getCapabilityServiceName(AUTHENTICATION_CONTEXT_CAPABILITY, security.getSecurityDomainAndApplication(), AuthenticationContext.class));
                    }
                }
                if (cd.getRecovery() != null && cd.getRecovery().getCredential() != null && cd.getRecovery().getCredential().getSecurityDomain() != null) {
                    if (!elytronEnabled) {
                        builder.addDependency(SecurityDomainService.SERVICE_NAME.append(cd.getRecovery().getCredential().getSecurityDomain()));
                    } else {
                        builder.addDependency(context.getCapabilityServiceName(AUTHENTICATION_CONTEXT_CAPABILITY, cd.getRecovery().getCredential().getSecurityDomain(), AuthenticationContext.class));
                    }
                }
            }
        }
        if (resourceAdapter.getWorkManager() != null) {
            final WorkManagerSecurity workManagerSecurity = resourceAdapter.getWorkManager().getSecurity();
            if (workManagerSecurity != null) {
                final boolean elytronEnabled = (workManagerSecurity instanceof org.jboss.as.connector.metadata.api.resourceadapter.WorkManagerSecurity) && ((org.jboss.as.connector.metadata.api.resourceadapter.WorkManagerSecurity) workManagerSecurity).isElytronEnabled();
                final String securityDomainName = workManagerSecurity.getDomain();
                if (securityDomainName != null) {
                    if (!elytronEnabled) {
                        builder.addDependency(SecurityDomainService.SERVICE_NAME.append(securityDomainName));
                    } else {
                        builder.addDependency(context.getCapabilityServiceName(ELYTRON_SECURITY_DOMAIN_CAPABILITY, securityDomainName, SecurityDomain.class));
                    }
                }
            }
        }
        newControllers.add(builder.install());
    }
    return raServiceName;
}
Also used : ConnectionDefinition(org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition) AuthenticationContext(org.wildfly.security.auth.client.AuthenticationContext) ServiceTarget(org.jboss.msc.service.ServiceTarget) WorkManagerSecurity(org.jboss.jca.common.api.metadata.resourceadapter.WorkManagerSecurity) Security(org.jboss.jca.common.api.metadata.common.Security) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain) WorkManagerSecurity(org.jboss.jca.common.api.metadata.resourceadapter.WorkManagerSecurity) ServiceName(org.jboss.msc.service.ServiceName) SecurityMetadata(org.jboss.as.connector.metadata.api.common.SecurityMetadata)

Aggregations

SecurityMetadata (org.jboss.as.connector.metadata.api.common.SecurityMetadata)1 Security (org.jboss.jca.common.api.metadata.common.Security)1 ConnectionDefinition (org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition)1 WorkManagerSecurity (org.jboss.jca.common.api.metadata.resourceadapter.WorkManagerSecurity)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 AuthenticationContext (org.wildfly.security.auth.client.AuthenticationContext)1 SecurityDomain (org.wildfly.security.auth.server.SecurityDomain)1