Search in sources :

Example 1 with ServiceConfigProperties

use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.

the class ApplicationConfig method authTokenFactory.

/**
 * Exposes a factory for JWTs asserting a client's identity as a Spring bean.
 *
 * @return The bean.
 */
@Bean
@Qualifier("signing")
public AuthTokenHelper authTokenFactory() {
    ServiceConfigProperties amqpProps = amqpProperties();
    AuthenticationServerConfigProperties serviceProps = serviceProperties();
    if (!serviceProps.getSigning().isAppropriateForCreating() && amqpProps.getKeyPath() != null) {
        // fall back to TLS configuration
        serviceProps.getSigning().setKeyPath(amqpProps.getKeyPath());
    }
    return AuthTokenHelperImpl.forSigning(vertx(), serviceProps.getSigning());
}
Also used : ServiceConfigProperties(org.eclipse.hono.config.ServiceConfigProperties) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean) ObjectFactoryCreatingFactoryBean(org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean)

Example 2 with ServiceConfigProperties

use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.

the class AbstractServiceBaseTest method checkSecurePortExplicitlySet.

/**
 * Verifies that a Hono server will bind to the configured secure port only
 * when using a default configuration with only the key store and the port property being set.
 */
@Test
public void checkSecurePortExplicitlySet() {
    // GIVEN a configuration with a key store and a secure port being set
    ServiceConfigProperties configProperties = new ServiceConfigProperties();
    configProperties.setKeyStorePath("/etc/hono/certs/honoKeyStore.p12");
    configProperties.setPort(8989);
    // WHEN using this configuration to determine the server's port configuration
    // secure port config: explicit port set -> port used
    AbstractServiceBase<ServiceConfigProperties> server = createServer(configProperties);
    Future<Void> portConfigurationTracker = server.checkPortConfiguration();
    // THEN the configured port is used and no insecure port will be opened
    assertTrue(portConfigurationTracker.succeeded());
    assertTrue(server.isSecurePortEnabled());
    assertThat(server.getPort(), is(8989));
    assertFalse(server.isInsecurePortEnabled());
}
Also used : ServiceConfigProperties(org.eclipse.hono.config.ServiceConfigProperties) Test(org.junit.Test)

Example 3 with ServiceConfigProperties

use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.

the class AbstractServiceBaseTest method checkInsecureOnlyPortExplicitlySet.

/**
 * Verifies that a Hono server will bind to a configured insecure port only
 * when using a default configuration with the insecure port property being set.
 */
@Test
public void checkInsecureOnlyPortExplicitlySet() {
    // GIVEN a default configuration with insecure port being set to a specific port.
    ServiceConfigProperties configProperties = new ServiceConfigProperties();
    configProperties.setInsecurePortEnabled(true);
    configProperties.setInsecurePort(8888);
    // WHEN using this configuration to determine the server's port configuration
    AbstractServiceBase<ServiceConfigProperties> server = createServer(configProperties);
    Future<Void> portConfigurationTracker = server.checkPortConfiguration();
    // THEN the server will bind to the configured insecure port only
    assertTrue(portConfigurationTracker.succeeded());
    assertFalse(server.isSecurePortEnabled());
    assertTrue(server.isInsecurePortEnabled());
    assertThat(server.getInsecurePort(), is(8888));
}
Also used : ServiceConfigProperties(org.eclipse.hono.config.ServiceConfigProperties) Test(org.junit.Test)

Example 4 with ServiceConfigProperties

use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.

the class AbstractServiceBaseTest method checkSecurePortAutoSelect.

/**
 * Verifies that a Hono server will bind to the default port only
 * when using a default configuration with only the key store property being set.
 */
@Test
public void checkSecurePortAutoSelect() {
    // GIVEN a configuration with a key store set
    ServiceConfigProperties configProperties = new ServiceConfigProperties();
    configProperties.setKeyStorePath("/etc/hono/certs/honoKeyStore.p12");
    // WHEN using this configuration to determine the server's port configuration
    // secure port config: no port set -> secure IANA port selected
    AbstractServiceBase<ServiceConfigProperties> server = createServer(configProperties);
    Future<Void> portConfigurationTracker = server.checkPortConfiguration();
    // THEN the default secure port is selected and no insecure port will be opened
    assertTrue(portConfigurationTracker.succeeded());
    assertTrue(server.isSecurePortEnabled());
    assertThat(server.getPort(), is(PORT_NR));
    assertFalse(server.isInsecurePortEnabled());
}
Also used : ServiceConfigProperties(org.eclipse.hono.config.ServiceConfigProperties) Test(org.junit.Test)

Example 5 with ServiceConfigProperties

use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.

the class AbstractServiceBaseTest method checkBothPortsOpen.

/**
 * Verifies that a Hono server will bind to both the default insecure and secure ports
 * when using a default configuration with the insecure port being enabled and the
 * key store property being set.
 */
@Test
public void checkBothPortsOpen() {
    // GIVEN a default configuration with insecure port being enabled and a key store being set.
    ServiceConfigProperties configProperties = new ServiceConfigProperties();
    configProperties.setInsecurePortEnabled(true);
    configProperties.setKeyStorePath("/etc/hono/certs/honoKeyStore.p12");
    // WHEN using this configuration to determine the server's port configuration
    AbstractServiceBase<ServiceConfigProperties> server = createServer(configProperties);
    Future<Void> portConfigurationTracker = server.checkPortConfiguration();
    // THEN the server will bind to both the default insecure and secure ports
    assertTrue(portConfigurationTracker.succeeded());
    assertTrue(server.isSecurePortEnabled());
    assertThat(server.getPort(), is(PORT_NR));
    assertTrue(server.isInsecurePortEnabled());
    assertThat(server.getInsecurePort(), is(INSECURE_PORT_NR));
}
Also used : ServiceConfigProperties(org.eclipse.hono.config.ServiceConfigProperties) Test(org.junit.Test)

Aggregations

ServiceConfigProperties (org.eclipse.hono.config.ServiceConfigProperties)19 Test (org.junit.Test)15 ProtonConnection (io.vertx.proton.ProtonConnection)6 AuthorizationService (org.eclipse.hono.service.auth.AuthorizationService)4 ResourceIdentifier (org.eclipse.hono.util.ResourceIdentifier)4 ProtonDelivery (io.vertx.proton.ProtonDelivery)3 DeliveryState (org.apache.qpid.proton.amqp.transport.DeliveryState)3 Message (org.apache.qpid.proton.message.Message)3 EventBusMessage (org.eclipse.hono.util.EventBusMessage)3 Qualifier (org.springframework.beans.factory.annotation.Qualifier)3 ObjectFactoryCreatingFactoryBean (org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean)3 Bean (org.springframework.context.annotation.Bean)3 Future (io.vertx.core.Future)2 Handler (io.vertx.core.Handler)2 Vertx (io.vertx.core.Vertx)2 Async (io.vertx.ext.unit.Async)2 TestContext (io.vertx.ext.unit.TestContext)2 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)2 ProtonReceiver (io.vertx.proton.ProtonReceiver)2 Rejected (org.apache.qpid.proton.amqp.messaging.Rejected)2