use of org.wildfly.security.http.oidc.OidcSecurityRealm in project wildfly by wildfly.
the class VirtualHttpServerMechanismFactoryProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (deploymentUnit.getParent() != null || !isVirtualMechanismFactoryRequired(deploymentUnit)) {
// Only interested in installation if this is really the root deployment.
return;
}
ServiceName virtualMechanismFactoryName = virtualMechanismFactoryName(deploymentUnit);
ServiceTarget serviceTarget = phaseContext.getServiceTarget();
ServiceBuilder<?> serviceBuilder = serviceTarget.addService(virtualMechanismFactoryName);
final HttpServerAuthenticationMechanismFactory virtualMechanismFactory = new OidcMechanismFactory();
final Consumer<HttpServerAuthenticationMechanismFactory> mechanismFactoryConsumer = serviceBuilder.provides(virtualMechanismFactoryName);
serviceBuilder.setInstance(Service.newInstance(mechanismFactoryConsumer, virtualMechanismFactory));
serviceBuilder.setInitialMode(Mode.ON_DEMAND);
serviceBuilder.install();
ServiceName virtualDomainName = VirtualDomainMarkerUtility.virtualDomainName(deploymentUnit);
serviceBuilder = serviceTarget.addService(virtualDomainName);
SecurityDomain virtualDomain = SecurityDomain.builder().addRealm(VIRTUAL_REALM, new OidcSecurityRealm()).build().setDefaultRealmName(VIRTUAL_REALM).setPermissionMapper((permissionMappable, roles) -> LoginPermission.getInstance()).build();
Consumer<SecurityDomain> securityDomainConsumer = serviceBuilder.provides(new ServiceName[] { virtualDomainName });
serviceBuilder.setInstance(Service.newInstance(securityDomainConsumer, virtualDomain));
serviceBuilder.setInitialMode(Mode.ON_DEMAND);
serviceBuilder.install();
}
Aggregations