Search in sources :

Example 1 with SslManagerServiceOptions

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());
    }
}
Also used : SslManagerServiceOptions(org.eclipse.kura.ssl.SslManagerServiceOptions) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) HashMap(java.util.HashMap) CryptoService(org.eclipse.kura.crypto.CryptoService) KuraException(org.eclipse.kura.KuraException) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) ConfigurationService(org.eclipse.kura.configuration.ConfigurationService) Password(org.eclipse.kura.configuration.Password)

Example 2 with SslManagerServiceOptions

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);
    }
}
Also used : SslManagerServiceOptions(org.eclipse.kura.ssl.SslManagerServiceOptions) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) SslManagerService(org.eclipse.kura.ssl.SslManagerService) KuraException(org.eclipse.kura.KuraException) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException)

Example 3 with SslManagerServiceOptions

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();
    }
}
Also used : SslManagerServiceOptions(org.eclipse.kura.ssl.SslManagerServiceOptions) SslServiceListener(org.eclipse.kura.ssl.SslServiceListener) ServiceTracker(org.osgi.util.tracker.ServiceTracker) SSLSocketFactory(javax.net.ssl.SSLSocketFactory)

Example 4 with SslManagerServiceOptions

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();
}
Also used : SslManagerServiceOptions(org.eclipse.kura.ssl.SslManagerServiceOptions)

Example 5 with SslManagerServiceOptions

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);
    }
}
Also used : SslManagerServiceOptions(org.eclipse.kura.ssl.SslManagerServiceOptions) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) KuraException(org.eclipse.kura.KuraException) GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) GwtSslConfig(org.eclipse.kura.web.shared.model.GwtSslConfig)

Aggregations

SslManagerServiceOptions (org.eclipse.kura.ssl.SslManagerServiceOptions)5 KuraException (org.eclipse.kura.KuraException)3 GwtKuraException (org.eclipse.kura.web.shared.GwtKuraException)3 IOException (java.io.IOException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 HashMap (java.util.HashMap)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 ConfigurationService (org.eclipse.kura.configuration.ConfigurationService)1 Password (org.eclipse.kura.configuration.Password)1 CryptoService (org.eclipse.kura.crypto.CryptoService)1 SslManagerService (org.eclipse.kura.ssl.SslManagerService)1 SslServiceListener (org.eclipse.kura.ssl.SslServiceListener)1 GwtSslConfig (org.eclipse.kura.web.shared.model.GwtSslConfig)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1