use of io.gravitee.am.identityprovider.http.configuration.HttpIdentityProviderConfiguration in project gravitee-access-management by gravitee-io.
the class HttpAuthenticationProviderTestConfiguration method httpIdentityProviderConfiguration.
@Bean
public HttpIdentityProviderConfiguration httpIdentityProviderConfiguration() {
HttpIdentityProviderConfiguration configuration = new HttpIdentityProviderConfiguration();
HttpResourceConfiguration httpResourceConfiguration = new HttpResourceConfiguration();
httpResourceConfiguration.setBaseURL("http://localhost:19999/api/authentication");
httpResourceConfiguration.setHttpMethod(HttpMethod.POST);
HttpHeader httpHeader = new HttpHeader();
httpHeader.setName("Content-Type");
httpHeader.setValue("application/json");
httpResourceConfiguration.setHttpHeaders(Collections.singletonList(httpHeader));
JsonObject jsonObject = new JsonObject();
jsonObject.put("username", "{#principal}");
jsonObject.put("password", "{#credentials}");
httpResourceConfiguration.setHttpBody(jsonObject.encode());
HttpResponseErrorCondition errorCondition = new HttpResponseErrorCondition();
errorCondition.setValue("{#authenticationResponse.status == 401}");
errorCondition.setException("io.gravitee.am.common.exception.authentication.BadCredentialsException");
HttpResponseErrorCondition errorCondition2 = new HttpResponseErrorCondition();
errorCondition2.setValue("{#authenticationResponse.status == 404}");
errorCondition2.setException("io.gravitee.am.common.exception.authentication.UsernameNotFoundException");
httpResourceConfiguration.setHttpResponseErrorConditions(Arrays.asList(errorCondition, errorCondition2));
configuration.setAuthenticationResource(httpResourceConfiguration);
return configuration;
}
Aggregations