Search in sources :

Example 1 with SimbaCredentialsFactory

use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory in project simba-os by cegeka.

the class SimbaManagerRule method before.

private void before() throws IOException, ConfigurationException, SimbaUnavailableException {
    SimbaManagerRestConfiguration simbaRestMgrConfig = getSimbaManagerRestConfiguration();
    simbaWebResource = getSimbaWebResource(simbaRestMgrConfig);
    String simbaWebURL = simbaRestMgrConfig.getSimbaWebURL();
    SimbaGateway simbaGateway = new SimbaGateway(simbaWebURL, new SimbaServiceFactory(), new SimbaCredentialsFactory(simbaWebURL));
    String appUser = simbaRestMgrConfig.getAppUser();
    String appPassword = simbaRestMgrConfig.getAppPassword();
    ssoToken = simbaGateway.login(appUser, appPassword);
    if (!ssoToken.isPresent()) {
        fail(String.format("Unsuccessful login for configured user/password: %s/%s", appUser, appPassword));
    }
}
Also used : SimbaManagerRestConfiguration(org.simbasecurity.dwclient.dropwizard.config.SimbaManagerRestConfiguration) SimbaServiceFactory(org.simbasecurity.dwclient.gateway.SimbaServiceFactory) SimbaCredentialsFactory(org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory) SimbaGateway(org.simbasecurity.dwclient.gateway.SimbaGateway)

Example 2 with SimbaCredentialsFactory

use of org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory 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

SimbaCredentialsFactory (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsFactory)2 ContainerRequest (com.sun.jersey.spi.container.ContainerRequest)1 SimbaAuthenticator (org.simbasecurity.dwclient.dropwizard.authenticator.SimbaAuthenticator)1 SimbaManagerRestConfiguration (org.simbasecurity.dwclient.dropwizard.config.SimbaManagerRestConfiguration)1 SimbaCredentials (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentials)1 SimbaCredentialsBuilderForTests (org.simbasecurity.dwclient.dropwizard.credentials.SimbaCredentialsBuilderForTests)1 SimbaPrincipal (org.simbasecurity.dwclient.dropwizard.credentials.SimbaPrincipal)1 SimbaAuthenticatedProvider (org.simbasecurity.dwclient.dropwizard.provider.SimbaAuthenticatedProvider)1 SimbaGateway (org.simbasecurity.dwclient.gateway.SimbaGateway)1 SimbaServiceFactory (org.simbasecurity.dwclient.gateway.SimbaServiceFactory)1