Search in sources :

Example 1 with OidcSecurityRealm

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();
}
Also used : OidcSecurityRealm(org.wildfly.security.http.oidc.OidcSecurityRealm) VirtualHttpServerMechanismFactoryMarkerUtility.virtualMechanismFactoryName(org.jboss.as.web.common.VirtualHttpServerMechanismFactoryMarkerUtility.virtualMechanismFactoryName) DeploymentPhaseContext(org.jboss.as.server.deployment.DeploymentPhaseContext) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) Mode(org.jboss.msc.service.ServiceController.Mode) VirtualHttpServerMechanismFactoryMarkerUtility.isVirtualMechanismFactoryRequired(org.jboss.as.web.common.VirtualHttpServerMechanismFactoryMarkerUtility.isVirtualMechanismFactoryRequired) Service(org.jboss.msc.Service) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) Consumer(java.util.function.Consumer) LoginPermission(org.wildfly.security.auth.permission.LoginPermission) HttpServerAuthenticationMechanismFactory(org.wildfly.security.http.HttpServerAuthenticationMechanismFactory) ServiceName(org.jboss.msc.service.ServiceName) OidcMechanismFactory(org.wildfly.security.http.oidc.OidcMechanismFactory) DeploymentUnitProcessor(org.jboss.as.server.deployment.DeploymentUnitProcessor) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ServiceTarget(org.jboss.msc.service.ServiceTarget) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain) VirtualDomainMarkerUtility(org.jboss.as.server.security.VirtualDomainMarkerUtility) HttpServerAuthenticationMechanismFactory(org.wildfly.security.http.HttpServerAuthenticationMechanismFactory) OidcSecurityRealm(org.wildfly.security.http.oidc.OidcSecurityRealm) ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) OidcMechanismFactory(org.wildfly.security.http.oidc.OidcMechanismFactory) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) SecurityDomain(org.wildfly.security.auth.server.SecurityDomain)

Aggregations

Consumer (java.util.function.Consumer)1 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 DeploymentUnitProcessor (org.jboss.as.server.deployment.DeploymentUnitProcessor)1 VirtualDomainMarkerUtility (org.jboss.as.server.security.VirtualDomainMarkerUtility)1 VirtualHttpServerMechanismFactoryMarkerUtility.isVirtualMechanismFactoryRequired (org.jboss.as.web.common.VirtualHttpServerMechanismFactoryMarkerUtility.isVirtualMechanismFactoryRequired)1 VirtualHttpServerMechanismFactoryMarkerUtility.virtualMechanismFactoryName (org.jboss.as.web.common.VirtualHttpServerMechanismFactoryMarkerUtility.virtualMechanismFactoryName)1 Service (org.jboss.msc.Service)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 Mode (org.jboss.msc.service.ServiceController.Mode)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 LoginPermission (org.wildfly.security.auth.permission.LoginPermission)1 SecurityDomain (org.wildfly.security.auth.server.SecurityDomain)1 HttpServerAuthenticationMechanismFactory (org.wildfly.security.http.HttpServerAuthenticationMechanismFactory)1 OidcMechanismFactory (org.wildfly.security.http.oidc.OidcMechanismFactory)1 OidcSecurityRealm (org.wildfly.security.http.oidc.OidcSecurityRealm)1