[jboss-cvs] Picketlink SVN: r1025 - in federation/trunk: picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 23 11:11:08 EDT 2011


Author: anil.saldhana at jboss.com
Date: 2011-06-23 11:11:07 -0400 (Thu, 23 Jun 2011)
New Revision: 1025

Added:
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAML11ParserUtil.java
   federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-assertion-attribstat.xml
Modified:
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAML11AssertionParser.java
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java
   federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/SAML11Constants.java
   federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11AssertionParserTestCase.java
   federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11AttributeStatementType.java
   federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11AttributeType.java
   federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11SubjectStatementType.java
Log:
PLFED-189: more parsing

Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAML11AssertionParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAML11AssertionParser.java	2011-06-23 01:06:53 UTC (rev 1024)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAML11AssertionParser.java	2011-06-23 15:11:07 UTC (rev 1025)
@@ -21,9 +21,6 @@
  */
 package org.picketlink.identity.federation.core.parsers.saml;
 
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
 import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLEventReader;
@@ -32,12 +29,11 @@
 import javax.xml.stream.events.StartElement;
 import javax.xml.stream.events.XMLEvent;
 
-import org.jboss.security.xacml.core.model.context.RequestType;
-import org.jboss.security.xacml.core.model.context.ResponseType;
 import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
 import org.picketlink.identity.federation.core.exceptions.ParsingException;
 import org.picketlink.identity.federation.core.exceptions.ProcessingException;
 import org.picketlink.identity.federation.core.parsers.ParserNamespaceSupport;
+import org.picketlink.identity.federation.core.parsers.util.SAML11ParserUtil;
 import org.picketlink.identity.federation.core.parsers.util.SAMLParserUtil;
 import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
 import org.picketlink.identity.federation.core.saml.v1.SAML11Constants;
@@ -47,6 +43,7 @@
 import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
 import org.picketlink.identity.federation.core.util.StringUtil;
 import org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType;
+import org.picketlink.identity.federation.saml.v1.assertion.SAML11AttributeStatementType;
 import org.picketlink.identity.federation.saml.v1.assertion.SAML11AuthenticationStatementType;
 import org.picketlink.identity.federation.saml.v1.assertion.SAML11ConditionsType;
 import org.picketlink.identity.federation.saml.v1.assertion.SAML11SubjectStatementType;
@@ -187,6 +184,12 @@
             SAML11AuthenticationStatementType authStat = SAMLParserUtil.parseAuthenticationStatement(xmlEventReader);
             assertion.add(authStat);
          }
+         else if (JBossSAMLConstants.ATTRIBUTE_STATEMENT.get().equalsIgnoreCase(tag))
+         {
+            SAML11AttributeStatementType attributeStatementType = SAML11ParserUtil
+                  .parseSAML11AttributeStatement(xmlEventReader);
+            assertion.add(attributeStatementType);
+         }
          /*else if (JBossSAMLConstants.AUTHN_STATEMENT.get().equalsIgnoreCase(tag))
          {
             AuthnStatementType authnStatementType = SAMLParserUtil.parseAuthnStatement(xmlEventReader);
@@ -229,7 +232,7 @@
                throw new RuntimeException("Unknown xsi:type=" + xsiTypeValue);
          }*/
          else
-            throw new RuntimeException("SAMLAssertionParser:: unknown: " + tag + "::location="
+            throw new RuntimeException("SAML11AssertionParser:: unknown: " + tag + "::location="
                   + peekedElement.getLocation());
       }
       return assertion;
@@ -250,6 +253,8 @@
    private SAML11AssertionType parseBaseAttributes(StartElement nextElement) throws ParsingException
    {
       Attribute idAttribute = nextElement.getAttributeByName(new QName(SAML11Constants.ASSERTIONID));
+      if (idAttribute == null)
+         throw new ParsingException("Required attribute AssertionID missing");
       String id = StaxParserUtil.getAttributeValue(idAttribute);
 
       Attribute majVersionAttribute = nextElement.getAttributeByName(new QName(SAML11Constants.MAJOR_VERSION));
@@ -266,46 +271,4 @@
 
       return new SAML11AssertionType(id, issueInstant);
    }
