use of org.springframework.ws.soap.security.support.KeyStoreFactoryBean in project open-smart-grid-platform by OSGP.
the class DefaultWebServiceTemplateFactory method getSSLConnectionSocketFactory.
private SSLConnectionSocketFactory getSSLConnectionSocketFactory(final String keystore) throws GeneralSecurityException, IOException {
// Open key store, assuming same identity
final KeyStoreFactoryBean keyStoreFactory = new KeyStoreFactoryBean();
keyStoreFactory.setType(this.keyStoreType);
keyStoreFactory.setLocation(new FileSystemResource(this.keyStoreLocation + "/" + keystore + ".pfx"));
keyStoreFactory.setPassword(this.keyStorePassword);
keyStoreFactory.afterPropertiesSet();
final KeyStore keyStore = keyStoreFactory.getObject();
if ((keyStore == null) || (keyStore.size() == 0)) {
throw new KeyStoreException("Key store is empty");
}
// Setup SSL context, load trust and key store and build the message
// sender
final SSLContext sslContext = SSLContexts.custom().loadKeyMaterial(keyStore, this.keyStorePassword.toCharArray()).loadTrustMaterial(this.trustStoreFactory.getObject(), new TrustSelfSignedStrategy()).build();
final HostnameVerifier hostnameVerifier = this.getHostnameVerifier();
return new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
}
use of org.springframework.ws.soap.security.support.KeyStoreFactoryBean in project open-smart-grid-platform by OSGP.
the class SoapClientConfig method keyStore.
@Bean
public KeyStoreFactoryBean keyStore() {
final KeyStoreFactoryBean keyStoreFactoryBean = new KeyStoreFactoryBean();
keyStoreFactoryBean.setLocation(this.keyStore);
keyStoreFactoryBean.setPassword(this.keyStorePassword);
return keyStoreFactoryBean;
}
use of org.springframework.ws.soap.security.support.KeyStoreFactoryBean in project open-smart-grid-platform by OSGP.
the class BaseWebServiceConfig method webServiceTrustStoreFactory.
@Bean
public KeyStoreFactoryBean webServiceTrustStoreFactory() {
final KeyStoreFactoryBean factory = new KeyStoreFactoryBean();
factory.setType(this.webserviceTruststoreType);
factory.setLocation(new FileSystemResource(this.webserviceTruststoreLocation));
factory.setPassword(this.webserviceTruststorePassword);
return factory;
}
use of org.springframework.ws.soap.security.support.KeyStoreFactoryBean in project open-smart-grid-platform by OSGP.
the class NotificationWebServiceTemplateFactory method createKeyStore.
private KeyStore createKeyStore(final String type, final String location, final String password) throws WebServiceSecurityException {
final KeyStoreFactoryBean keyStoreFactory = new KeyStoreFactoryBean();
keyStoreFactory.setType(type);
keyStoreFactory.setLocation(new FileSystemResource(location));
keyStoreFactory.setPassword(password);
try {
keyStoreFactory.afterPropertiesSet();
final KeyStore keyStore = keyStoreFactory.getObject();
if ((keyStore == null) || (keyStore.size() == 0)) {
throw new KeyStoreException("Key store is empty");
}
return keyStore;
} catch (final GeneralSecurityException | IOException e) {
LOGGER.error("Exception creating {} key store for file {}", type, location, e);
throw new WebServiceSecurityException("Unable to create KeyStore", e);
}
}
use of org.springframework.ws.soap.security.support.KeyStoreFactoryBean in project open-smart-grid-platform by OSGP.
the class NotificationClientConfigBase method webServiceTrustStoreFactory.
@Bean
public KeyStoreFactoryBean webServiceTrustStoreFactory() {
final KeyStoreFactoryBean factory = new KeyStoreFactoryBean();
factory.setType(this.webserviceTruststoreType);
factory.setLocation(new FileSystemResource(this.webserviceTruststoreLocation));
factory.setPassword(this.webserviceTruststorePassword);
return factory;
}
Aggregations