use of com.sun.net.httpserver.Authenticator in project jetty.project by eclipse.
the class JettyHttpContext method setAuthenticator.
@Override
public Authenticator setAuthenticator(Authenticator auth) {
Authenticator previous = _authenticator;
_authenticator = auth;
return previous;
}
use of com.sun.net.httpserver.Authenticator in project data-prepper by opensearch-project.
the class DataPrepperServerConfigurationTest method testGivenPrometheusMeterRegistryAndAuthenticatorThenServerIsCreated.
@Test
public void testGivenPrometheusMeterRegistryAndAuthenticatorThenServerIsCreated() {
final PrometheusMeterRegistry meterRegistry = mock(PrometheusMeterRegistry.class);
final Authenticator authenticator = mock(Authenticator.class);
when(httpServerProvider.get()).thenReturn(httpServer);
when(httpServer.createContext(any(String.class), any(HttpHandler.class))).thenReturn(context);
final HttpServer server = serverConfiguration.httpServer(httpServerProvider, listPipelinesHandler, shutdownHandler, meterRegistry, authenticator);
assertThat(server, is(httpServer));
verify(server).createContext(eq("/list"), eq(listPipelinesHandler));
verify(server).createContext(eq("/shutdown"), eq(shutdownHandler));
verify(server).createContext(eq("/metrics/prometheus"), any(PrometheusMetricsHandler.class));
verify(server).createContext(eq("/metrics/sys"), any(PrometheusMetricsHandler.class));
verify(context, times(4)).setAuthenticator(eq(authenticator));
}
use of com.sun.net.httpserver.Authenticator in project data-prepper by opensearch-project.
the class DataPrepperServerConfigurationTest method testGivenGetAuthenticatorReturnsValueThenReturnOptionalContainingValue.
@Test
public void testGivenGetAuthenticatorReturnsValueThenReturnOptionalContainingValue() {
final DataPrepperCoreAuthenticationProvider provider = mock(DataPrepperCoreAuthenticationProvider.class);
final Authenticator authenticatorMock = mock(Authenticator.class);
when(provider.getAuthenticator()).thenReturn(authenticatorMock);
final Authenticator authenticator = serverConfiguration.authenticator(provider);
assertThat(authenticator, is(authenticatorMock));
}
use of com.sun.net.httpserver.Authenticator in project data-prepper by opensearch-project.
the class HttpBasicDataPrepperCoreAuthenticationProviderTest method getAuthenticator_should_return_Authenticator_with_core_Realm.
@Test
void getAuthenticator_should_return_Authenticator_with_core_Realm() {
final Authenticator authenticator = createObjectUnderTest().getAuthenticator();
assertThat(authenticator, notNullValue());
assertThat(authenticator, instanceOf(BasicAuthenticator.class));
final BasicAuthenticator basicAuthenticator = (BasicAuthenticator) authenticator;
assertThat(basicAuthenticator.getRealm(), equalTo("core"));
}
use of com.sun.net.httpserver.Authenticator in project data-prepper by opensearch-project.
the class HttpBasicDataPrepperCoreAuthenticationProviderTest method getAuthenticator_should_return_Authenticator_which_returns_false_for_incorrect_password.
@Test
void getAuthenticator_should_return_Authenticator_which_returns_false_for_incorrect_password() {
final Authenticator authenticator = createObjectUnderTest().getAuthenticator();
assertThat(authenticator, notNullValue());
assertThat(authenticator, instanceOf(BasicAuthenticator.class));
final BasicAuthenticator basicAuthenticator = (BasicAuthenticator) authenticator;
assertThat(basicAuthenticator.checkCredentials(username, UUID.randomUUID().toString()), equalTo(false));
}
Aggregations