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;
}
Aggregations