Search in sources :

Example 1 with HttpIdentityProviderConfiguration

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;
}
Also used : HttpIdentityProviderConfiguration(io.gravitee.am.identityprovider.http.configuration.HttpIdentityProviderConfiguration) HttpHeader(io.gravitee.common.http.HttpHeader) JsonObject(io.vertx.core.json.JsonObject) HttpResourceConfiguration(io.gravitee.am.identityprovider.http.configuration.HttpResourceConfiguration) HttpResponseErrorCondition(io.gravitee.am.identityprovider.http.configuration.HttpResponseErrorCondition) Bean(org.springframework.context.annotation.Bean)

Aggregations

HttpIdentityProviderConfiguration (io.gravitee.am.identityprovider.http.configuration.HttpIdentityProviderConfiguration)1 HttpResourceConfiguration (io.gravitee.am.identityprovider.http.configuration.HttpResourceConfiguration)1 HttpResponseErrorCondition (io.gravitee.am.identityprovider.http.configuration.HttpResponseErrorCondition)1 HttpHeader (io.gravitee.common.http.HttpHeader)1 JsonObject (io.vertx.core.json.JsonObject)1 Bean (org.springframework.context.annotation.Bean)1