-
-   @SuppressWarnings("unchecked")
-   private ResponseType getXACMLResponse(XMLEventReader xmlEventReader) throws ParsingException
-   {
-      Element xacmlResponse = StaxParserUtil.getDOMElement(xmlEventReader);
-      //xacml request
-      String xacmlPath = "org.jboss.security.xacml.core.model.context";
-      try
-      {
-         JAXBContext jaxb = JAXBContext.newInstance(xacmlPath);
-         Unmarshaller un = jaxb.createUnmarshaller();
-         un.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
-         JAXBElement<ResponseType> jaxbResponseType = (JAXBElement<ResponseType>) un.unmarshal(DocumentUtil
-               .getNodeAsStream(xacmlResponse));
-         return jaxbResponseType.getValue();
-      }
-      catch (Exception e)
-      {
-         throw new ParsingException(e);
-      }
-   }
-
-   @SuppressWarnings("unchecked")
-   private RequestType getXACMLRequest(XMLEventReader xmlEventReader) throws ParsingException
-   {
-      Element xacmlRequest = StaxParserUtil.getDOMElement(xmlEventReader);
-      //xacml request
-      String xacmlPath = "org.jboss.security.xacml.core.model.context";
-      try
-      {
-         JAXBContext jaxb = JAXBContext.newInstance(xacmlPath);
-         Unmarshaller un = jaxb.createUnmarshaller();
-         un.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
-         JAXBElement<RequestType> jaxbRequestType = (JAXBElement<RequestType>) un.unmarshal(DocumentUtil
-               .getNodeAsStream(xacmlRequest));
-         return jaxbRequestType.getValue();
-      }
-      catch (Exception e)
-      {
-         throw new ParsingException(e);
-      }
-   }
 }
\ No newline at end of file

