use of io.gravitee.am.service.exception.TechnicalManagementException in project gravitee-access-management by gravitee-io.
the class BotDetectionHandler method handle.
@Override
public void handle(RoutingContext routingContext) {
Client client = routingContext.get(CLIENT_CONTEXT_KEY);
AccountSettings accountSettings = AccountSettings.getInstance(domain, client);
if (accountSettings == null || !accountSettings.isUseBotDetection()) {
routingContext.next();
return;
}
if (StringUtils.isEmpty(accountSettings.getBotDetectionPlugin())) {
LOGGER.error("Bot Detection enable without plugin identifier for domain '{}' and application '{}'", domain.getId(), client.getId());
routingContext.fail(INTERNAL_SERVER_ERROR_500, new TechnicalManagementException(DEFAULT_ERROR_MSG));
return;
}
final MultiMap headers = routingContext.request().headers();
final MultiMap params = routingContext.request().params();
BotDetectionContext context = new BotDetectionContext(accountSettings.getBotDetectionPlugin(), headers, params);
botDetectionManager.validate(context).subscribe((isValid) -> {
if (isValid) {
LOGGER.debug("No bot detected for domain '{}' and client '{}'", domain.getId(), client.getId());
routingContext.next();
} else {
LOGGER.warn("Bot detected for domain '{}' and client '{}'", domain.getId(), client.getId());
routingContext.fail(BAD_REQUEST_400, new BotDetectedException(DEFAULT_ERROR_MSG));
}
}, (error) -> {
LOGGER.error("BotDetection failed for domain '{}' and client '{}'", domain.getId(), client.getId(), error);
routingContext.fail(INTERNAL_SERVER_ERROR_500, new TechnicalManagementException(DEFAULT_ERROR_MSG));
});
}
use of io.gravitee.am.service.exception.TechnicalManagementException in project gravitee-access-management by gravitee-io.
the class RolesResourceTest method shouldGetRoles_technicalManagementException.
@Test
public void shouldGetRoles_technicalManagementException() {
final String domainId = "domain-1";
doReturn(Single.error(new TechnicalManagementException("error occurs"))).when(roleService).findByDomain(domainId);
final Response response = target("domains").path(domainId).path("roles").request().get();
assertEquals(HttpStatusCode.INTERNAL_SERVER_ERROR_500, response.getStatus());
}
use of io.gravitee.am.service.exception.TechnicalManagementException in project gravitee-access-management by gravitee-io.
the class TagsResourceTest method shouldGetTags_technicalManagementException.
@Test
public void shouldGetTags_technicalManagementException() {
doReturn(Flowable.error(new TechnicalManagementException("error occurs"))).when(tagService).findAll(anyString());
final Response response = target("organizations").path("DEFAULT").path("tags").request().get();
assertEquals(HttpStatusCode.INTERNAL_SERVER_ERROR_500, response.getStatus());
}
use of io.gravitee.am.service.exception.TechnicalManagementException in project gravitee-access-management by gravitee-io.
the class UserConsentsResourceTest method shouldGetUserConsents_technicalManagementException.
@Test
public void shouldGetUserConsents_technicalManagementException() {
final String domainId = "domain-1";
doReturn(Maybe.error(new TechnicalManagementException("error occurs"))).when(domainService).findById(domainId);
final Response response = target("domains").path(domainId).path("users").path("user1").path("consents").request().get();
assertEquals(HttpStatusCode.INTERNAL_SERVER_ERROR_500, response.getStatus());
}
use of io.gravitee.am.service.exception.TechnicalManagementException in project gravitee-access-management by gravitee-io.
the class UserCredentialsResourceTest method shouldGetUserFactors_technicalManagementException.
@Test
public void shouldGetUserFactors_technicalManagementException() {
final String domainId = "domain-1";
doReturn(Maybe.error(new TechnicalManagementException("error occurs"))).when(domainService).findById(domainId);
final Response response = target("domains").path(domainId).path("users").path("user1").path("credentials").request().get();
assertEquals(HttpStatusCode.INTERNAL_SERVER_ERROR_500, response.getStatus());
}
Aggregations