Author: anil.saldhana(a)jboss.com
Date: 2011-06-06 19:25:10 -0400 (Mon, 06 Jun 2011)
New Revision: 976
Modified:
trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/SAMLRoleLoginModule.java
Log:
use string version of assertion
Modified:
trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/SAMLRoleLoginModule.java
===================================================================
---
trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/SAMLRoleLoginModule.java 2011-06-06
23:15:17 UTC (rev 975)
+++
trust/trunk/jbossws/src/main/java/org/picketlink/trust/jbossws/jaas/SAMLRoleLoginModule.java 2011-06-06
23:25:10 UTC (rev 976)
@@ -21,6 +21,7 @@
*/
package org.picketlink.trust.jbossws.jaas;
+import java.io.ByteArrayInputStream;
import java.security.Principal;
import java.security.acl.Group;
import java.util.List;
@@ -37,10 +38,9 @@
import org.jboss.security.auth.spi.AbstractServerLoginModule;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
import org.picketlink.identity.federation.core.saml.v2.util.AssertionUtil;
-import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
+import org.picketlink.identity.federation.core.util.StringUtil;
import org.picketlink.identity.federation.core.wstrust.SamlCredential;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
-import org.w3c.dom.Element;
/**
* A login module that extracts the roles from the SAML assertion
@@ -95,8 +95,7 @@
}
throw new RuntimeException("Unable to get the Identity from the subject. Set
password-stacking to useFirstPass.");
}
-
- @SuppressWarnings("static-access")
+
@Override
protected Group[] getRoleSets() throws LoginException
{
@@ -115,11 +114,13 @@
throw new RuntimeException("SAML Credential not found in the
subject");
try
- {
- DocumentUtil util = new DocumentUtil();
- Element assertionEl = samlCredential.getAssertionAsElement();
+ {
+ String assertionStr = samlCredential.getAssertionAsString();
+ if(StringUtil.isNullOrEmpty(assertionStr))
+ throw new RuntimeException("Assertion String is null or empty");
+
SAMLParser parser = new SAMLParser();
- AssertionType assertion = (AssertionType)
parser.parse(util.getNodeAsStream(assertionEl));
+ AssertionType assertion = (AssertionType) parser.parse(new
ByteArrayInputStream(assertionStr.getBytes()));
List<String> roles = AssertionUtil.getRoles(assertion, null);
Group roleGroup = new SimpleGroup(SecurityConstants.ROLES_IDENTIFIER);
for(String role: roles)
Show replies by date