use of org.springframework.security.saml.saml2.metadata.IdentityProviderMetadata 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());
}
Aggregations