Added: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAML11ParserUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAML11ParserUtil.java	                        (rev 0)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAML11ParserUtil.java	2011-06-23 15:11:07 UTC (rev 1025)
@@ -0,0 +1,183 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.identity.federation.core.parsers.util;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.picketlink.identity.federation.core.exceptions.ParsingException;
+import org.picketlink.identity.federation.core.parsers.saml.SAML11SubjectParser;
+import org.picketlink.identity.federation.core.saml.v1.SAML11Constants;
+import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
+import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
+import org.picketlink.identity.federation.saml.v1.assertion.SAML11AttributeStatementType;
+import org.picketlink.identity.federation.saml.v1.assertion.SAML11AttributeType;
+import org.picketlink.identity.federation.saml.v1.assertion.SAML11SubjectType;
+
+/**
+ * Utility for parsing SAML 1.1 payload
+ * @author Anil.Saldhana at redhat.com
+ * @since Jun 23, 2011
+ */
+public class SAML11ParserUtil
+{
+   /**
+    * Parse an {@code SAML11AttributeStatementType}
+    * @param xmlEventReader
+    * @return
+    * @throws ParsingException
+    */
+   public static SAML11AttributeStatementType parseSAML11AttributeStatement(XMLEventReader xmlEventReader)
+         throws ParsingException
+   {
+      SAML11AttributeStatementType attributeStatementType = new SAML11AttributeStatementType();
+
+      StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+      String ATTRIBSTATEMT = JBossSAMLConstants.ATTRIBUTE_STATEMENT.get();
+      StaxParserUtil.validate(startElement, ATTRIBSTATEMT);
+
+      while (xmlEventReader.hasNext())
+      {
+         XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
+         if (xmlEvent instanceof EndElement)
+         {
+            EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+            StaxParserUtil.validate(endElement, JBossSAMLConstants.ATTRIBUTE_STATEMENT.get());
+            break;
+         }
+         //Get the next start element
+         startElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
+         String tag = startElement.getName().getLocalPart();
+         if (JBossSAMLConstants.ATTRIBUTE.get().equals(tag))
+         {
+            SAML11AttributeType attribute = parseSAML11Attribute(xmlEventReader);
+            attributeStatementType.add(attribute);
+         }
+         else if (JBossSAMLConstants.SUBJECT.get().equals(tag))
+         {
+            SAML11SubjectParser parser = new SAML11SubjectParser();
+            SAML11SubjectType subject = (SAML11SubjectType) parser.parse(xmlEventReader);
+            attributeStatementType.setSubject(subject);
+         }
+         else
+            throw new RuntimeException("Unknown tag:" + tag + "::Location=" + startElement.getLocation());
+      }
+      return attributeStatementType;
+   }
+
+   /**
+    * Parse a {@link SAML11AttributeType}
+    * @param xmlEventReader
+    * @return
+    * @throws ParsingException
+    */
+   public static SAML11AttributeType parseSAML11Attribute(XMLEventReader xmlEventReader) throws ParsingException
+   {
+      StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+      StaxParserUtil.validate(startElement, JBossSAMLConstants.ATTRIBUTE.get());
+      SAML11AttributeType attributeType = null;
+
+      Attribute name = startElement.getAttributeByName(new QName(SAML11Constants.ATTRIBUTE_NAME));
+      if (name == null)
+         throw new RuntimeException("Required attribute Name in Attribute");
+      String attribName = StaxParserUtil.getAttributeValue(name);
+
+      Attribute namesp = startElement.getAttributeByName(new QName(SAML11Constants.ATTRIBUTE_NAMESPACE));
+      if (namesp == null)
+         throw new RuntimeException("Required attribute Namespace in Attribute");
+      String attribNamespace = StaxParserUtil.getAttributeValue(namesp);
+
+      attributeType = new SAML11AttributeType(attribName, URI.create(attribNamespace));
+
+      attributeType.add(parseAttributeValue(xmlEventReader));
+
+      parseAttributeType(xmlEventReader, startElement, JBossSAMLConstants.ATTRIBUTE.get(), attributeType);
+      return attributeType;
+   }
+
+   /**
+    * Parse an {@code SAML11AttributeType}
+    * @param xmlEventReader 
+    * @throws ParsingException
+    */
+   public static void parseAttributeType(XMLEventReader xmlEventReader, StartElement startElement, String rootTag,
+         SAML11AttributeType attributeType) throws ParsingException
+   {
+      while (xmlEventReader.hasNext())
+      {
+         XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
+         if (xmlEvent instanceof EndElement)
+         {
+            EndElement end = StaxParserUtil.getNextEndElement(xmlEventReader);
+            if (StaxParserUtil.matches(end, rootTag))
+               break;
+         }
+         startElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
+         if (startElement == null)
+            break;
+         String tag = StaxParserUtil.getStartElementName(startElement);
+
+         if (JBossSAMLConstants.ATTRIBUTE.get().equals(tag))
+            break;
+
+         if (JBossSAMLConstants.ATTRIBUTE_VALUE.get().equals(tag))
+         {
+            Object attributeValue = parseAttributeValue(xmlEventReader);
+            attributeType.add(attributeValue);
+         }
+         else
+            throw new RuntimeException("Unknown tag:" + tag + "::Location=" + startElement.getLocation());
+      }
+   }
+
+   /**
+    * Parse Attribute value
+    * @param xmlEventReader
+    * @return
+    * @throws ParsingException
+    */
+   public static Object parseAttributeValue(XMLEventReader xmlEventReader) throws ParsingException
+   {
+      StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+      StaxParserUtil.validate(startElement, JBossSAMLConstants.ATTRIBUTE_VALUE.get());
+
+      Attribute type = startElement.getAttributeByName(new QName(JBossSAMLURIConstants.XSI_NSURI.get(), "type", "xsi"));
+      if (type == null)
+      {
+         return StaxParserUtil.getElementText(xmlEventReader);
+      }
+
+      String typeValue = StaxParserUtil.getAttributeValue(type);
+      if (typeValue.contains(":string"))
+      {
+         return StaxParserUtil.getElementText(xmlEventReader);
+      }
+
+      throw new RuntimeException("Unsupported xsi:type=" + typeValue);
+   }
+}

Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java	2011-06-23 01:06:53 UTC (rev 1024)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java	2011-06-23 15:11:07 UTC (rev 1025)
@@ -117,50 +117,6 @@
 
       parseAttributeType(xmlEventReader, startElement, JBossSAMLConstants.ATTRIBUTE.get(), attributeType);
 
