use of org.wildfly.extension.undertow.security.sso.DistributableHostSingleSignOnManagerBuilder in project wildfly by wildfly.
the class HostSingleSignOnServiceHandler method installServices.
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
PathAddress hostAddress = address.getParent();
PathAddress serverAddress = hostAddress.getParent();
String hostName = hostAddress.getLastElement().getValue();
String serverName = serverAddress.getLastElement().getValue();
String domain = ModelNodes.optionalString(DOMAIN.resolveModelAttribute(context, model)).orElse(null);
String path = PATH.resolveModelAttribute(context, model).asString();
boolean secure = SECURE.resolveModelAttribute(context, model).asBoolean();
boolean httpOnly = HTTP_ONLY.resolveModelAttribute(context, model).asBoolean();
String cookieName = COOKIE_NAME.resolveModelAttribute(context, model).asString();
ServiceName serviceName = UndertowService.ssoServiceName(serverName, hostName);
ServiceName virtualHostServiceName = UndertowService.virtualHostName(serverName, hostName);
ServiceTarget target = context.getServiceTarget();
ServiceName managerServiceName = serviceName.append("manager");
if (DistributableHostSingleSignOnManagerBuilder.INSTANCE.isPresent()) {
DistributableHostSingleSignOnManagerBuilder builder = DistributableHostSingleSignOnManagerBuilder.INSTANCE.get();
builder.build(target, managerServiceName, context.getCapabilityServiceSupport(), serverName, hostName).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
} else {
target.addService(managerServiceName, new ValueService<>(new ImmediateValue<>(new InMemorySingleSignOnManager()))).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
SingleSignOnService service = new SingleSignOnService(domain, path, httpOnly, secure, cookieName);
target.addService(serviceName, service).addDependency(virtualHostServiceName, Host.class, service.getHost()).addDependency(managerServiceName, SingleSignOnManager.class, service.getSingleSignOnSessionManager()).setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Aggregations