use of org.opensaml.saml.metadata.resolver.impl.FileBackedHTTPMetadataResolver in project cas by apereo.
the class ChainingMetadataResolverCacheLoader method resolveUrlBasedMetadataResource.
private void resolveUrlBasedMetadataResource(final SamlRegisteredService service, final List<MetadataResolver> metadataResolvers, final AbstractResource metadataResource) throws Exception {
final SamlIdPProperties.Metadata md = casProperties.getAuthn().getSamlIdp().getMetadata();
final File backupDirectory = new File(md.getLocation().getFile(), "metadata-backups");
final File backupFile = new File(backupDirectory, metadataResource.getFilename());
LOGGER.debug("Metadata backup directory is designated to be [{}]", backupDirectory.getCanonicalPath());
FileUtils.forceMkdir(backupDirectory);
LOGGER.debug("Metadata backup file will be at [{}]", backupFile.getCanonicalPath());
FileUtils.forceMkdirParent(backupFile);
final HttpClientMultithreadedDownloader downloader = new HttpClientMultithreadedDownloader(metadataResource, backupFile);
final FileBackedHTTPMetadataResolver metadataProvider = new FileBackedHTTPMetadataResolver(this.httpClient.getWrappedHttpClient(), metadataResource.getURL().toExternalForm(), backupFile.getCanonicalPath());
buildSingleMetadataResolver(metadataProvider, service);
metadataResolvers.add(metadataProvider);
}
use of org.opensaml.saml.metadata.resolver.impl.FileBackedHTTPMetadataResolver in project cas by apereo.
the class UrlResourceMetadataResolver method resolve.
@Override
public Collection<MetadataResolver> resolve(final SamlRegisteredService service) {
try {
final String metadataLocation = service.getMetadataLocation();
LOGGER.info("Loading SAML metadata from [{}]", metadataLocation);
final AbstractResource metadataResource = ResourceUtils.getResourceFrom(metadataLocation);
final File backupFile = getMetadataBackupFile(metadataResource, service);
final String canonicalPath = backupFile.getCanonicalPath();
LOGGER.debug("Metadata backup file will be at [{}]", canonicalPath);
FileUtils.forceMkdirParent(backupFile);
cleanUpExpiredBackupMetadataFilesFor(metadataResource, service);
final FileBackedHTTPMetadataResolver metadataProvider = new FileBackedHTTPMetadataResolver(this.httpClient.getWrappedHttpClient(), metadataResource.getURL().toExternalForm(), canonicalPath);
configureAndInitializeSingleMetadataResolver(metadataProvider, service);
return CollectionUtils.wrap(metadataProvider);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return new ArrayList<>(0);
}
Aggregations