-      /*//Look for X500 Encoding
-      QName x500EncodingName = new QName( JBossSAMLURIConstants.X500_NSURI.get(), 
-            JBossSAMLConstants.ENCODING.get(), JBossSAMLURIConstants.X500_PREFIX.get() );
-      Attribute x500EncodingAttr = startElement.getAttributeByName( x500EncodingName );
-      
-      if( x500EncodingAttr != null )
-      {   
-         attributeType.getOtherAttributes().put( x500EncodingAttr.getName(), StaxParserUtil.getAttributeValue( x500EncodingAttr ));
-      }
-      
-      
-      Attribute friendlyName = startElement.getAttributeByName( new QName( JBossSAMLConstants.FRIENDLY_NAME.get() ));
-      if( friendlyName != null ) 
-         attributeType.setFriendlyName( StaxParserUtil.getAttributeValue( friendlyName ));
-      
-      Attribute nameFormat = startElement.getAttributeByName( new QName( JBossSAMLConstants.NAME_FORMAT.get() ));
-      if( nameFormat != null ) 
-         attributeType.setNameFormat( StaxParserUtil.getAttributeValue( nameFormat ));
-      
-      while( xmlEventReader.hasNext() )
-      {
-         XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
-         if( xmlEvent instanceof EndElement )
-         {
-            EndElement end = StaxParserUtil.getNextEndElement(xmlEventReader);
-            if( StaxParserUtil.matches( end, JBossSAMLConstants.ATTRIBUTE.get() ))
-               break;
-         }
-         startElement = StaxParserUtil.peekNextStartElement(xmlEventReader);
-         if( startElement == null )
-            break;
-         String tag = StaxParserUtil.getStartElementName(startElement);
-         
-         if( JBossSAMLConstants.ATTRIBUTE.get().equals( tag ))
-            break;
-         
-         if( JBossSAMLConstants.ATTRIBUTE_VALUE.get().equals( tag ) )
-         {
-            Object attributeValue = parseAttributeValue(xmlEventReader);
-            attributeType.addAttributeValue( attributeValue ); 
-         }
-         else throw new RuntimeException( "Unknown tag:" + tag );
-      }*/
-
       return attributeType;
    }
 

Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/SAML11Constants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/SAML11Constants.java	2011-06-23 01:06:53 UTC (rev 1024)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v1/SAML11Constants.java	2011-06-23 15:11:07 UTC (rev 1025)
@@ -31,6 +31,10 @@
 
    String ASSERTION_11_NSURI = "urn:oasis:names:tc:SAML:1.0:assertion";
 
+   String ATTRIBUTE_NAME = "AttributeName";
+
+   String ATTRIBUTE_NAMESPACE = "AttributeNamespace";
+
    String AUTHENTICATION_INSTANT = "AuthenticationInstant";
 
    String AUTHENTICATION_METHOD = "AuthenticationMethod";

Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11AssertionParserTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11AssertionParserTestCase.java	2011-06-23 01:06:53 UTC (rev 1024)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/saml/SAML11AssertionParserTestCase.java	2011-06-23 15:11:07 UTC (rev 1025)
@@ -23,14 +23,18 @@
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.InputStream;
 import java.net.URI;
+import java.util.List;
 
 import org.junit.Test;
 import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
 import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
 import org.picketlink.identity.federation.saml.v1.assertion.SAML11AssertionType;
+import org.picketlink.identity.federation.saml.v1.assertion.SAML11AttributeStatementType;
+import org.picketlink.identity.federation.saml.v1.assertion.SAML11AttributeType;
 import org.picketlink.identity.federation.saml.v1.assertion.SAML11AuthenticationStatementType;
 import org.picketlink.identity.federation.saml.v1.assertion.SAML11ConditionsType;
 import org.picketlink.identity.federation.saml.v1.assertion.SAML11SubjectConfirmationType;
@@ -77,4 +81,61 @@
       URI confirmationMethod = subjectConfirm.getConfirmationMethod().get(0);
       assertEquals("urn:oasis:names:tc:SAML:1.0:cm:bearer", confirmationMethod.toString());
    }
