use of org.apereo.cas.support.saml.OpenSamlConfigBean in project cas by apereo.
the class SamlMetadataUIConfiguration method configureAdapter.
private static MetadataResolverAdapter configureAdapter(final AbstractMetadataResolverAdapter adapter, final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties, final OpenSamlConfigBean openSamlConfigBean) {
val resources = new HashMap<Resource, MetadataFilterChain>();
val chain = new MetadataFilterChain();
casProperties.getSamlMetadataUi().getResources().forEach(Unchecked.consumer(r -> configureResource(applicationContext, resources, chain, r, casProperties)));
adapter.setRequireValidMetadata(casProperties.getSamlMetadataUi().isRequireValidMetadata());
adapter.setMetadataResources(resources);
adapter.setConfigBean(openSamlConfigBean);
return adapter;
}
use of org.apereo.cas.support.saml.OpenSamlConfigBean in project cas by apereo.
the class SamlRegisteredServiceCachedMetadataEndpoint method getCachedMetadataObject.
/**
* Gets cached metadata object.
*
* @param serviceId the service id
* @param entityId the entity id
* @return the cached metadata object
*/
@ReadOperation
@Operation(summary = "Get SAML2 cached metadata", parameters = { @Parameter(name = "serviceId", required = true), @Parameter(name = "entityId") })
public Map<String, Object> getCachedMetadataObject(final String serviceId, @Nullable final String entityId) {
try {
val registeredService = findRegisteredService(serviceId);
val issuer = StringUtils.defaultIfBlank(entityId, registeredService.getServiceId());
val criteriaSet = new CriteriaSet();
criteriaSet.add(new EntityIdCriterion(issuer));
criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
val metadataResolver = cachingMetadataResolver.resolve(registeredService, criteriaSet);
val iteration = metadataResolver.resolve(criteriaSet).spliterator();
return StreamSupport.stream(iteration, false).map(entity -> Pair.of(entity.getEntityID(), SamlUtils.transformSamlObject(openSamlConfigBean, entity).toString())).collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
} catch (final Exception e) {
LoggingUtils.error(LOGGER, e);
return CollectionUtils.wrap("error", e.getMessage());
}
}
Aggregations