use of org.springframework.security.saml.saml2.metadata.ServiceProviderMetadata in project service-authorization by reportportal.
the class HostBasedSamlServiceProviderProvisioningExtension method getHostedServiceProvider.
@Override
protected ServiceProviderService getHostedServiceProvider(LocalServiceProviderConfiguration spConfig) {
String basePath = spConfig.getBasePath();
List<SimpleKey> keys = new LinkedList<>();
SimpleKey activeKey = spConfig.getKeys().getActive();
keys.add(activeKey);
keys.add(activeKey.clone(activeKey.getName() + "-encryption", KeyType.ENCRYPTION));
keys.addAll(spConfig.getKeys().getStandBy());
SimpleKey signingKey = spConfig.isSignMetadata() ? spConfig.getKeys().getActive() : null;
String prefix = hasText(spConfig.getPrefix()) ? spConfig.getPrefix() : "saml/sp/";
String aliasPath = getAliasPath(spConfig);
ServiceProviderMetadata metadata = serviceProviderMetadata(basePath, signingKey, keys, prefix, aliasPath, spConfig.getDefaultSigningAlgorithm(), spConfig.getDefaultDigest());
if (!spConfig.getNameIds().isEmpty()) {
metadata.getServiceProvider().setNameIds(spConfig.getNameIds());
}
if (!spConfig.isSingleLogoutEnabled()) {
metadata.getServiceProvider().setSingleLogoutService(Collections.emptyList());
}
if (hasText(spConfig.getEntityId())) {
metadata.setEntityId(spConfig.getEntityId());
}
if (hasText(spConfig.getAlias())) {
metadata.setEntityAlias(spConfig.getAlias());
}
metadata.getServiceProvider().setWantAssertionsSigned(spConfig.isWantAssertionsSigned());
metadata.getServiceProvider().setAuthnRequestsSigned(spConfig.isSignRequests());
return new NonAliasHostedServiceProviderService(spConfig, metadata, getTransformer(), getValidator(), getCache(), authenticationRequestEnhancer);
}
use of org.springframework.security.saml.saml2.metadata.ServiceProviderMetadata in project service-authorization by reportportal.
the class NonAliasHostedServiceProviderService method authenticationRequest.
@Override
public AuthenticationRequest authenticationRequest(IdentityProviderMetadata idp) {
ExternalIdentityProviderConfiguration configuration = getIdentityProviderConfigurationForMetadata(idp);
final URI authnBinding = configuration.getAuthenticationRequestBinding();
Binding preferredBinding = authnBinding == null ? Binding.REDIRECT : Binding.fromUrn(authnBinding);
Endpoint endpoint = getPreferredEndpoint(idp.getIdentityProvider().getSingleSignOnService(), preferredBinding, 0);
ServiceProviderMetadata sp = getMetadata();
AuthenticationRequest request = new AuthenticationRequest().setId("ARQ" + UUID.randomUUID().toString().substring(1)).setIssueInstant(new DateTime(getClock().millis())).setForceAuth(Boolean.FALSE).setPassive(Boolean.FALSE).setBinding(endpoint.getBinding()).setAssertionConsumerService(getPreferredEndpoint(sp.getServiceProvider().getAssertionConsumerService(), null, -1)).setIssuer(new Issuer().setValue(sp.getEntityId())).setDestination(endpoint);
if (sp.getServiceProvider().isAuthnRequestsSigned()) {
request.setSigningKey(sp.getSigningKey(), sp.getAlgorithm(), sp.getDigest());
}
return authenticationRequestEnhancer.enhance(request);
}
Aggregations