use of org.apereo.cas.support.saml.services.idp.metadata.cache.resolver.FileSystemResourceMetadataResolver in project cas by apereo.
the class SamlIdPMetadataConfiguration method samlRegisteredServiceMetadataResolvers.
@ConditionalOnMissingBean(name = "samlRegisteredServiceMetadataResolvers")
@Bean
public SamlRegisteredServiceMetadataResolutionPlan samlRegisteredServiceMetadataResolvers() {
final DefaultSamlRegisteredServiceMetadataResolutionPlan plan = new DefaultSamlRegisteredServiceMetadataResolutionPlan();
final SamlIdPProperties samlIdp = casProperties.getAuthn().getSamlIdp();
plan.registerMetadataResolver(new DynamicMetadataResolver(samlIdp, openSamlConfigBean, httpClient));
plan.registerMetadataResolver(new FileSystemResourceMetadataResolver(samlIdp, openSamlConfigBean));
plan.registerMetadataResolver(new UrlResourceMetadataResolver(samlIdp, openSamlConfigBean, httpClient));
plan.registerMetadataResolver(new ClasspathResourceMetadataResolver(samlIdp, openSamlConfigBean));
plan.registerMetadataResolver(new GroovyResourceMetadataResolver(samlIdp, openSamlConfigBean));
final Map<String, SamlRegisteredServiceMetadataResolutionPlanConfigurator> configurers = this.applicationContext.getBeansOfType(SamlRegisteredServiceMetadataResolutionPlanConfigurator.class, false, true);
configurers.values().forEach(c -> {
final String name = StringUtils.removePattern(c.getClass().getSimpleName(), "\\$.+");
LOGGER.debug("Configuring saml metadata resolution plan [{}]", name);
c.configureMetadataResolutionPlan(plan);
});
return plan;
}
use of org.apereo.cas.support.saml.services.idp.metadata.cache.resolver.FileSystemResourceMetadataResolver in project cas by apereo.
the class SamlRegisteredServiceMetadataResolverCacheLoaderTests method verifyFileByExpression.
@Test
public void verifyFileByExpression() throws Exception {
val mdFile = File.createTempFile("spsamlmetadata", ".xml");
val content = IOUtils.toString(new ClassPathResource("sample-sp.xml").getInputStream(), StandardCharsets.UTF_8);
FileUtils.writeStringToFile(mdFile, content, StandardCharsets.UTF_8);
System.setProperty("SP_REF", mdFile.getCanonicalPath());
val props = new SamlIdPProperties();
props.getMetadata().getFileSystem().setLocation(new FileSystemResource(FileUtils.getTempDirectory()).getFile().getCanonicalPath());
val plan = new DefaultSamlRegisteredServiceMetadataResolutionPlan();
plan.registerMetadataResolver(new FileSystemResourceMetadataResolver(props, openSamlConfigBean));
val loader = new SamlRegisteredServiceMetadataResolverCacheLoader(openSamlConfigBean, httpClient, plan);
val service = new SamlRegisteredService();
service.setName("Example");
service.setId(1000);
service.setServiceId("https://example.org/saml");
service.setMetadataLocation("${#systemProperties['SP_REF']}");
val key = new SamlRegisteredServiceCacheKey(service, new CriteriaSet());
assertNotNull(loader.load(key));
}
Aggregations