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());
}
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());
}
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));
}
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());
}
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));
}
Aggregations