use of org.wildfly.extension.picketlink.federation.config.IDPConfiguration in project wildfly by wildfly.
the class FederationDependencyProcessor method getFederationService.
private ServiceName getFederationService(DeploymentPhaseContext phaseContext) {
DeploymentUnit deployment = phaseContext.getDeploymentUnit();
ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();
// We assume the mgmt ops that trigger IdentityProviderAddHandler or ServiceProviderAddHandler
// run before the OperationStepHandler that triggers deploy. If not, that's a user mistake.
// Since those handlers run first, we can count on MSC having services *registered* even
// though we cannot count on them being *started*.
ServiceController<?> service = serviceRegistry.getService(IdentityProviderService.createServiceName(deployment.getName()));
if (service == null) {
service = serviceRegistry.getService(ServiceProviderService.createServiceName(deployment.getName()));
} else {
IdentityProviderService identityProviderService = (IdentityProviderService) service.getService();
IDPConfiguration idpType = identityProviderService.getValue().getConfiguration();
if (idpType.isExternal()) {
return null;
}
}
if (service == null) {
return null;
}
return service.getName();
}
use of org.wildfly.extension.picketlink.federation.config.IDPConfiguration in project wildfly by wildfly.
the class IdentityProviderAddHandler method toIDPConfig.
static IDPConfiguration toIDPConfig(OperationContext context, ModelNode fromModel, String alias) throws OperationFailedException {
IDPConfiguration idpType = new IDPConfiguration(alias);
boolean external = IdentityProviderResourceDefinition.EXTERNAL.resolveModelAttribute(context, fromModel).asBoolean();
idpType.setExternal(external);
String url = IdentityProviderResourceDefinition.URL.resolveModelAttribute(context, fromModel).asString();
idpType.setIdentityURL(url);
if (!idpType.isExternal()) {
ModelNode securityDomain = IdentityProviderResourceDefinition.SECURITY_DOMAIN.resolveModelAttribute(context, fromModel);
if (securityDomain.isDefined()) {
idpType.setSecurityDomain(securityDomain.asString());
} else {
throw ROOT_LOGGER.requiredAttribute(ModelElement.COMMON_SECURITY_DOMAIN.getName(), alias);
}
boolean supportsSignatures = IdentityProviderResourceDefinition.SUPPORT_SIGNATURES.resolveModelAttribute(context, fromModel).asBoolean();
idpType.setSupportsSignature(supportsSignatures);
boolean supportsMetadata = IdentityProviderResourceDefinition.SUPPORT_METADATA.resolveModelAttribute(context, fromModel).asBoolean();
idpType.setSupportMetadata(supportsMetadata);
boolean encrypt = IdentityProviderResourceDefinition.ENCRYPT.resolveModelAttribute(context, fromModel).asBoolean();
idpType.setEncrypt(encrypt);
boolean sslAuthentication = IdentityProviderResourceDefinition.SSL_AUTHENTICATION.resolveModelAttribute(context, fromModel).asBoolean();
idpType.setSSLClientAuthentication(sslAuthentication);
boolean strictPostBinding = IdentityProviderResourceDefinition.STRICT_POST_BINDING.resolveModelAttribute(context, fromModel).asBoolean();
idpType.setStrictPostBinding(strictPostBinding);
ModelNode roleGenerator = fromModel.get(ModelElement.IDENTITY_PROVIDER_ROLE_GENERATOR.getName());
String roleGeneratorType;
if (roleGenerator.isDefined()) {
ModelNode roleGeneratorValue = roleGenerator.asProperty().getValue();
ModelNode classNameNode = RoleGeneratorResourceDefinition.CLASS_NAME.resolveModelAttribute(context, roleGeneratorValue);
ModelNode codeNode = RoleGeneratorResourceDefinition.CODE.resolveModelAttribute(context, roleGeneratorValue);
if (classNameNode.isDefined()) {
roleGeneratorType = classNameNode.asString();
} else if (codeNode.isDefined()) {
roleGeneratorType = RoleGeneratorTypeEnum.forType(codeNode.asString());
} else {
throw ROOT_LOGGER.typeNotProvided(IDENTITY_PROVIDER_ROLE_GENERATOR.getName());
}
} else {
roleGeneratorType = UndertowRoleGenerator.class.getName();
}
idpType.setRoleGenerator(roleGeneratorType);
ModelNode attributeManager = fromModel.get(ModelElement.IDENTITY_PROVIDER_ATTRIBUTE_MANAGER.getName());
String attributeManagerType;
if (attributeManager.isDefined()) {
ModelNode attributeManagerValue = attributeManager.asProperty().getValue();
ModelNode classNameNode = AttributeManagerResourceDefinition.CLASS_NAME.resolveModelAttribute(context, attributeManagerValue);
ModelNode codeNode = AttributeManagerResourceDefinition.CODE.resolveModelAttribute(context, attributeManagerValue);
if (classNameNode.isDefined()) {
attributeManagerType = classNameNode.asString();
} else if (codeNode.isDefined()) {
attributeManagerType = AttributeManagerTypeEnum.forType(codeNode.asString());
} else {
throw ROOT_LOGGER.typeNotProvided(IDENTITY_PROVIDER_ATTRIBUTE_MANAGER.getName());
}
} else {
attributeManagerType = UndertowAttributeManager.class.getName();
}
idpType.setAttributeManager(attributeManagerType);
}
return idpType;
}
use of org.wildfly.extension.picketlink.federation.config.IDPConfiguration in project wildfly by wildfly.
the class DomainModelConfigProvider method getIDPConfiguration.
@Override
public IDPType getIDPConfiguration() {
ProviderType providerType = getPicketLinkConfiguration().getIdpOrSP();
if (providerType instanceof IDPConfiguration) {
IDPConfiguration configuration = (IDPConfiguration) providerType;
if (configuration.isSupportMetadata()) {
try {
IDPType metadataConfig = new IDPMetadataConfigurationProvider().getIDPConfiguration();
metadataConfig.importFrom(configuration);
providerType = metadataConfig;
} catch (ProcessingException e) {
throw PicketLinkLogger.ROOT_LOGGER.federationSAMLMetadataConfigError(configuration.getAlias(), e);
}
}
if (configParsedIDPType != null) {
configuration.importFrom(configParsedIDPType);
}
return (IDPType) providerType;
}
return null;
}
use of org.wildfly.extension.picketlink.federation.config.IDPConfiguration in project wildfly by wildfly.
the class ServiceProviderService method configureIdentityProvider.
private void configureIdentityProvider() {
IDPConfiguration idpConfiguration = getFederationService().getValue().getIdpConfiguration();
if (idpConfiguration == null) {
throw PicketLinkLogger.ROOT_LOGGER.federationIdentityProviderNotConfigured(getFederationService().getValue().getAlias());
}
getConfiguration().setIdentityURL(idpConfiguration.getIdentityURL());
}
use of org.wildfly.extension.picketlink.federation.config.IDPConfiguration in project wildfly by wildfly.
the class IdentityProviderAddHandler method launchServices.
static void launchServices(OperationContext context, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers, PathAddress pathAddress, boolean isRestart) throws OperationFailedException {
String alias = pathAddress.getLastElement().getValue();
IdentityProviderService service = new IdentityProviderService(toIDPConfig(context, model, alias));
ServiceBuilder<IdentityProviderService> serviceBuilder = context.getServiceTarget().addService(IdentityProviderService.createServiceName(alias), service);
String federationAlias = pathAddress.subAddress(0, pathAddress.size() - 1).getLastElement().getValue();
serviceBuilder.addDependency(FederationService.createServiceName(federationAlias), FederationService.class, service.getFederationService());
configureHandler(context, model, service);
IDPConfiguration configuration = service.getConfiguration();
if (!configuration.isExternal()) {
serviceBuilder.addDependency(SecurityDomainService.SERVICE_NAME.append(configuration.getSecurityDomain()));
}
if (verificationHandler != null) {
serviceBuilder.addListener(verificationHandler);
}
ServiceController<IdentityProviderService> controller = serviceBuilder.install();
if (newControllers != null) {
newControllers.add(controller);
}
if (isRestart) {
restartTrustDomains(alias, model, context);
}
}
Aggregations