use of org.apereo.cas.util.ResourceUtils in project cas by apereo.
the class CasThemesConfiguration method themesStaticResourcesWebMvcConfigurer.
@Bean
@ConditionalOnMissingBean(name = "themesStaticResourcesWebMvcConfigurer")
public WebMvcConfigurer themesStaticResourcesWebMvcConfigurer(final CasConfigurationProperties casProperties, final WebProperties webProperties, final ThymeleafProperties thymeleafProperties) {
return new WebMvcConfigurer() {
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
val templatePrefixes = casProperties.getView().getTemplatePrefixes();
if (!templatePrefixes.isEmpty()) {
val registration = registry.addResourceHandler("/**");
val resources = templatePrefixes.stream().map(prefix -> StringUtils.appendIfMissing(prefix, "/")).map(Unchecked.function(ResourceUtils::getRawResourceFrom)).toArray(Resource[]::new);
LOGGER.debug("Adding resource handler for resources [{}]", (Object[]) resources);
registration.addResourceLocations(templatePrefixes.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
registration.addResourceLocations(webProperties.getResources().getStaticLocations());
FunctionUtils.doIfNotNull(webProperties.getResources().getCache().getPeriod(), period -> registration.setCachePeriod((int) period.getSeconds()));
registration.setCacheControl(webProperties.getResources().getCache().getCachecontrol().toHttpCacheControl());
registration.setUseLastModified(true);
val cache = thymeleafProperties != null && thymeleafProperties.isCache();
val chainRegistration = registration.resourceChain(cache);
val resolver = new PathResourceResolver();
resolver.setAllowedLocations(resources);
chainRegistration.addResolver(resolver);
}
}
};
}
use of org.apereo.cas.util.ResourceUtils in project cas by apereo.
the class WsFederationCertificateProvider method getProvider.
/**
* Gets providers.
*
* @param config the config
* @param openSamlConfigBean the open saml config bean
* @return the providers
*/
static WsFederationCertificateProvider getProvider(final WsFederationConfiguration config, final OpenSamlConfigBean openSamlConfigBean) {
val chain = new ChainingWsFederationCertificateProvider();
StringUtils.commaDelimitedListToSet(config.getSigningCertificates()).stream().map(Unchecked.function(ResourceUtils::getRawResourceFrom)).forEach(resource -> {
if (StringUtils.hasText(resource.getFilename()) && resource.getFilename().endsWith(".xml")) {
chain.addProvider(new WsFederationMetadataCertificateProvider(resource, config, openSamlConfigBean));
} else {
chain.addProvider(new WsFederationStaticCertificateProvider(resource));
}
});
return chain;
}
Aggregations