Search in sources :

Example 51 with ConfigurationException

use of org.osgi.service.cm.ConfigurationException in project felix by apache.

the class RoleRepositoryFileStoreTest method testUpdateConfigurationWithKeyWriteDisabledInvalidValueFail.

/**
 * Tests that calling updated with the key "background.write.disabled" set to a numeric value fails.
 */
public void testUpdateConfigurationWithKeyWriteDisabledInvalidValueFail() throws Exception {
    Properties properties = new Properties();
    properties.put(RoleRepositoryFileStore.KEY_WRITE_DISABLED, Integer.valueOf(1));
    try {
        m_store.updated(properties);
        fail("ConfigurationException expected!");
    } catch (ConfigurationException e) {
    // Ok; expected
    }
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) Properties(java.util.Properties)

Example 52 with ConfigurationException

use of org.osgi.service.cm.ConfigurationException in project cxf by apache.

the class HTTPJettyTransportActivator method updated.

public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
    if (pid == null) {
        return;
    }
    int port = Integer.parseInt((String) properties.get("port"));
    String host = (String) properties.get("host");
    try {
        TLSServerParameters tls = createTlsServerParameters(properties);
        if (tls != null) {
            factory.setTLSServerParametersForPort(host, port, tls);
        } else {
            factory.createJettyHTTPServerEngine(host, port, "http");
        }
        JettyHTTPServerEngine e = factory.retrieveJettyHTTPServerEngine(port);
        configure(e, properties);
    } catch (GeneralSecurityException e) {
        throw new ConfigurationException(null, null, e);
    } catch (IOException e) {
        throw new ConfigurationException(null, null, e);
    }
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) GeneralSecurityException(java.security.GeneralSecurityException) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) IOException(java.io.IOException) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters)

Example 53 with ConfigurationException

use of org.osgi.service.cm.ConfigurationException in project cxf by apache.

the class HTTPUndertowTransportActivator method updated.

public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
    if (pid == null) {
        return;
    }
    int port = Integer.parseInt((String) properties.get("port"));
    String host = (String) properties.get("host");
    try {
        TLSServerParameters tls = createTlsServerParameters(properties);
        if (tls != null) {
            factory.setTLSServerParametersForPort(host, port, tls);
        } else {
            factory.createUndertowHTTPServerEngine(host, port, "http");
        }
        UndertowHTTPServerEngine e = factory.retrieveUndertowHTTPServerEngine(port);
        configure(e, properties);
    } catch (GeneralSecurityException e) {
        throw new ConfigurationException(null, null, e);
    } catch (IOException e) {
        throw new ConfigurationException(null, null, e);
    }
}
Also used : UndertowHTTPServerEngine(org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngine) ConfigurationException(org.osgi.service.cm.ConfigurationException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) TLSServerParameters(org.apache.cxf.configuration.jsse.TLSServerParameters)

Example 54 with ConfigurationException

use of org.osgi.service.cm.ConfigurationException in project smarthome by eclipse.

the class AcceptAllCertificatesSSLContext method getContext.

@Override
public SSLContext getContext() throws ConfigurationException {
    try {
        SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
        sslContext.init(null, new TrustManager[] { trustManager }, null);
        return sslContext;
    } catch (KeyManagementException | NoSuchAlgorithmException e) {
        logger.warn("SSL configuration failed", e);
        throw new ConfigurationException("ssl", e.getMessage());
    }
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) SSLContext(javax.net.ssl.SSLContext) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyManagementException(java.security.KeyManagementException)

Example 55 with ConfigurationException

use of org.osgi.service.cm.ConfigurationException in project adeptj-modules by AdeptJ.

the class DefaultJaxRSAuthenticationRealm method updated.

/**
 * {@inheritDoc}
 */
@Override
public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
    String username = Objects.requireNonNull((String) properties.get(KEY_USERNAME), USERNAME_NULL_MSG);
    String password = Objects.requireNonNull((String) properties.get(KEY_PWD), PWD_NULL_MSG);
    LOGGER.info("Creating JaxRSAuthenticationInfo for User: [{}]", username);
    if (this.pidVsUserMappings.containsKey(pid)) {
        // This is an update
        this.pidVsUserMappings.put(pid, username);
        this.authInfoMap.put(username, new JaxRSAuthenticationInfo(username, password.toCharArray()));
    } else if (!this.pidVsUserMappings.containsKey(pid) && this.pidVsUserMappings.containsValue(username)) {
        LOGGER.warn("User: [{}] already present, ignoring this config!!");
        throw new ConfigurationException(KEY_USERNAME, "User already present!!");
    } else if (!this.pidVsUserMappings.containsKey(pid) && !this.pidVsUserMappings.containsValue(username)) {
        this.pidVsUserMappings.put(pid, username);
        this.authInfoMap.put(username, new JaxRSAuthenticationInfo(username, password.toCharArray()));
    }
}
Also used : ConfigurationException(org.osgi.service.cm.ConfigurationException) JaxRSAuthenticationInfo(com.adeptj.modules.jaxrs.core.auth.JaxRSAuthenticationInfo)

Aggregations

ConfigurationException (org.osgi.service.cm.ConfigurationException)190 Activate (org.apache.felix.scr.annotations.Activate)31 ServiceReference (org.osgi.framework.ServiceReference)30 Matcher (java.util.regex.Matcher)28 Hashtable (java.util.Hashtable)26 Properties (java.util.Properties)22 IOException (java.io.IOException)21 Test (org.junit.Test)21 ManagedService (org.osgi.service.cm.ManagedService)20 FooService (org.apache.felix.ipojo.runtime.core.services.FooService)19 HashMap (java.util.HashMap)17 File (java.io.File)11 URISyntaxException (java.net.URISyntaxException)11 Collection (java.util.Collection)11 HashSet (java.util.HashSet)11 ServiceTracker (org.osgi.util.tracker.ServiceTracker)10 URI (java.net.URI)9 Dictionary (java.util.Dictionary)9 Map (java.util.Map)9 NotFoundException (org.opencastproject.util.NotFoundException)9