use of org.opensaml.saml.metadata.criteria.entity.impl.EvaluableEntityRoleEntityDescriptorCriterion in project cas by apereo.
the class SamlIdPUtils method determineNameIdNameQualifier.
/**
* Determine name id name qualifier string.
*
* @param samlRegisteredService the saml registered service
* @param samlIdPMetadataResolver the saml id p metadata resolver
* @return the string
*/
public static String determineNameIdNameQualifier(final SamlRegisteredService samlRegisteredService, final MetadataResolver samlIdPMetadataResolver) {
if (StringUtils.isNotBlank(samlRegisteredService.getNameIdQualifier())) {
return samlRegisteredService.getNameIdQualifier();
}
val nameQualifier = FunctionUtils.doIf(StringUtils.isNotBlank(samlRegisteredService.getIssuerEntityId()), samlRegisteredService::getIssuerEntityId, Unchecked.supplier(() -> {
val criteriaSet = new CriteriaSet(new EvaluableEntityRoleEntityDescriptorCriterion(IDPSSODescriptor.DEFAULT_ELEMENT_NAME), new SamlIdPSamlRegisteredServiceCriterion(samlRegisteredService));
LOGGER.trace("Resolving entity id from SAML2 IdP metadata to determine issuer for [{}]", samlRegisteredService.getName());
val entityDescriptor = Objects.requireNonNull(samlIdPMetadataResolver.resolveSingle(criteriaSet));
return entityDescriptor.getEntityID();
})).get();
LOGGER.debug("Using name qualifier [{}] for the Name ID", nameQualifier);
return nameQualifier;
}
Aggregations