Search in sources :

Example 1 with SimbaAuthenticatedProvider

use of org.simbasecurity.dwclient.dropwizard.provider.SimbaAuthenticatedProvider in project simba-os by cegeka.

the class SimbaAuthRule method before.

protected void before(ResourceTest currentTest) throws AuthenticationException {
    SimbaAuthenticator authenticatorMock = mock(SimbaAuthenticator.class);
    SimbaCredentialsFactory simbaCredentialsFactoryMock = mock(SimbaCredentialsFactory.class);
    SimbaAuthenticatedProvider simbaAuthenticatedProvider = new SimbaAuthenticatedProvider(authenticatorMock, simbaCredentialsFactoryMock, domainProvider);
    SimbaCredentials simbaCredentials = new SimbaCredentialsBuilderForTests().build();
    when(simbaCredentialsFactoryMock.create(any(ContainerRequest.class))).thenReturn(simbaCredentials);
    when(authenticatorMock.authenticate(simbaCredentials)).thenReturn(Optional.fromNullable(new SimbaPrincipal("user", "ssoToken")));
    currentTest.addProvider(simbaAuthenticatedProvider);
}
Also used : SimbaPrincipal(org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal) SimbaAuthenticator(org.simbasecurity.dwclient.dropwizard.authenticator.SimbaAuthenticator) SimbaCredentials(org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials) SimbaCredentialsBuilderForTests(org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsBuilderForTests) SimbaAuthenticatedProvider(org.simbasecurity.dwclient.dropwizard.provider.SimbaAuthenticatedProvider) SimbaCredentialsFactory(org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory) ContainerRequest(com.sun.jersey.spi.container.ContainerRequest)

Aggregations

ContainerRequest (com.sun.jersey.spi.container.ContainerRequest)1 SimbaAuthenticator (org.simbasecurity.dwclient.dropwizard.authenticator.SimbaAuthenticator)1 SimbaCredentials (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials)1 SimbaCredentialsBuilderForTests (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsBuilderForTests)1 SimbaCredentialsFactory (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory)1 SimbaPrincipal (org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal)1 SimbaAuthenticatedProvider (org.simbasecurity.dwclient.dropwizard.provider.SimbaAuthenticatedProvider)1