use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.
the class ChainContextImplTest method redirectToPasswordChanged.
@Test
public void redirectToPasswordChanged() {
when(configurationServiceMock.getValue(PASSWORD_CHANGED_URL)).thenReturn(SIMBA_PASSWORD_CHANGED_URL);
chainContextImpl.redirectToPasswordChanged();
ActionDescriptor actionDescriptor = chainContextImpl.getActionDescriptor();
Set<ActionType> actionTypes = actionDescriptor.getActionTypes();
assertEquals(2, actionTypes.size());
assertTrue(actionTypes.contains(ADD_PARAMETER_TO_TARGET));
assertTrue(actionTypes.contains(REDIRECT));
assertEquals(SIMBA_WEB_URL + SIMBA_PASSWORD_CHANGED_URL, actionDescriptor.getRedirectURL());
}
use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.
the class LoginController method handleRequest.
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
RequestData requestData = RequestUtil.createRequestData(request, resolveSimbaWebURL(request));
AuthenticationFilterService.Iface authenticationFilterService = GlobalContext.locate(AuthenticationFilterService.Iface.class, "authenticationFilterService");
ActionDescriptor actionDescriptor = authenticationFilterService.processRequest(requestData, "credentialChain");
if (actionDescriptor.getSsoToken() != null) {
makeSimbaSSOCookieForCORS(response, actionDescriptor);
}
RequestActionFactory actionFactory = new RequestActionFactory(request, response);
actionFactory.execute(actionDescriptor);
return null;
}
use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.
the class SimbaGateway method processRequestInSimba.
private ActionDescriptor processRequestInSimba(RequestData requestData, String chain) throws SimbaUnavailableException {
try {
logger.debug("processRequest in simba with requestdata: {}", requestData);
ActionDescriptor actionDescriptor = createAuthenticationService().processRequest(requestData, chain);
return actionDescriptor;
} catch (TException | RuntimeException e) {
logger.error("Simba is down?", e);
throw new SimbaUnavailableException(e);
} finally {
if (tHttpClient != null) {
tHttpClient.close();
}
}
}
use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.
the class SimbaGateway method authenticate.
/**
* On successful authentication returns a present SimbaPrincipal
* On failed authentication returns either an absent SimbaPrincipal, or throws a SimbaUnavailableException
*
* @param credentials
* @return an absent SimbaPrincipal when the ActionDescriptor does not contain DO_FILTER_AND_SET_PRINCIPAL (means authentication failed)
* a present SimbaPrincipal when the ActionDescriptor does contain DO_FILTER_AND_SET_PRINCIPAL (means authentication was successful)
* @throws SimbaUnavailableException
*/
public Optional<SimbaPrincipal> authenticate(SimbaCredentials credentials) throws SimbaUnavailableException {
SimbaPrincipal principal = null;
ActionDescriptor actionDescriptor = processRequestInSimba(credentials.asRequestData(), SESSION_AUTHENTICATE_CHAIN);
if (isValidActionDescriptor(actionDescriptor) && actionDescriptor.getActionTypes().contains(ActionType.DO_FILTER_AND_SET_PRINCIPAL)) {
String token = actionDescriptor.getSsoToken() != null ? actionDescriptor.getSsoToken().getToken() : null;
principal = new SimbaPrincipal(actionDescriptor.getPrincipal(), token);
}
return Optional.fromNullable(principal);
}
use of org.simbasecurity.api.service.thrift.ActionDescriptor in project simba-os by cegeka.
the class SimbaGatewayTest method login_WithUsernameAndPassword.
@Test
public void login_WithUsernameAndPassword() throws Exception {
String username = "appUser";
String password = "appPassword";
Client authenticationServicemock = setupSimbaServiceToReturnASimbaAuthenticationService();
SimbaCredentials simbaCredentials = mock(SimbaCredentials.class);
RequestData requestData = mock(RequestData.class);
SSOToken ssoToken = new SSOToken("token");
ActionDescriptor actionDescriptor = new ActionDescriptorBuilderForTests().withActionTypes(ActionType.MAKE_COOKIE).withSsoToken(ssoToken).build();
when(simbaCredentialsFactoryMock.createForLogin(username, password)).thenReturn(simbaCredentials);
when(simbaCredentials.asRequestData()).thenReturn(requestData);
when(authenticationServicemock.processRequest(requestData, LOGIN_AUTHENTICATE_CHAIN)).thenReturn(actionDescriptor);
Optional<String> actual = simbaGateway.login(username, password);
assertThat(actual.get()).isEqualTo(ssoToken.getToken());
}
Aggregations