use of org.eclipse.hono.service.auth.delegating.AuthenticationServerClientConfigProperties 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