Search in sources :

Example 1 with ExternalIdentityProviderConfiguration

use of org.springframework.security.saml.provider.service.config.ExternalIdentityProviderConfiguration in project service-authorization by reportportal.

the class SamlIntegrationStrategy method populateProviderDetails.

private void populateProviderDetails(Integration samlIntegration) {
    Map<String, Object> params = samlIntegration.getParams().getParams();
    ExternalIdentityProviderConfiguration externalConfiguration = new ExternalIdentityProviderConfiguration().setMetadata(SamlParameter.IDP_METADATA_URL.getRequiredParameter(samlIntegration));
    IdentityProviderMetadata remoteProvider = serviceProviderProvisioning.getHostedProvider().getRemoteProvider(externalConfiguration);
    params.put(IDP_URL.getParameterName(), remoteProvider.getEntityId());
    params.put(IDP_ALIAS.getParameterName(), remoteProvider.getEntityAlias());
    NameId nameId = ofNullable(remoteProvider.getDefaultNameId()).orElseGet(() -> {
        Optional<NameId> first = remoteProvider.getProviders().stream().filter(IdentityProvider.class::isInstance).map(IdentityProvider.class::cast).flatMap(v -> v.getNameIds().stream()).filter(Objects::nonNull).findFirst();
        return first.orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, "Provider does not contain information about identification mapping"));
    });
    params.put(IDP_NAME_ID.getParameterName(), nameId.toString());
}
Also used : NameId(org.springframework.security.saml.saml2.metadata.NameId) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IdentityProvider(org.springframework.security.saml.saml2.metadata.IdentityProvider) ExternalIdentityProviderConfiguration(org.springframework.security.saml.provider.service.config.ExternalIdentityProviderConfiguration) IdentityProviderMetadata(org.springframework.security.saml.saml2.metadata.IdentityProviderMetadata)

Aggregations

ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 ExternalIdentityProviderConfiguration (org.springframework.security.saml.provider.service.config.ExternalIdentityProviderConfiguration)1 IdentityProvider (org.springframework.security.saml.saml2.metadata.IdentityProvider)1 IdentityProviderMetadata (org.springframework.security.saml.saml2.metadata.IdentityProviderMetadata)1 NameId (org.springframework.security.saml.saml2.metadata.NameId)1