+
+   @Test
+   public void testSAML11AssertionWithAttributeStatements() throws Exception
+   {
+      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+      InputStream configStream = tcl.getResourceAsStream("parser/saml1/saml1-assertion-attribstat.xml");
+
+      SAMLParser parser = new SAMLParser();
+      SAML11AssertionType assertion = (SAML11AssertionType) parser.parse(configStream);
+      assertNotNull(assertion);
+
+      //Validate assertion
+      assertEquals(1, assertion.getMajorVersion());
+      assertEquals(1, assertion.getMinorVersion());
+      assertEquals("buGxcG4gILg5NlocyLccDz6iXrUb", assertion.getID());
+      assertEquals("https://idp.example.org/saml", assertion.getIssuer());
+      assertEquals(XMLTimeUtil.parse("2002-06-19T17:05:37.795Z"), assertion.getIssueInstant());
+
+      SAML11ConditionsType conditions = assertion.getConditions();
+      assertEquals(XMLTimeUtil.parse("2002-06-19T17:05:37.795Z"), conditions.getNotBefore());
+      assertEquals(XMLTimeUtil.parse("2002-06-19T17:15:37.795Z"), conditions.getNotOnOrAfter());
+
+      SAML11AuthenticationStatementType stat = (SAML11AuthenticationStatementType) assertion.getStatements().get(0);
+      assertEquals("urn:oasis:names:tc:SAML:1.0:am:password", stat.getAuthenticationMethod().toString());
+      assertEquals(XMLTimeUtil.parse("2002-06-19T17:08:37.795Z"), stat.getAuthenticationInstant());
+
+      SAML11SubjectType subject = stat.getSubject();
+      SAML11SubjectType.SAML11SubjectTypeChoice choice = subject.getChoice();
+      assertEquals("user at idp.example.org", choice.getNameID().getNameQualifier());
+      assertEquals("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", choice.getNameID().getFormat().toString());
+
+      SAML11SubjectConfirmationType subjectConfirm = subject.getSubjectConfirmation();
+      URI confirmationMethod = subjectConfirm.getConfirmationMethod().get(0);
+      assertEquals("urn:oasis:names:tc:SAML:1.0:cm:bearer", confirmationMethod.toString());
+
+      SAML11AttributeStatementType attribStat = (SAML11AttributeStatementType) assertion.getStatements().get(1);
+      assertNotNull(attribStat);
+      subject = attribStat.getSubject();
+
+      choice = subject.getChoice();
+      assertEquals("user at idp.example.org", choice.getNameID().getNameQualifier());
+      assertEquals("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", choice.getNameID().getFormat().toString());
+
+      subjectConfirm = subject.getSubjectConfirmation();
+      confirmationMethod = subjectConfirm.getConfirmationMethod().get(0);
+      assertEquals("urn:oasis:names:tc:SAML:1.0:cm:bearer", confirmationMethod.toString());
+
+      List<SAML11AttributeType> attribs = attribStat.get();
+      assertEquals(1, attribs.size());
+      SAML11AttributeType attrib = attribs.get(0);
+      assertEquals("urn:mace:dir:attribute-def:eduPersonAffiliation", attrib.getAttributeName());
+      assertEquals("urn:mace:shibboleth:1.0:attributeNamespace:uri", attrib.getAttributeNamespace().toString());
+
+      List<Object> attribValues = attrib.get();
+      assertTrue(attribValues.contains("member"));
+      assertTrue(attribValues.contains("student"));
+   }
 }
\ No newline at end of file

