Search in sources :

Example 6 with Request

use of org.keycloak.adapters.spi.HttpFacade.Request in project keycloak by keycloak.

the class ClaimInformationPointProviderTest method createHttpFacade.

private HttpFacade createHttpFacade(Map<String, List<String>> headers, InputStream requestBody) {
    return new OIDCHttpFacade() {

        private Request request;

        @Override
        public KeycloakSecurityContext getSecurityContext() {
            AccessToken token = new AccessToken();
            token.subject("sub");
            token.setPreferredUsername("username");
            token.getOtherClaims().put("custom_claim", Arrays.asList("param-other-claims-value1", "param-other-claims-value2"));
            IDToken idToken = new IDToken();
            idToken.subject("sub");
            idToken.setPreferredUsername("username");
            idToken.getOtherClaims().put("custom_claim", Arrays.asList("param-other-claims-value1", "param-other-claims-value2"));
            return new KeycloakSecurityContext("tokenString", token, "idTokenString", idToken);
        }

        @Override
        public Request getRequest() {
            if (request == null) {
                request = createHttpRequest(headers, requestBody);
            }
            return request;
        }

        @Override
        public Response getResponse() {
            return createHttpResponse();
        }

        @Override
        public X509Certificate[] getCertificateChain() {
            return new X509Certificate[0];
        }
    };
}
Also used : KeycloakSecurityContext(org.keycloak.KeycloakSecurityContext) OIDCHttpFacade(org.keycloak.adapters.OIDCHttpFacade) AccessToken(org.keycloak.representations.AccessToken) Request(org.keycloak.adapters.spi.HttpFacade.Request) IDToken(org.keycloak.representations.IDToken) X509Certificate(javax.security.cert.X509Certificate)

Aggregations

Request (org.keycloak.adapters.spi.HttpFacade.Request)6 List (java.util.List)3 BufferedInputStream (java.io.BufferedInputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 KeycloakSecurityContext (org.keycloak.KeycloakSecurityContext)2 Cookie (org.keycloak.adapters.spi.HttpFacade.Cookie)2 AccessToken (org.keycloak.representations.AccessToken)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 X509Certificate (javax.security.cert.X509Certificate)1 KeycloakConfigResolver (org.keycloak.adapters.KeycloakConfigResolver)1 KeycloakDeployment (org.keycloak.adapters.KeycloakDeployment)1 OIDCHttpFacade (org.keycloak.adapters.OIDCHttpFacade)1 AuthenticationError (org.keycloak.adapters.spi.AuthenticationError)1 LogoutError (org.keycloak.adapters.spi.LogoutError)1