From d3e559453b7dcf6f0d9f32c5a9a7f8c49403bb3a Mon Sep 17 00:00:00 2001 From: Pedro Igor Date: Wed, 16 Aug 2017 16:26:50 -0300 Subject: [PATCH] [KEYCLOAK-5015] - Updating Elytron Adapters --- .../adapters/elytron/ElytronHttpFacade.java | 16 +++++++++++++++- .../adapters/elytron/KeycloakSecurityRealm.java | 5 +++-- .../saml/elytron/KeycloakSecurityRealm.java | 5 +++-- .../shared-cli/adapter-elytron-install.cli | 4 ++-- .../cli/adapter-elytron-install-offline.cli | 4 ++-- .../shared-cli/adapter-elytron-install-saml.cli | 4 ++-- pom.xml | 4 ++-- testsuite/integration-arquillian/pom.xml | 2 +- 8 files changed, 30 insertions(+), 14 deletions(-) diff --git a/adapters/oidc/wildfly-elytron/src/main/java/org/keycloak/adapters/elytron/ElytronHttpFacade.java b/adapters/oidc/wildfly-elytron/src/main/java/org/keycloak/adapters/elytron/ElytronHttpFacade.java index 4472af75f9..4941275f1e 100644 --- a/adapters/oidc/wildfly-elytron/src/main/java/org/keycloak/adapters/elytron/ElytronHttpFacade.java +++ b/adapters/oidc/wildfly-elytron/src/main/java/org/keycloak/adapters/elytron/ElytronHttpFacade.java @@ -50,7 +50,9 @@ import java.net.InetSocketAddress; import java.net.URI; import java.net.URLDecoder; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.function.Consumer; /** @@ -66,6 +68,7 @@ class ElytronHttpFacade implements OIDCHttpFacade { private ElytronAccount account; private SecurityIdentity securityIdentity; private boolean restored; + private final Map headers = new HashMap<>(); public ElytronHttpFacade(HttpServerRequest request, AdapterDeploymentContext deploymentContext, CallbackHandler handler) { this.request = request; @@ -261,6 +264,7 @@ class ElytronHttpFacade implements OIDCHttpFacade { @Override public Response getResponse() { return new Response() { + @Override public void setStatus(final int status) { responseConsumer = responseConsumer.andThen(response -> response.setStatusCode(status)); @@ -268,7 +272,17 @@ class ElytronHttpFacade implements OIDCHttpFacade { @Override public void addHeader(final String name, final String value) { - responseConsumer = responseConsumer.andThen(response -> response.addResponseHeader(name, value)); + headers.put(name, value); + responseConsumer = responseConsumer.andThen(new Consumer() { + @Override + public void accept(HttpServerResponse response) { + String latestValue = headers.get(name); + + if (latestValue.equals(value)) { + response.addResponseHeader(name, latestValue); + } + } + }); } @Override diff --git a/adapters/oidc/wildfly-elytron/src/main/java/org/keycloak/adapters/elytron/KeycloakSecurityRealm.java b/adapters/oidc/wildfly-elytron/src/main/java/org/keycloak/adapters/elytron/KeycloakSecurityRealm.java index 6042ec82d1..eef2b26942 100644 --- a/adapters/oidc/wildfly-elytron/src/main/java/org/keycloak/adapters/elytron/KeycloakSecurityRealm.java +++ b/adapters/oidc/wildfly-elytron/src/main/java/org/keycloak/adapters/elytron/KeycloakSecurityRealm.java @@ -17,6 +17,7 @@ package org.keycloak.adapters.elytron; import java.security.Principal; +import java.security.spec.AlgorithmParameterSpec; import java.util.Set; import org.keycloak.KeycloakPrincipal; @@ -54,7 +55,7 @@ public class KeycloakSecurityRealm implements SecurityRealm { } @Override - public SupportLevel getCredentialAcquireSupport(Class credentialType, String algorithmName) throws RealmUnavailableException { + public SupportLevel getCredentialAcquireSupport(Class credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException { return SupportLevel.UNSUPPORTED; } @@ -92,7 +93,7 @@ public class KeycloakSecurityRealm implements SecurityRealm { } @Override - public SupportLevel getCredentialAcquireSupport(Class credentialType, String algorithmName) throws RealmUnavailableException { + public SupportLevel getCredentialAcquireSupport(Class credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException { return SupportLevel.UNSUPPORTED; } diff --git a/adapters/saml/wildfly-elytron/src/main/java/org/keycloak/adapters/saml/elytron/KeycloakSecurityRealm.java b/adapters/saml/wildfly-elytron/src/main/java/org/keycloak/adapters/saml/elytron/KeycloakSecurityRealm.java index 3207835360..f79b60d25e 100644 --- a/adapters/saml/wildfly-elytron/src/main/java/org/keycloak/adapters/saml/elytron/KeycloakSecurityRealm.java +++ b/adapters/saml/wildfly-elytron/src/main/java/org/keycloak/adapters/saml/elytron/KeycloakSecurityRealm.java @@ -17,6 +17,7 @@ package org.keycloak.adapters.saml.elytron; import java.security.Principal; +import java.security.spec.AlgorithmParameterSpec; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -53,7 +54,7 @@ public class KeycloakSecurityRealm implements SecurityRealm { } @Override - public SupportLevel getCredentialAcquireSupport(Class credentialType, String algorithmName) throws RealmUnavailableException { + public SupportLevel getCredentialAcquireSupport(Class aClass, String s, AlgorithmParameterSpec algorithmParameterSpec) throws RealmUnavailableException { return SupportLevel.UNSUPPORTED; } @@ -90,7 +91,7 @@ public class KeycloakSecurityRealm implements SecurityRealm { } @Override - public SupportLevel getCredentialAcquireSupport(Class credentialType, String algorithmName) throws RealmUnavailableException { + public SupportLevel getCredentialAcquireSupport(Class credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec) throws RealmUnavailableException { return SupportLevel.UNSUPPORTED; } diff --git a/distribution/adapters/shared-cli/adapter-elytron-install.cli b/distribution/adapters/shared-cli/adapter-elytron-install.cli index 16f17ce9a8..6ef26d01e5 100644 --- a/distribution/adapters/shared-cli/adapter-elytron-install.cli +++ b/distribution/adapters/shared-cli/adapter-elytron-install.cli @@ -36,10 +36,10 @@ else end-if if (outcome != success) of /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:read-resource - /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:add(http-server-factories=[keycloak-oidc-http-server-mechanism-factory, global]) + /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:add(http-server-mechanism-factories=[keycloak-oidc-http-server-mechanism-factory, global]) else echo Keycloak HTTP Mechanism Factory already installed. Trying to install Keycloak OpenID Connect HTTP Mechanism Factory. - /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:list-add(name=http-server-factories, value=keycloak-oidc-http-server-mechanism-factory) + /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:list-add(name=http-server-mechanism-factories, value=keycloak-oidc-http-server-mechanism-factory) end-if diff --git a/distribution/adapters/wildfly-adapter/cli/adapter-elytron-install-offline.cli b/distribution/adapters/wildfly-adapter/cli/adapter-elytron-install-offline.cli index 8e0335ac02..76ec08cb17 100644 --- a/distribution/adapters/wildfly-adapter/cli/adapter-elytron-install-offline.cli +++ b/distribution/adapters/wildfly-adapter/cli/adapter-elytron-install-offline.cli @@ -38,10 +38,10 @@ else end-if if (outcome != success) of /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:read-resource - /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:add(http-server-factories=[keycloak-oidc-http-server-mechanism-factory, global]) + /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:add(http-server-mechanism-factories=[keycloak-oidc-http-server-mechanism-factory, global]) else echo Keycloak HTTP Mechanism Factory already installed. Trying to install Keycloak OpenID Connect HTTP Mechanism Factory. - /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:list-add(name=http-server-factories, value=keycloak-oidc-http-server-mechanism-factory) + /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:list-add(name=http-server-mechanism-factories, value=keycloak-oidc-http-server-mechanism-factory) end-if diff --git a/distribution/saml-adapters/shared-cli/adapter-elytron-install-saml.cli b/distribution/saml-adapters/shared-cli/adapter-elytron-install-saml.cli index 1f24085459..a76109b809 100755 --- a/distribution/saml-adapters/shared-cli/adapter-elytron-install-saml.cli +++ b/distribution/saml-adapters/shared-cli/adapter-elytron-install-saml.cli @@ -36,10 +36,10 @@ else end-if if (outcome != success) of /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:read-resource - /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:add(http-server-factories=[keycloak-saml-http-server-mechanism-factory, global]) + /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:add(http-server-mechanism-factories=[keycloak-saml-http-server-mechanism-factory, global]) else echo Keycloak HTTP Mechanism Factory already installed. Trying to install Keycloak SAML HTTP Mechanism Factory. - /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:list-add(name=http-server-factories, value=keycloak-saml-http-server-mechanism-factory) + /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:list-add(name=http-server-mechanism-factories, value=keycloak-saml-http-server-mechanism-factory) end-if if (outcome != success) of /subsystem=elytron/http-authentication-factory=keycloak-http-authentication:read-resource diff --git a/pom.xml b/pom.xml index 7389fa745f..0c5a771617 100755 --- a/pom.xml +++ b/pom.xml @@ -49,8 +49,8 @@ 1.2.2.Final 3.0.0.Beta30 - 1.1.0.Beta32 - 1.0.0.Beta14 + 1.1.0.CR4 + 1.0.0.CR1 0.66.15 4.5 diff --git a/testsuite/integration-arquillian/pom.xml b/testsuite/integration-arquillian/pom.xml index 0bcb2b899b..cb25e181fa 100644 --- a/testsuite/integration-arquillian/pom.xml +++ b/testsuite/integration-arquillian/pom.xml @@ -45,7 +45,7 @@ 2.53.0 2.0.1.Final 2.1.0.Alpha3 - 2.1.0.Alpha2 + 2.1.0.Beta1 1.0.1.Final 1.2.0.Beta2 2.2.2