use of org.springframework.core.io.FileSystemResource in project cas by apereo.
the class FileSystemResourceMetadataResolver method supports.
@Override
public boolean supports(final SamlRegisteredService service) {
try {
final String metadataLocation = service.getMetadataLocation();
final AbstractResource metadataResource = ResourceUtils.getResourceFrom(metadataLocation);
return metadataResource instanceof FileSystemResource;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
use of org.springframework.core.io.FileSystemResource in project cas by apereo.
the class GoogleAccountsServiceResponseBuilder method createGoogleAppsPrivateKey.
/**
* Create the private key.
*
* @throws Exception if key creation ran into an error
*/
protected void createGoogleAppsPrivateKey() throws Exception {
if (!isValidConfiguration()) {
LOGGER.debug("Google Apps private key bean will not be created, because it's not configured");
return;
}
final PrivateKeyFactoryBean bean = new PrivateKeyFactoryBean();
if (this.privateKeyLocation.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) {
bean.setLocation(new ClassPathResource(StringUtils.removeStart(this.privateKeyLocation, ResourceUtils.CLASSPATH_URL_PREFIX)));
} else if (this.privateKeyLocation.startsWith(ResourceUtils.FILE_URL_PREFIX)) {
bean.setLocation(new FileSystemResource(StringUtils.removeStart(this.privateKeyLocation, ResourceUtils.FILE_URL_PREFIX)));
} else {
bean.setLocation(new FileSystemResource(this.privateKeyLocation));
}
bean.setAlgorithm(this.keyAlgorithm);
LOGGER.debug("Loading Google Apps private key from [{}] with key algorithm [{}]", bean.getLocation(), bean.getAlgorithm());
bean.afterPropertiesSet();
LOGGER.debug("Creating Google Apps private key instance via [{}]", this.privateKeyLocation);
this.privateKey = bean.getObject();
}
use of org.springframework.core.io.FileSystemResource in project cas by apereo.
the class FileTrustStoreSslSocketFactoryTests method verifyTrustStoreNotFound.
@Test
public void verifyTrustStoreNotFound() {
this.thrown.expect(FileNotFoundException.class);
sslFactory(new FileSystemResource("test.jks"), "changeit");
}
use of org.springframework.core.io.FileSystemResource in project cas by apereo.
the class DefaultCasConfigurationPropertiesSourceLocator method loadSettingsByApplicationProfiles.
private PropertySource<?> loadSettingsByApplicationProfiles(final Environment environment, final File config) {
final Properties props = new Properties();
final List<String> profiles = getApplicationProfiles(environment);
final String regex = buildPatternForConfigurationFileDiscovery(config, profiles);
final Collection<File> configFiles = scanForConfigurationFilesByPattern(config, regex);
LOGGER.info("Configuration files found at [{}] are [{}]", config, configFiles);
configFiles.forEach(Unchecked.consumer(f -> {
LOGGER.debug("Loading configuration file [{}]", f);
if (f.getName().toLowerCase().endsWith("yml")) {
final Map<String, Object> pp = loadYamlProperties(new FileSystemResource(f));
LOGGER.debug("Found settings [{}] in YAML file [{}]", pp.keySet(), f);
props.putAll(decryptProperties(pp));
} else {
final Properties pp = new Properties();
pp.load(Files.newBufferedReader(f.toPath(), StandardCharsets.UTF_8));
LOGGER.debug("Found settings [{}] in file [{}]", pp.keySet(), f);
props.putAll(decryptProperties(pp));
}
}));
return new PropertiesPropertySource("applicationProfilesProperties", props);
}
use of org.springframework.core.io.FileSystemResource in project opennms by OpenNMS.
the class PropertiesGraphDaoIT method testLoadSnmpGraphProperties.
@Test
public void testLoadSnmpGraphProperties() throws Exception {
PropertiesGraphDao dao = createPropertiesGraphDao(s_emptyMap, s_emptyMap);
dao.loadProperties("foo", new FileSystemResource(ConfigurationTestUtils.getFileForConfigFile("snmp-graph.properties")));
for (PrefabGraph graph : dao.getAllPrefabGraphs()) {
if (!graph.getCommand().trim().equals(graph.getCommand())) {
fail("Prefab graph contains extra whitespace: " + graph.getCommand());
}
}
}
Aggregations