utils: Remove hard coded strings from SAMLUtils

Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1b0f81ec
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1b0f81ec
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1b0f81ec

Branch: refs/heads/master
Commit: 1b0f81ec6f13ce967908049a4bb5bba0cd0a08d9
Parents: 5d94fd5
Author: Rohit Yadav <rohit.ya...@shapeblue.com>
Authored: Sun Aug 24 17:33:45 2014 +0200
Committer: Rohit Yadav <rohit.ya...@shapeblue.com>
Committed: Thu Aug 28 19:45:23 2014 +0200

----------------------------------------------------------------------
 utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1b0f81ec/utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java 
b/utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java
index bc39eaf..9c54053 100644
--- a/utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java
+++ b/utils/src/org/apache/cloudstack/utils/auth/SAMLUtils.java
@@ -19,6 +19,7 @@
 
 package org.apache.cloudstack.utils.auth;
 
+import com.cloud.utils.HttpUtils;
 import org.apache.log4j.Logger;
 import org.joda.time.DateTime;
 import org.opensaml.Configuration;
@@ -85,7 +86,7 @@ public class SAMLUtils {
         NameIDPolicyBuilder nameIdPolicyBuilder = new NameIDPolicyBuilder();
         NameIDPolicy nameIdPolicy = nameIdPolicyBuilder.buildObject();
         nameIdPolicy.setFormat(NameIDType.PERSISTENT);
-        nameIdPolicy.setSPNameQualifier("Apache CloudStack");
+        nameIdPolicy.setSPNameQualifier(spId);
         nameIdPolicy.setAllowCreate(true);
 
         // AuthnContextClass
@@ -113,7 +114,7 @@ public class SAMLUtils {
         authnRequest.setIsPassive(false);
         authnRequest.setIssuer(issuer);
         authnRequest.setIssueInstant(new DateTime());
-        authnRequest.setProviderName("Apache CloudStack");
+        authnRequest.setProviderName(spId);
         
authnRequest.setProtocolBinding(SAMLConstants.SAML2_REDIRECT_BINDING_URI);
         authnRequest.setAssertionConsumerServiceURL(consumerUrl);
         authnRequest.setNameIDPolicy(nameIdPolicy);
@@ -136,7 +137,7 @@ public class SAMLUtils {
         deflaterOutputStream.write(requestMessage.getBytes());
         deflaterOutputStream.close();
         String encodedRequestMessage = 
Base64.encodeBytes(byteArrayOutputStream.toByteArray(), 
Base64.DONT_BREAK_LINES);
-        encodedRequestMessage = URLEncoder.encode(encodedRequestMessage, 
"UTF-8").trim();
+        encodedRequestMessage = URLEncoder.encode(encodedRequestMessage, 
HttpUtils.UTF_8).trim();
         return encodedRequestMessage;
     }
 

Reply via email to