use of org.springframework.core.io.FileSystemResource in project cas by apereo.
the class SamlIdPConfiguration method casSamlIdPMetadataResolver.
@Bean
public MetadataResolver casSamlIdPMetadataResolver() {
try {
final SamlIdPProperties idp = casProperties.getAuthn().getSamlIdp();
final ResourceBackedMetadataResolver resolver = new ResourceBackedMetadataResolver(ResourceHelper.of(new FileSystemResource(idp.getMetadata().getMetadataFile())));
resolver.setParserPool(this.openSamlConfigBean.getParserPool());
resolver.setFailFastInitialization(idp.getMetadata().isFailFast());
resolver.setRequireValidMetadata(idp.getMetadata().isRequireValidMetadata());
resolver.setId(idp.getEntityId());
resolver.initialize();
return resolver;
} catch (final Exception e) {
throw new BeanCreationException(e.getMessage(), e);
}
}
use of org.springframework.core.io.FileSystemResource in project cas by apereo.
the class BaseSamlObjectSigner method getSigningCertificate.
/**
* Gets signing certificate.
*
* @return the signing certificate
* @throws Exception the exception
*/
protected X509Certificate getSigningCertificate() throws Exception {
final SamlIdPProperties samlIdp = casProperties.getAuthn().getSamlIdp();
LOGGER.debug("Locating signature signing certificate file from [{}]", samlIdp.getMetadata().getSigningCertFile());
return SamlUtils.readCertificate(new FileSystemResource(samlIdp.getMetadata().getSigningCertFile().getFile()));
}
use of org.springframework.core.io.FileSystemResource in project grails-core by grails.
the class AbstractGrailsPluginManager method informOfClassChange.
public void informOfClassChange(File file, @SuppressWarnings("rawtypes") Class cls) {
if (file.getName().equals(CONFIG_FILE)) {
ConfigSlurper configSlurper = getConfigSlurper(application);
ConfigObject c;
try {
c = configSlurper.parse(file.toURI().toURL());
application.getConfig().merge(c);
final Map flat = c.flatten();
application.getConfig().merge(flat);
application.configChanged();
informPluginsOfConfigChange();
} catch (Exception e) {
// ignore
LOG.debug("Error in changing Config", e);
}
} else {
if (cls != null) {
MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
registry.removeMetaClass(cls);
ExpandoMetaClass newMc = new ExpandoMetaClass(cls, true, true);
newMc.initialize();
registry.setMetaClass(cls, newMc);
Enhanced en = AnnotationUtils.findAnnotation(cls, Enhanced.class);
if (en != null) {
Class<?>[] mixinClasses = en.mixins();
if (mixinClasses != null) {
DefaultGroovyMethods.mixin(newMc, mixinClasses);
}
}
}
for (GrailsPlugin grailsPlugin : pluginList) {
if (grailsPlugin.hasInterestInChange(file.getAbsolutePath())) {
try {
if (cls == null) {
grailsPlugin.notifyOfEvent(GrailsPlugin.EVENT_ON_CHANGE, new FileSystemResource(file));
} else {
grailsPlugin.notifyOfEvent(GrailsPlugin.EVENT_ON_CHANGE, cls);
}
Environment.setCurrentReloadError(null);
} catch (Exception e) {
LOG.error("Plugin " + grailsPlugin + " could not reload changes to file [" + file + "]: " + e.getMessage(), e);
Environment.setCurrentReloadError(e);
}
}
}
}
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class JaxbResourceConfigurationTest method testFileSystemResourceDoesNotExist.
@Test(expected = org.opennms.core.config.api.ConfigurationResourceException.class)
public void testFileSystemResourceDoesNotExist() throws ConfigurationResourceException {
final File configFile = new File("target/test-classes/collectd-configuration.x");
final ConfigurationResource<CollectdConfiguration> collectd = new JaxbResourceConfiguration<CollectdConfiguration>(CollectdConfiguration.class, new FileSystemResource(configFile));
assertNotNull(collectd);
collectd.get();
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class JaxbResourceConfigurationTest method testSave.
@Test
public void testSave() throws ConfigurationResourceException, IOException {
final File configFile = getConfigFile();
final ConfigurationResource<CollectdConfiguration> collectd = new JaxbResourceConfiguration<CollectdConfiguration>(CollectdConfiguration.class, new FileSystemResource(configFile));
assertNotNull(collectd);
CollectdConfiguration config = collectd.get();
assertNotNull(config);
assertEquals(5, config.getPackages().size());
config.removePackage(config.getPackages().get(0));
assertEquals("vmware4", config.getPackages().get(0).getName());
assertEquals(4, config.getPackages().size());
collectd.save(config);
config = collectd.get();
assertNotNull(config);
assertEquals(4, config.getPackages().size());
assertEquals("vmware4", config.getPackages().get(0).getName());
}
Aggregations