use of org.simbasecurity.dwclient.exception.SimbaUnavailableException in project simba-os by cegeka.
the class SimbaGateway method createAuthenticationService.
/**
* @return always creates a new client
* @throws SimbaUnavailableException
*/
AuthenticationFilterService.Client createAuthenticationService() throws SimbaUnavailableException {
try {
tHttpClient = getTHttpClient();
authenticationFilterService = simbaServiceFactory.createJSONAuthenticationFilterService(tHttpClient);
} catch (TTransportException | RuntimeException e) {
if (tHttpClient != null) {
tHttpClient.close();
}
logger.error("Simba is down?", e);
throw new SimbaUnavailableException(e);
}
return authenticationFilterService;
}
use of org.simbasecurity.dwclient.exception.SimbaUnavailableException 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.dwclient.exception.SimbaUnavailableException in project simba-os by cegeka.
the class SimbaUnavailableExceptionToJSONMapperTest method toResponse_ReturnsJSONValidationError.
@Test
public void toResponse_ReturnsJSONValidationError() throws Exception {
SimbaUnavailableExceptionToJSONMapper mapperUnderTest = new SimbaUnavailableExceptionToJSONMapper();
SimbaUnavailableException simbaUnavailableException = new SimbaUnavailableException();
DWSimbaErrorR expectedEntity = new DWSimbaErrorR(HttpStatus.INTERNAL_SERVER_ERROR.getDescription(), SimbaUnavailableExceptionToJSONMapper.SIMBA_ERROR_MESSAGE, null);
MediaType expectedMediaType = MediaType.APPLICATION_JSON_TYPE;
int expectedStatus = 500;
Response actual = mapperUnderTest.toResponse(simbaUnavailableException);
assertThat(actual.getStatus()).isEqualTo(expectedStatus);
assertThat((MediaType) actual.getMetadata().get("Content-Type").get(0)).isEqualTo(expectedMediaType);
assertThat(actual.getEntity()).isEqualsToByComparingFields(expectedEntity);
}
use of org.simbasecurity.dwclient.exception.SimbaUnavailableException in project simba-os by cegeka.
the class SimbaAuthenticatorTest method authenticate_WhenConnectionToSimbaFails_ThrowAuthenticationException.
@Test
public void authenticate_WhenConnectionToSimbaFails_ThrowAuthenticationException() throws Exception {
SimbaCredentials credentials = mock(SimbaCredentials.class);
when(simbaGatewayMock.authenticate(credentials)).thenThrow(new SimbaUnavailableException());
expectedException.expect(AuthenticationException.class);
authenticator.authenticate(credentials);
}
Aggregations