@Test void testRegisterAuthentication() throws Exception { var environment = mock(Environment.class); var jersey = mock(JerseyEnvironment.class); when(environment.jersey()).thenReturn(jersey); AuthConfiguration configuration = FACTORY.build(new File(Resources.getResource( "fixtures/configuration/auth/basic-auth-with-keys.yaml").toURI())); assertTrue(configuration instanceof BasicAuthConfiguration); configuration.registerAuthentication(environment); ArgumentCaptor<Object> captor = ArgumentCaptor.forClass(Object.class); verify(jersey, atLeastOnce()).register(captor.capture()); List<Object> values = captor.getAllValues(); assertAll("Assert all objects were registered to Jersey", () -> assertEquals(1, values.stream().filter(v -> v instanceof AuthDynamicFeature).count()), () -> assertEquals(1, values.stream().filter(v -> v instanceof AuthValueFactoryProvider.Binder).count())); }
@Override public void registerAuthentication(Environment environment) { var authenticator = new BasicAuthenticator(keys); environment.jersey().register(new AuthDynamicFeature( new BasicCredentialAuthFilter.Builder<>() .setAuthenticator(authenticator) .setRealm("THUNDER - AUTHENTICATION") .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(Principal.class)); }
BasicAuthConfiguration implements AuthConfiguration { @Override public void registerAuthentication(Environment environment) { var authenticator = new BasicAuthenticator(keys); environment.jersey().register(new AuthDynamicFeature( new BasicCredentialAuthFilter.Builder<>() .setAuthenticator(authenticator) .setRealm("THUNDER - AUTHENTICATION") .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(Principal.class)); } }
BasicAuthConfiguration implements AuthConfiguration { @Override public void registerAuthentication(Environment environment) { var authenticator = new BasicAuthenticator(keys); environment.jersey().register(new AuthDynamicFeature( new BasicCredentialAuthFilter.Builder<>() .setAuthenticator(authenticator) .setRealm("THUNDER - AUTHENTICATION") .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(Principal.class)); }  }
BasicAuthConfiguration implements AuthConfiguration { @Override public void registerAuthentication(Environment environment) { var authenticator = new BasicAuthenticator(keys); environment.jersey().register(new AuthDynamicFeature( new BasicCredentialAuthFilter.Builder<>() .setAuthenticator(authenticator) .setRealm("THUNDER - AUTHENTICATION") .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(Principal.class)); }  List<Key> getKeys(); @Override void registerAuthentication(Environment environment); }
BasicAuthConfiguration implements AuthConfiguration { @Override public void registerAuthentication(Environment environment) { var authenticator = new BasicAuthenticator(keys); environment.jersey().register(new AuthDynamicFeature( new BasicCredentialAuthFilter.Builder<>() .setAuthenticator(authenticator) .setRealm("THUNDER - AUTHENTICATION") .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(Principal.class)); }  List<Key> getKeys(); @Override void registerAuthentication(Environment environment);  }