Search in sources :

Example 1 with ServiceProviderMetadata

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);
}
Also used : ServiceProviderMetadata(org.springframework.security.saml.saml2.metadata.ServiceProviderMetadata) LinkedList(java.util.LinkedList) SimpleKey(org.springframework.security.saml.key.SimpleKey)

Example 2 with ServiceProviderMetadata

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);
}
Also used : Binding(org.springframework.security.saml.saml2.metadata.Binding) ServiceProviderMetadata(org.springframework.security.saml.saml2.metadata.ServiceProviderMetadata) Endpoint(org.springframework.security.saml.saml2.metadata.Endpoint) Issuer(org.springframework.security.saml.saml2.authentication.Issuer) AuthenticationRequest(org.springframework.security.saml.saml2.authentication.AuthenticationRequest) URI(java.net.URI) DateTime(org.joda.time.DateTime) ExternalIdentityProviderConfiguration(org.springframework.security.saml.provider.service.config.ExternalIdentityProviderConfiguration)

Aggregations

ServiceProviderMetadata (org.springframework.security.saml.saml2.metadata.ServiceProviderMetadata)2 URI (java.net.URI)1 LinkedList (java.util.LinkedList)1 DateTime (org.joda.time.DateTime)1 SimpleKey (org.springframework.security.saml.key.SimpleKey)1 ExternalIdentityProviderConfiguration (org.springframework.security.saml.provider.service.config.ExternalIdentityProviderConfiguration)1 AuthenticationRequest (org.springframework.security.saml.saml2.authentication.AuthenticationRequest)1 Issuer (org.springframework.security.saml.saml2.authentication.Issuer)1 Binding (org.springframework.security.saml.saml2.metadata.Binding)1 Endpoint (org.springframework.security.saml.saml2.metadata.Endpoint)1