Added: federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-assertion-attribstat.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-assertion-attribstat.xml	                        (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/resources/parser/saml1/saml1-assertion-attribstat.xml	2011-06-23 15:11:07 UTC (rev 1025)
@@ -0,0 +1,42 @@
+<saml:Assertion
+   xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
+   MajorVersion="1" MinorVersion="1"
+   Issuer="https://idp.example.org/saml" 
+   AssertionID="buGxcG4gILg5NlocyLccDz6iXrUb"
+   IssueInstant="2002-06-19T17:05:37.795Z">
+   <saml:Conditions NotBefore="2002-06-19T17:05:37.795Z" NotOnOrAfter="2002-06-19T17:15:37.795Z"/>
+   <saml:AuthenticationStatement
+     AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password"
+     AuthenticationInstant="2002-06-19T17:08:37.795Z">
+     <saml:Subject>
+       <saml:NameIdentifier
+         Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">
+         user at idp.example.org
+       </saml:NameIdentifier>
+       <saml:SubjectConfirmation>
+         <saml:ConfirmationMethod>
+           urn:oasis:names:tc:SAML:1.0:cm:bearer
+         </saml:ConfirmationMethod>
+       </saml:SubjectConfirmation>
+     </saml:Subject>
+   </saml:AuthenticationStatement>
+   <saml:AttributeStatement>
+     <saml:Subject>
+       <saml:NameIdentifier
+         Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">
+         user at idp.example.org
+       </saml:NameIdentifier>
+       <saml:SubjectConfirmation>
+         <saml:ConfirmationMethod>
+           urn:oasis:names:tc:SAML:1.0:cm:bearer
+         </saml:ConfirmationMethod>
+       </saml:SubjectConfirmation>
+     </saml:Subject>
+     <saml:Attribute
+       AttributeName="urn:mace:dir:attribute-def:eduPersonAffiliation"
+       AttributeNamespace="urn:mace:shibboleth:1.0:attributeNamespace:uri">
+       <saml:AttributeValue>member</saml:AttributeValue>
+       <saml:AttributeValue>student</saml:AttributeValue>
+     </saml:Attribute>
+   </saml:AttributeStatement>
+ </saml:Assertion>
\ No newline at end of file

Modified: federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11AttributeStatementType.java
===================================================================
--- federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11AttributeStatementType.java	2011-06-23 01:06:53 UTC (rev 1024)
+++ federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11AttributeStatementType.java	2011-06-23 15:11:07 UTC (rev 1025)
@@ -46,19 +46,19 @@
 
    protected List<SAML11AttributeType> attribute = new ArrayList<SAML11AttributeType>();
 
-   public void add(SAML11AttributeType statement)
+   public void add(SAML11AttributeType aAttribute)
    {
-      this.attribute.add(statement);
+      this.attribute.add(aAttribute);
    }
 
-   public void addAllStatements(List<SAML11AttributeType> statement)
+   public void addAllAttributes(List<SAML11AttributeType> attribList)
    {
-      this.attribute.addAll(statement);
+      this.attribute.addAll(attribList);
    }
 
-   public boolean remove(SAML11AttributeType statement)
+   public boolean remove(SAML11AttributeType anAttrib)
    {
-      return this.attribute.remove(statement);
+      return this.attribute.remove(anAttrib);
    }
 
    public List<SAML11AttributeType> get()

Modified: federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11AttributeType.java
===================================================================
--- federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11AttributeType.java	2011-06-23 01:06:53 UTC (rev 1024)
+++ federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11AttributeType.java	2011-06-23 15:11:07 UTC (rev 1025)
@@ -49,19 +49,19 @@
       super(attributeName, attributeNamespace);
    }
 
-   public void add(Object advice)
+   public void add(Object attribValue)
    {
-      this.attributeValues.add(advice);
+      this.attributeValues.add(attribValue);
    }
 
-   public void addAll(List<Object> advice)
+   public void addAll(List<Object> attribValueList)
    {
-      this.attributeValues.addAll(advice);
+      this.attributeValues.addAll(attribValueList);
    }
 
-   public boolean remove(Object advice)
+   public boolean remove(Object attribVal)
    {
-      return this.attributeValues.remove(advice);
+      return this.attributeValues.remove(attribVal);
    }
 
    public List<Object> get()

Modified: federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11SubjectStatementType.java
===================================================================
--- federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11SubjectStatementType.java	2011-06-23 01:06:53 UTC (rev 1024)
+++ federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/saml/v1/assertion/SAML11SubjectStatementType.java	2011-06-23 15:11:07 UTC (rev 1025)
@@ -42,6 +42,15 @@
 
    protected SAML11SubjectType subject;
 
+   public SAML11SubjectStatementType()
+   {
+   }
+
+   public SAML11SubjectStatementType(SAML11SubjectType subject)
+   {
+      this.subject = subject;
+   }
+
    public SAML11SubjectType getSubject()
    {
       return subject;



More information about the jboss-cvs-commits mailing list