use of org.eclipse.hono.service.auth.HonoSaslAuthenticatorFactory in project hono by eclipse.
the class StandaloneEventApiTest method prepareHonoServer.
/**
* Sets up Hono Messaging service.
*
* @param ctx The test context.
*/
@BeforeClass
public static void prepareHonoServer(final TestContext ctx) {
vertx = Vertx.vertx();
downstreamAdapter = new MessageDiscardingDownstreamAdapter(vertx);
final HonoMessagingConfigProperties configProperties = new HonoMessagingConfigProperties();
configProperties.setInsecurePort(0);
final EventEndpoint eventEndpoint = new EventEndpoint(vertx);
eventEndpoint.setMetrics(mock(MessagingMetrics.class));
eventEndpoint.setEventAdapter(downstreamAdapter);
eventEndpoint.setRegistrationAssertionValidator(assertionHelper);
eventEndpoint.setConfiguration(configProperties);
server = new HonoMessaging();
server.setSaslAuthenticatorFactory(new HonoSaslAuthenticatorFactory(TestSupport.createAuthenticationService(createUser())));
server.setConfig(configProperties);
server.addEndpoint(eventEndpoint);
Future<String> serverTracker = Future.future();
vertx.deployVerticle(server, serverTracker.completer());
serverTracker.compose(s -> {
final ClientConfigProperties clientProps = new ClientConfigProperties();
clientProps.setName("test");
clientProps.setHost(server.getInsecurePortBindAddress());
clientProps.setPort(server.getInsecurePort());
clientProps.setUsername(USER);
clientProps.setPassword(PWD);
client = new HonoClientImpl(vertx, clientProps);
return client.connect(new ProtonClientOptions());
}).setHandler(ctx.asyncAssertSuccess());
}
use of org.eclipse.hono.service.auth.HonoSaslAuthenticatorFactory in project hono by eclipse.
the class StandaloneTelemetryApiTest method prepareHonoServer.
/**
* Sets up the fixture common to all test cases.
*
* @param ctx The vert.x test context.
*/
@BeforeClass
public static void prepareHonoServer(final TestContext ctx) {
vertx = Vertx.vertx();
downstreamAdapter = new MessageDiscardingDownstreamAdapter(vertx);
final HonoMessagingConfigProperties configProperties = new HonoMessagingConfigProperties();
configProperties.setInsecurePort(0);
final TelemetryEndpoint telemetryEndpoint = new TelemetryEndpoint(vertx);
telemetryEndpoint.setMetrics(mock(MessagingMetrics.class));
telemetryEndpoint.setTelemetryAdapter(downstreamAdapter);
telemetryEndpoint.setRegistrationAssertionValidator(assertionHelper);
telemetryEndpoint.setConfiguration(configProperties);
server = new HonoMessaging();
server.setSaslAuthenticatorFactory(new HonoSaslAuthenticatorFactory(TestSupport.createAuthenticationService(createUser())));
server.setConfig(configProperties);
server.addEndpoint(telemetryEndpoint);
final Future<String> serverTracker = Future.future();
vertx.deployVerticle(server, serverTracker.completer());
serverTracker.compose(s -> {
final ClientConfigProperties clientProps = new ClientConfigProperties();
clientProps.setName("test");
clientProps.setHost(server.getInsecurePortBindAddress());
clientProps.setPort(server.getInsecurePort());
clientProps.setUsername(USER);
clientProps.setPassword(PWD);
client = new HonoClientImpl(vertx, clientProps);
return client.connect(new ProtonClientOptions());
}).setHandler(ctx.asyncAssertSuccess());
}
use of org.eclipse.hono.service.auth.HonoSaslAuthenticatorFactory in project hono by eclipse.
the class StandaloneAuthServerTest method prepareServer.
/**
* Sets up the server.
*
* @param ctx The vertx test context.
*/
@BeforeClass
public static void prepareServer(final TestContext ctx) {
AuthTokenHelper tokenHelper = AuthTokenHelperImpl.forSharedSecret(SIGNING_SECRET, 5);
ServiceConfigProperties props = new ServiceConfigProperties();
props.setInsecurePortEnabled(true);
props.setInsecurePort(0);
server = new SimpleAuthenticationServer();
server.setConfig(props);
server.setSaslAuthenticatorFactory(new HonoSaslAuthenticatorFactory(vertx, tokenHelper));
server.addEndpoint(new AuthenticationEndpoint(vertx));
AuthenticationServerConfigProperties serviceProps = new AuthenticationServerConfigProperties();
serviceProps.getSigning().setTokenExpiration(5);
serviceProps.getSigning().setSharedSecret(SIGNING_SECRET);
serviceProps.setPermissionsPath(new ClassPathResource("authentication-service-test-permissions.json"));
FileBasedAuthenticationService authServiceImpl = new FileBasedAuthenticationService();
authServiceImpl.setConfig(serviceProps);
authServiceImpl.setTokenFactory(tokenHelper);
Async startup = ctx.async();
Future<String> serverTracker = Future.future();
serverTracker.setHandler(ctx.asyncAssertSuccess(s -> startup.complete()));
Future<String> serviceTracker = Future.future();
vertx.deployVerticle(authServiceImpl, serviceTracker.completer());
serviceTracker.compose(s -> {
vertx.deployVerticle(server, ctx.asyncAssertSuccess(d -> serverTracker.complete(d)));
}, serverTracker);
startup.await(2000);
AuthenticationServerClientConfigProperties clientProps = new AuthenticationServerClientConfigProperties();
clientProps.setHost("127.0.0.1");
clientProps.setName("test-client");
clientProps.setPort(server.getInsecurePort());
clientProps.getValidation().setSharedSecret(SIGNING_SECRET);
ConnectionFactory clientFactory = new ConnectionFactoryImpl(vertx, clientProps);
client = new AuthenticationServerClient(vertx, clientFactory);
}
Aggregations