use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.
the class ApplicationConfig method registrationAssertionFactory.
/**
* Exposes a factory for JWTs asserting a device's registration status as a Spring bean.
*
* @return The bean.
*/
@Bean
@Qualifier("signing")
public RegistrationAssertionHelper registrationAssertionFactory() {
ServiceConfigProperties amqpProps = amqpProperties();
FileBasedRegistrationConfigProperties serviceProps = serviceProperties();
if (!serviceProps.getSigning().isAppropriateForCreating() && amqpProps.getKeyPath() != null) {
// fall back to TLS configuration
serviceProps.getSigning().setKeyPath(amqpProps.getKeyPath());
}
return RegistrationAssertionHelperImpl.forSigning(vertx(), serviceProps.getSigning());
}
use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.
the class AbstractServiceBaseTest method checkNoPortsSet.
/**
* Verifies that a Hono server will not be able to start
* when using a default configuration with not key store being set.
*/
@Test
public void checkNoPortsSet() {
// GIVEN a default configuration with no key store being set
ServiceConfigProperties configProperties = new ServiceConfigProperties();
// WHEN using this configuration to determine the server's port configuration
AbstractServiceBase<ServiceConfigProperties> server = createServer(configProperties);
Future<Void> portConfigurationTracker = server.checkPortConfiguration();
// THEN the port configuration fails
assertTrue(portConfigurationTracker.failed());
}
use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.
the class AbstractServiceBaseTest method checkBothPortsSetToSame.
/**
* Verifies that a Hono server will only bind to the secure port
* when using a default configuration with both secure and insecure ports being enabled and
* set to the same port number.
*/
@Test
public void checkBothPortsSetToSame() {
// GIVEN a default configuration with both the insecure port and the secure port
// being set to the same value.
ServiceConfigProperties configProperties = new ServiceConfigProperties();
configProperties.setInsecurePortEnabled(true);
configProperties.setKeyStorePath("/etc/hono/certs/honoKeyStore.p12");
configProperties.setInsecurePort(8888);
configProperties.setPort(8888);
// WHEN using this configuration to determine the server's port configuration
AbstractServiceBase<ServiceConfigProperties> server = createServer(configProperties);
Future<Void> portConfigurationTracker = server.checkPortConfiguration();
// THEN port configuration fails
assertTrue(portConfigurationTracker.failed());
}
use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.
the class AmqpServiceBaseTest method createServer.
private AmqpServiceBase<ServiceConfigProperties> createServer(final AmqpEndpoint amqpEndpoint, final Handler<ProtonConnection> onClientDisconnect) {
final AmqpServiceBase<ServiceConfigProperties> server = new AmqpServiceBase<ServiceConfigProperties>() {
@Override
protected String getServiceName() {
return "AmqpServiceBase";
}
@Override
public void setConfig(final ServiceConfigProperties configuration) {
setSpecificConfig(configuration);
}
@Override
protected void publishConnectionClosedEvent(final ProtonConnection con) {
if (onClientDisconnect != null) {
onClientDisconnect.handle(con);
}
}
};
server.setConfig(new ServiceConfigProperties());
if (amqpEndpoint != null) {
server.addEndpoint(amqpEndpoint);
}
server.init(vertx, mock(Context.class));
return server;
}
use of org.eclipse.hono.config.ServiceConfigProperties in project hono by eclipse.
the class AmqpServiceBaseTest method testHandleReceiverOpenForwardsToEndpoint.
/**
* Verifies that the service notifies a registered endpoint about a client
* that has established a link.
*/
@Test
public void testHandleReceiverOpenForwardsToEndpoint() {
// GIVEN a server with an endpoint
final ResourceIdentifier targetAddress = ResourceIdentifier.from(ENDPOINT, Constants.DEFAULT_TENANT, null);
final AmqpEndpoint endpoint = mock(AmqpEndpoint.class);
when(endpoint.getName()).thenReturn(ENDPOINT);
final AuthorizationService authService = mock(AuthorizationService.class);
when(authService.isAuthorized(Constants.PRINCIPAL_ANONYMOUS, targetAddress, Activity.WRITE)).thenReturn(Future.succeededFuture(Boolean.TRUE));
final AmqpServiceBase<ServiceConfigProperties> server = createServer(endpoint);
server.setAuthorizationService(authService);
// WHEN a client connects to the server using this endpoint
final Target target = getTarget(targetAddress);
final ProtonReceiver receiver = mock(ProtonReceiver.class);
when(receiver.getRemoteTarget()).thenReturn(target);
when(receiver.attachments()).thenReturn(mock(Record.class));
server.handleReceiverOpen(newConnection(Constants.PRINCIPAL_ANONYMOUS), receiver);
// THEN the server delegates link establishment to the endpoint
verify(endpoint).onLinkAttach(any(ProtonConnection.class), eq(receiver), eq(targetAddress));
}
Aggregations