From 8dc50927f9cfe994e2c2a828aedf77826f2599d9 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Mon, 25 Aug 2014 01:58:24 +0200 Subject: [PATCH] saml: use SAML_RESPONSE from SAMLUtils Signed-off-by: Rohit Yadav --- .../api/command/SAML2LoginAPIAuthenticatorCmd.java | 8 +++----- utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java index 8456872556e..6c46b044a85 100644 --- a/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java +++ b/plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java @@ -67,9 +67,7 @@ import javax.servlet.http.HttpSession; import javax.xml.parsers.ParserConfigurationException; import javax.xml.stream.FactoryConfigurationError; import java.io.IOException; -import java.math.BigInteger; import java.net.URLEncoder; -import java.security.SecureRandom; import java.util.List; import java.util.Map; @@ -123,7 +121,7 @@ public class SAML2LoginAPIAuthenticatorCmd extends BaseCmd implements APIAuthent throw new ServerApiException(ApiErrorCode.METHOD_NOT_ALLOWED, "This is an authentication api, cannot be used directly"); } - public String buildAuthnRequestUrl(String idpUrl) { + private String buildAuthnRequestUrl(String idpUrl) { String spId = _samlAuthManager.getServiceProviderId(); String consumerUrl = _samlAuthManager.getSpSingleSignOnUrl(); String identityProviderUrl = _samlAuthManager.getIdpSingleSignOnUrl(); @@ -143,7 +141,7 @@ public class SAML2LoginAPIAuthenticatorCmd extends BaseCmd implements APIAuthent return redirectUrl; } - public Response processSAMLResponse(String responseMessage) { + private Response processSAMLResponse(String responseMessage) { Response responseObject = null; try { DefaultBootstrap.bootstrap(); @@ -168,7 +166,7 @@ public class SAML2LoginAPIAuthenticatorCmd extends BaseCmd implements APIAuthent resp.sendRedirect(redirectUrl); return ""; } else { - final String samlResponse = ((String[])params.get("SAMLResponse"))[0]; + final String samlResponse = ((String[])params.get(SAMLUtils.SAML_RESPONSE))[0]; Response processedSAMLResponse = processSAMLResponse(samlResponse); String statusCode = processedSAMLResponse.getStatus().getStatusCode().getValue(); if (!statusCode.equals(StatusCode.SUCCESS_URI)) { diff --git a/utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java b/utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java index 9eafe55cf9b..a238c82bf4c 100644 --- a/utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java +++ b/utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java @@ -72,10 +72,10 @@ import java.util.zip.DeflaterOutputStream; public class SAMLUtils { public static final Logger s_logger = Logger.getLogger(SAMLUtils.class); + public static final String SAML_RESPONSE = "SAMLResponse"; public static final String SAML_NS = "saml://"; public static final String SAML_NAMEID = "SAML_NAMEID"; public static final String SAML_SESSION = "SAML_SESSION"; - public static final String CERTIFICATE_NAME = "SAMLSP_CERTIFICATE"; public static String createSAMLId(String uid) {