Fixing signature calculation
Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/6426abb5 Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/6426abb5 Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/6426abb5 Branch: refs/heads/master Commit: 6426abb5ab292690940bce9fd7bf99ce42eeefbb Parents: bb6d06d Author: Colm O hEigeartaigh <[email protected]> Authored: Fri Mar 25 13:31:24 2016 +0000 Committer: Colm O hEigeartaigh <[email protected]> Committed: Fri Mar 25 13:31:24 2016 +0000 ---------------------------------------------------------------------- .../service/idp/beans/samlsso/AuthnRequestValidator.java | 8 +++----- .../test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6426abb5/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestValidator.java ---------------------------------------------------------------------- diff --git a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestValidator.java b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestValidator.java index 26088d6..6a892a9 100644 --- a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestValidator.java +++ b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestValidator.java @@ -92,11 +92,9 @@ public class AuthnRequestValidator { sig.initVerify(validatingCert); // Recreate request to sign - String requestToSign = WebUtils.getHttpServletRequest(context).getRequestURL().toString() + "?"; - requestToSign += SSOConstants.RELAY_STATE + "=" + relayState; - requestToSign += "&" + SSOConstants.SAML_REQUEST + "=" + URLEncoder.encode(samlRequest, "UTF-8"); - requestToSign += "&" + SSOConstants.SIG_ALG + "=" - + URLEncoder.encode(SSOConstants.RSA_SHA1, StandardCharsets.UTF_8.name()); + String requestToSign = SSOConstants.SAML_REQUEST + "=" + URLEncoder.encode(samlRequest, "UTF-8") + + "&" + SSOConstants.RELAY_STATE + "=" + relayState + "&" + SSOConstants.SIG_ALG + + "=" + URLEncoder.encode(SSOConstants.RSA_SHA1, StandardCharsets.UTF_8.name()); sig.update(requestToSign.getBytes(StandardCharsets.UTF_8)); http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/6426abb5/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java ---------------------------------------------------------------------- diff --git a/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java b/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java index bdf72d4..0a165c5 100644 --- a/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java +++ b/systests/samlsso/src/test/java/org/apache/cxf/fediz/systests/idp/IdpTest.java @@ -421,9 +421,8 @@ public class IdpTest { java.security.Signature signature = java.security.Signature.getInstance("SHA1withRSA"); signature.initSign(privateKey); - String requestToSign = "https://localhost:" + getIdpHttpsPort() + "/fediz-idp/saml/up?"; - requestToSign += SSOConstants.RELAY_STATE + "=" + relayState; - requestToSign += "&" + SSOConstants.SAML_REQUEST + "=" + urlEncodedRequest; + String requestToSign = SSOConstants.SAML_REQUEST + "=" + urlEncodedRequest; + requestToSign += "&" + SSOConstants.RELAY_STATE + "=" + relayState; requestToSign += "&" + SSOConstants.SIG_ALG + "=" + URLEncoder.encode(SSOConstants.RSA_SHA1, StandardCharsets.UTF_8.name());
