use of org.eclipse.kura.ssl.SslManagerServiceOptions in project kura by eclipse.
the class GwtSslServiceImpl method updateSslConfiguration.
@Override
public void updateSslConfiguration(GwtXSRFToken xsrfToken, GwtSslConfig sslConfig) throws GwtKuraException {
checkXSRFToken(xsrfToken);
try {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PROP_PROTOCOL, sslConfig.getProtocol());
properties.put(PROP_HN_VERIFY, sslConfig.isHostnameVerification());
properties.put(PROP_TRUST_STORE, sslConfig.getKeyStore());
if (PLACEHOLDER.equals(sslConfig.getKeystorePassword())) {
CryptoService cryptoService = ServiceLocator.getInstance().getService(CryptoService.class);
SslManagerServiceOptions options = getSslConfiguration();
properties.put(PROP_TRUST_PASSWORD, new Password(cryptoService.decryptAes(options.getSslKeystorePassword().toCharArray())));
} else {
properties.put(PROP_TRUST_PASSWORD, new Password(sslConfig.getKeystorePassword()));
}
properties.put(PROP_CIPHERS, sslConfig.getCiphers());
ConfigurationService configService = ServiceLocator.getInstance().getService(ConfigurationService.class);
configService.updateConfiguration(SSL_PID, properties);
} catch (KuraException e) {
throw new GwtKuraException(e.getMessage());
}
}
use of org.eclipse.kura.ssl.SslManagerServiceOptions in project kura by eclipse.
the class GwtSslServiceImpl method getSslConfiguration.
private SslManagerServiceOptions getSslConfiguration() throws KuraException {
SslManagerServiceOptions options;
try {
SslManagerService sslService = ServiceLocator.getInstance().getService(SslManagerService.class);
options = sslService.getConfigurationOptions();
return options;
} catch (GeneralSecurityException e) {
throw new KuraException(KuraErrorCode.SECURITY_EXCEPTION);
} catch (IOException e) {
throw new KuraException(KuraErrorCode.SECURITY_EXCEPTION);
} catch (GwtKuraException e) {
throw new KuraException(KuraErrorCode.SECURITY_EXCEPTION);
}
}
use of org.eclipse.kura.ssl.SslManagerServiceOptions in project kura by eclipse.
the class SslManagerServiceImpl method activate.
// ----------------------------------------------------------------
//
// Activation APIs
//
// ----------------------------------------------------------------
protected void activate(ComponentContext componentContext, Map<String, Object> properties) {
s_logger.info("activate...");
//
// save the bundle context and the properties
this.m_ctx = componentContext;
this.m_properties = properties;
this.m_options = new SslManagerServiceOptions(properties);
this.m_sslSocketFactories = new ConcurrentHashMap<ConnectionSslOptions, SSLSocketFactory>();
ServiceTracker<SslServiceListener, SslServiceListener> listenersTracker = new ServiceTracker<SslServiceListener, SslServiceListener>(componentContext.getBundleContext(), SslServiceListener.class, null);
// Deferred open of tracker to prevent
// java.lang.Exception: Recursive invocation of
// ServiceFactory.getService
// on ProSyst
this.m_sslServiceListeners = new SslServiceListeners(listenersTracker);
// Then self-update our configuration to reflect the password change.
if (!changeDefaultKeystorePassword()) {
// 2. If the password saved in the snapshot and the password hold by
// the CryptoService do not match change the keystore password
// to the password in the snapshot.
changeKeyStorePassword();
}
}
use of org.eclipse.kura.ssl.SslManagerServiceOptions in project kura by eclipse.
the class SslManagerServiceImpl method updated.
public void updated(Map<String, Object> properties) {
s_logger.info("updated...");
this.m_properties = properties;
this.m_options = new SslManagerServiceOptions(properties);
changeKeyStorePassword();
// Notify listeners that service has been updated
this.m_sslServiceListeners.onConfigurationUpdated();
}
use of org.eclipse.kura.ssl.SslManagerServiceOptions in project kura by eclipse.
the class GwtSslServiceImpl method getSslConfiguration.
@Override
public GwtSslConfig getSslConfiguration(GwtXSRFToken xsrfToken) throws GwtKuraException {
checkXSRFToken(xsrfToken);
try {
SslManagerServiceOptions options = getSslConfiguration();
GwtSslConfig gwtSslConfig = new GwtSslConfig();
gwtSslConfig.setProtocol(options.getSslProtocol());
gwtSslConfig.setKeyStore(options.getSslKeyStore());
gwtSslConfig.setCiphers(options.getSslCiphers());
gwtSslConfig.setKeystorePassword(PLACEHOLDER);
gwtSslConfig.setHostnameVerification(options.isSslHostnameVerification());
return gwtSslConfig;
} catch (KuraException e) {
throw new GwtKuraException(GwtKuraErrorCode.ILLEGAL_ACCESS);
}
}
Aggregations