Picketlink SVN: r754 - idm/branches.
by picketlink-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2011-02-18 12:54:43 -0500 (Fri, 18 Feb 2011)
New Revision: 754
Added:
idm/branches/config/
Log:
14 years, 10 months
Picketlink SVN: r753 - in federation/trunk: picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp and 16 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-02-17 21:28:51 -0500 (Thu, 17 Feb 2011)
New Revision: 753
Added:
federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/saml/handlers/SAML2AuthenticationHandlerUnitTestCase.java
Modified:
federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/idp/IDPWebBrowserSSOValve.java
federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPRedirectSignatureFormAuthenticator.java
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLResponseParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/DocumentUtil.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/XMLEncryptionUtil.java
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/EncryptedAssertionType.java
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/EncryptedElementType.java
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/protocol/ResponseType.java
federation/trunk/picketlink-web/pom.xml
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/constants/GeneralConstants.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/filters/SPFilter.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/handlers/saml2/SAML2AuthenticationHandler.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/process/ServiceProviderSAMLResponseProcessor.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/IDPServlet.java
Log:
PLFED-137: handle encrypted assertions
Modified: federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/idp/IDPWebBrowserSSOValve.java
===================================================================
--- federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/idp/IDPWebBrowserSSOValve.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/idp/IDPWebBrowserSSOValve.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -395,7 +395,7 @@
requestOptions.put(GeneralConstants.ASSERTIONS_VALIDITY, this.assertionValidity);
requestOptions.put(GeneralConstants.CONFIGURATION, this.idpConfiguration);
if( assertionID != null )
- requestOptions.put(GeneralConstants.ASSERTION_ID, assertionID );
+ requestOptions.put(GeneralConstants.ASSERTION_ID, assertionID );
if(this.keyManager != null)
{
@@ -406,6 +406,7 @@
}
PublicKey validatingKey = CoreConfigUtil.getValidatingKey(keyManager, remoteHost );
requestOptions.put(GeneralConstants.SENDER_PUBLIC_KEY, validatingKey);
+ requestOptions.put( GeneralConstants.DECRYPTING_KEY, keyManager.getSigningKey() );
}
Map<String,Object> attribs = this.attribManager.getAttributes(userPrincipal, attributeKeys);
Modified: federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPRedirectSignatureFormAuthenticator.java
===================================================================
--- federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPRedirectSignatureFormAuthenticator.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPRedirectSignatureFormAuthenticator.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -193,9 +193,7 @@
EncryptedElementType myEET = (EncryptedElementType) responseType.getAssertions().get(0).getEncryptedAssertion();
Document eetDoc = saml2Response.convert(myEET);
- Element decryptedDocumentElement = XMLEncryptionUtil.decryptElementInDocument(eetDoc,privateKey);
-
- //Let us use the encrypted doc element to decrypt it
+ Element decryptedDocumentElement = XMLEncryptionUtil.decryptElementInDocument(eetDoc,privateKey);
return saml2Response.getResponseType(DocumentUtil.getNodeAsStream(decryptedDocumentElement));
}
catch (Exception e)
Modified: federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
===================================================================
--- federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -71,6 +71,7 @@
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusResponseType;
import org.picketlink.identity.federation.saml.v2.SAML2Object;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
@@ -234,6 +235,20 @@
{
return JBossSAMLAuthnResponseFactory.createResponseType(ID, issuerInfo, assertion);
}
+
+ /**
+ * Create a ResponseType
+ * @param ID
+ * @param issuerInfo
+ * @param encryptedAssertion a DOM {@link Element} that represents an encrypted assertion
+ * @return
+ * @throws ConfigurationException
+ */
+ public ResponseType createResponseType(String ID, IssuerInfoHolder issuerInfo, Element encryptedAssertion)
+ throws ConfigurationException
+ {
+ return JBossSAMLAuthnResponseFactory.createResponseType(ID, issuerInfo, encryptedAssertion);
+ }
/**
* Add validity conditions to the SAML2 Assertion
Modified: federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-api/src/test/java/org/picketlink/test/identity/federation/api/util/XMLEncryptionUnitTestCase.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -83,6 +83,8 @@
Element docElement = XMLEncryptionUtil.encryptElementInDocument(responseDoc,kp.getPublic(), sk,
128, assertionQName, true);
+ System.out.println( DocumentUtil.getDOMElementAsString(docElement));
+
// System.out.println( DocumentUtil.getNodeAsString(docElement));
InputStream is = DocumentUtil.getNodeAsStream( docElement );
@@ -95,7 +97,7 @@
Document eetDoc = sr.convert( encryptedAssertionType );
Element decryptedDocumentElement = XMLEncryptionUtil.decryptElementInDocument(eetDoc,kp.getPrivate());
-
+
//Let us use the encrypted doc element to decrypt it
ResponseType newRT = sr.getResponseType(DocumentUtil.getNodeAsStream(decryptedDocumentElement));
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLResponseParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLResponseParser.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/SAMLResponseParser.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -32,9 +32,11 @@
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.newmodel.saml.v2.assertion.AssertionType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.EncryptedAssertionType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType.RTChoiceType;
+import org.w3c.dom.Element;
/**
* Parse the SAML Response
@@ -84,6 +86,13 @@
{
response.setStatus( parseStatus(xmlEventReader) );
}
+ else if( JBossSAMLConstants.ENCRYPTED_ASSERTION.get().equals( elementName ))
+ {
+ Element encryptedAssertion = StaxParserUtil.getDOMElement(xmlEventReader);
+ response.addAssertion( new RTChoiceType( new EncryptedAssertionType(encryptedAssertion ) ));
+ }
+ else
+ throw new RuntimeException( "Unknown tag=" + elementName );
}
return response;
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -34,6 +34,7 @@
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.ConditionsType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.EncryptedAssertionType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.StatementAbstractType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectConfirmationDataType;
@@ -43,6 +44,7 @@
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType.RTChoiceType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusCodeType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusType;
+import org.w3c.dom.Element;
/**
* Factory for the SAML v2 Authn Response
@@ -168,4 +170,42 @@
responseType.addAssertion( new RTChoiceType( assertionType ));
return responseType;
}
+
+ /**
+ * Create a Response Type
+ * @param ID
+ * @param issuerInfo
+ * @param encryptedAssertion a DOM {@link Element} that represents an encrypted assertion
+ * @return
+ * @throws ConfigurationException
+ */
+ public static ResponseType createResponseType(String ID, IssuerInfoHolder issuerInfo, Element encryptedAssertion )
+ throws ConfigurationException
+ {
+ ResponseType responseType = new ResponseType();
+ responseType.setVersion(issuerInfo.getSamlVersion());
+
+ //ID
+ responseType.setID(ID);
+
+ //Issuer
+ NameIDType issuer = issuerInfo.getIssuer();
+ responseType.setIssuer(issuer);
+
+ //Status
+ String statusCode = issuerInfo.getStatusCode();
+ if(statusCode == null)
+ throw new IllegalArgumentException("issuerInfo missing status code");
+
+ responseType.setStatus(createStatusType(statusCode) );
+
+ XMLGregorianCalendar issueInstant = XMLTimeUtil.getIssueInstant();
+
+ //IssueInstant
+ responseType.setIssueInstant(issueInstant);
+
+
+ responseType.addAssertion( new RTChoiceType( new EncryptedAssertionType( encryptedAssertion ) ));
+ return responseType;
+ }
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/DocumentUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/DocumentUtil.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/DocumentUtil.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -30,6 +30,7 @@
import java.io.StringReader;
import java.io.StringWriter;
+import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -267,6 +268,28 @@
return sw.toString();
}
+
+ /**
+ * <p>Get an element from the document given its {@link QName} </p>
+ * <p>First an attempt to get the element based on its namespace is made, failing which
+ * an element with the localpart ignoring any namespace is returned.</p>
+ * @param doc
+ * @param elementQName
+ * @return
+ */
+ public static Element getElement( Document doc, QName elementQName )
+ {
+ NodeList nl = doc.getElementsByTagNameNS( elementQName.getNamespaceURI(), elementQName.getLocalPart() );
+ if( nl.getLength() == 0 )
+ {
+ nl = doc.getElementsByTagNameNS( "*", elementQName.getLocalPart() );
+ if( nl.getLength() == 0 )
+ nl = doc.getElementsByTagName( elementQName.getPrefix() + ":" + elementQName.getLocalPart() );
+ if( nl.getLength() == 0 )
+ return null;
+ }
+ return (Element) nl.item(0);
+ }
/**
* Stream a DOM Node as an input stream
@@ -280,6 +303,13 @@
return getSourceAsStream(new DOMSource(node));
}
+ /**
+ * Get the {@link Source} as an {@link InputStream}
+ * @param source
+ * @return
+ * @throws ConfigurationException
+ * @throws ProcessingException
+ */
public static InputStream getSourceAsStream(Source source) throws ConfigurationException, ProcessingException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLResponseWriter.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -43,6 +43,7 @@
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusDetailType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusResponseType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.StatusType;
+import org.w3c.dom.Element;
/**
* Write a SAML Response to stream
@@ -70,6 +71,7 @@
StaxUtil.writeStartElement( writer, PROTOCOL_PREFIX, JBossSAMLConstants.RESPONSE.get() , PROTOCOL_NSURI.get() );
StaxUtil.writeNameSpace( writer, PROTOCOL_PREFIX, PROTOCOL_NSURI.get() );
+ StaxUtil.writeNameSpace( writer, ASSERTION_PREFIX, ASSERTION_NSURI.get() );
StaxUtil.writeDefaultNameSpace( writer, ASSERTION_NSURI.get() );
writeBaseAttributes( response );
@@ -94,7 +96,8 @@
EncryptedAssertionType encryptedAssertion = choiceType.getEncryptedAssertion();
if( encryptedAssertion != null )
{
- //Skip
+ Element encElement = encryptedAssertion.getEncryptedElement();
+ StaxUtil.writeDOMElement(writer, encElement);
}
}
}
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/XMLEncryptionUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/XMLEncryptionUtil.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/util/XMLEncryptionUtil.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -35,6 +35,7 @@
import org.apache.xml.security.encryption.XMLEncryptionException;
import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -185,10 +186,7 @@
if (wrappingElementPrefix == null || wrappingElementPrefix == "")
throw new IllegalArgumentException("Wrapping element prefix invalid");
- NodeList elements = document.getElementsByTagName(elementQName.toString());
- if (elements == null || elements.getLength() > 1)
- throw new IllegalStateException("Element was either null or more than one:" + elements);
- Element documentElement = (Element) elements.item(0);
+ Element documentElement = DocumentUtil.getElement(document , elementQName );
if (documentElement == null)
throw new IllegalStateException("Element could not be found in the document:" + elementQName.toString());
Modified: federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/EncryptedAssertionType.java
===================================================================
--- federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/EncryptedAssertionType.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/EncryptedAssertionType.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -21,6 +21,8 @@
*/
package org.picketlink.identity.federation.newmodel.saml.v2.assertion;
+import org.w3c.dom.Element;
+
/**
* Assertion that is encrypted
* @author Anil.Saldhana(a)redhat.com
@@ -28,4 +30,18 @@
*/
public class EncryptedAssertionType extends EncryptedElementType
{
+ public EncryptedAssertionType()
+ {
+ super();
+ }
+
+ public EncryptedAssertionType(Element el)
+ {
+ super(el);
+ }
+
+ public String getID()
+ {
+ return null;
+ }
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/EncryptedElementType.java
===================================================================
--- federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/EncryptedElementType.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/assertion/EncryptedElementType.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -39,8 +39,17 @@
</complexType>
*/
- private Element encryptedElement;
+ protected Element encryptedElement;
+ public EncryptedElementType()
+ {
+ }
+
+ public EncryptedElementType( Element el)
+ {
+ this.encryptedElement = el;
+ }
+
public Element getEncryptedElement()
{
return encryptedElement;
Modified: federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/protocol/ResponseType.java
===================================================================
--- federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/protocol/ResponseType.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/protocol/ResponseType.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -70,6 +70,29 @@
{
assertions.remove(choice);
}
+
+ /**
+ * Replace the first assertion with the passed assertion
+ * @param id id of the old assertion
+ * @param newAssertion
+ */
+ public void replaceAssertion( String id, RTChoiceType newAssertion )
+ {
+ int index = 0;
+ if( id != null && !id.isEmpty())
+ {
+ for( RTChoiceType assertion : assertions )
+ {
+ if( assertion.getID().equals(id) )
+ {
+ break;
+ }
+ index++;
+ }
+ }
+ assertions.remove(index);
+ assertions.add(index, newAssertion);
+ }
/**
* Gets a read only list of assertions
@@ -83,13 +106,16 @@
{
private AssertionType assertion;
private EncryptedAssertionType encryptedAssertion;
+ private String id;
public RTChoiceType(AssertionType assertion)
{
this.assertion = assertion;
+ this.id = assertion.getID();
}
public RTChoiceType(EncryptedAssertionType encryptedAssertion)
{
this.encryptedAssertion = encryptedAssertion;
+
}
public AssertionType getAssertion()
{
@@ -99,5 +125,9 @@
{
return encryptedAssertion;
}
+ public String getID()
+ {
+ return id;
+ }
}
}
\ No newline at end of file
Modified: federation/trunk/picketlink-web/pom.xml
===================================================================
--- federation/trunk/picketlink-web/pom.xml 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-web/pom.xml 2011-02-18 02:28:51 UTC (rev 753)
@@ -33,7 +33,7 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.4.3</version>
+ <version>2.7.1</version>
<configuration>
<printSummary>true</printSummary>
<disableXmlReport>false</disableXmlReport>
@@ -178,6 +178,12 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/constants/GeneralConstants.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/constants/GeneralConstants.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/constants/GeneralConstants.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -48,8 +48,8 @@
String IDENTITY_SERVER = "IDENTITY_SERVER";
String IGNORE_SIGNATURES = "IGNORE_SIGNATURES";
- String KEYPAIR = "KEYPAIR";
-
+ String KEYPAIR = "KEYPAIR";
+
String LOGOUT_PAGE = "LOGOUT_PAGE";
String LOGOUT_PAGE_NAME = "/logout.jsp";
@@ -65,9 +65,10 @@
String SAML_REQUEST_KEY = "SAMLRequest";
String SAML_RESPONSE_KEY = "SAMLResponse";
+ String DECRYPTING_KEY = "DECRYPTING_KEY";
String SENDER_PUBLIC_KEY = "SENDER_PUBLIC_KEY";
String SIGN_OUTGOING_MESSAGES = "SIGN_OUTGOING_MESSAGES";
-
+
String USERNAME_FIELD = "JBID_USERNAME";
String PASS_FIELD = "JBID_PASSWORD";
}
\ No newline at end of file
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/filters/SPFilter.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/filters/SPFilter.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/filters/SPFilter.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -210,7 +210,8 @@
SAML2HandlerRequest saml2HandlerRequest =
new DefaultSAML2HandlerRequest(protocolContext,
holder.getIssuer(), null,
- HANDLER_TYPE.SP);
+ HANDLER_TYPE.SP);
+
SAML2HandlerResponse saml2HandlerResponse = new DefaultSAML2HandlerResponse();
saml2HandlerResponse.setDestination(identityURL);
@@ -305,6 +306,8 @@
new DefaultSAML2HandlerRequest(protocolContext,
holder.getIssuer(), documentHolder,
HANDLER_TYPE.SP);
+ if( keyManager != null )
+ saml2HandlerRequest.addOption( GeneralConstants.DECRYPTING_KEY, keyManager.getSigningKey() );
SAML2HandlerResponse saml2HandlerResponse = new DefaultSAML2HandlerResponse();
@@ -397,6 +400,8 @@
new DefaultSAML2HandlerRequest(protocolContext,
holder.getIssuer(), documentHolder,
HANDLER_TYPE.SP);
+ if( keyManager != null )
+ saml2HandlerRequest.addOption( GeneralConstants.DECRYPTING_KEY, keyManager.getSigningKey() );
SAML2HandlerResponse saml2HandlerResponse = new DefaultSAML2HandlerResponse();
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/handlers/saml2/SAML2AuthenticationHandler.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/handlers/saml2/SAML2AuthenticationHandler.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/handlers/saml2/SAML2AuthenticationHandler.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -23,6 +23,7 @@
import java.io.StringWriter;
import java.security.Principal;
+import java.security.PrivateKey;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -30,13 +31,17 @@
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
+import javax.xml.namespace.QName;
import org.apache.log4j.Logger;
import org.picketlink.identity.federation.api.saml.v2.request.SAML2Request;
import org.picketlink.identity.federation.api.saml.v2.response.SAML2Response;
import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.exceptions.ProcessingException;
+import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.saml.v2.common.IDGenerator;
+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.core.saml.v2.exceptions.AssertionExpiredException;
import org.picketlink.identity.federation.core.saml.v2.holders.IDPInfoHolder;
@@ -47,8 +52,10 @@
import org.picketlink.identity.federation.core.saml.v2.interfaces.SAML2HandlerRequest.GENERATE_REQUEST_TYPE;
import org.picketlink.identity.federation.core.saml.v2.interfaces.SAML2HandlerResponse;
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.saml.v2.util.StatementUtil;
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
+import org.picketlink.identity.federation.core.util.XMLEncryptionUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeStatementType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeStatementType.ASTChoiceType;
@@ -68,6 +75,7 @@
import org.picketlink.identity.federation.web.core.IdentityServer;
import org.picketlink.identity.federation.web.interfaces.IRoleValidator;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
@@ -339,10 +347,13 @@
if(assertions.size() == 0)
throw new IllegalStateException("No assertions in reply from IDP");
+ PrivateKey privateKey = (PrivateKey) request.getOptions().get( GeneralConstants.DECRYPTING_KEY );
+
Object assertion = assertions.get(0).getEncryptedAssertion();
if(assertion instanceof EncryptedAssertionType)
{
- responseType = this.decryptAssertion(responseType);
+ responseType = this.decryptAssertion(responseType, privateKey );
+ assertion = responseType.getAssertions().get(0).getAssertion();
}
if( assertion == null )
{
@@ -367,9 +378,34 @@
{
}
- private ResponseType decryptAssertion(ResponseType responseType)
+ private ResponseType decryptAssertion(ResponseType responseType, PrivateKey privateKey ) throws ProcessingException
{
- throw new RuntimeException("This authenticator does not handle encryption");
+ if( privateKey == null )
+ throw new IllegalArgumentException( "privateKey is null" );
+ SAML2Response saml2Response = new SAML2Response();
+ try
+ {
+ Document doc = saml2Response.convert( responseType );
+
+ Element enc = DocumentUtil.getElement(doc, new QName( JBossSAMLConstants.ENCRYPTED_ASSERTION.get() ));
+ if( enc == null )
+ throw new ProcessingException( "Null encrypted assertion element" );
+ String oldID = enc.getAttribute( "ID" );
+ Document newDoc = DocumentUtil.createDocument();
+ Node importedNode = newDoc.importNode(enc, true);
+ newDoc.appendChild(importedNode);
+
+ Element decryptedDocumentElement = XMLEncryptionUtil.decryptElementInDocument( newDoc, privateKey );
+ SAMLParser parser = new SAMLParser();
+ AssertionType assertion = (AssertionType) parser.parse( StaxParserUtil.getXMLEventReader( DocumentUtil.getNodeAsStream(decryptedDocumentElement)));
+
+ responseType.replaceAssertion( oldID, new RTChoiceType(assertion));
+ return responseType;
+ }
+ catch ( Exception e )
+ {
+ throw new ProcessingException( e );
+ }
}
private Principal handleSAMLResponse(ResponseType responseType, SAML2HandlerResponse response)
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/process/ServiceProviderSAMLResponseProcessor.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/process/ServiceProviderSAMLResponseProcessor.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/process/ServiceProviderSAMLResponseProcessor.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -156,6 +156,7 @@
}
PublicKey validatingKey = CoreConfigUtil.getValidatingKey(keyManager, remoteHost );
requestOptions.put(GeneralConstants.SENDER_PUBLIC_KEY, validatingKey);
+ requestOptions.put( GeneralConstants.DECRYPTING_KEY, keyManager.getSigningKey() );
}
saml2HandlerRequest.setOptions(requestOptions);
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/IDPServlet.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/IDPServlet.java 2011-02-17 19:31:32 UTC (rev 752)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/IDPServlet.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -341,7 +341,8 @@
SAML2HandlerRequest saml2HandlerRequest =
new DefaultSAML2HandlerRequest(protocolContext,
idpIssuer.getIssuer(), samlDocumentHolder,
- HANDLER_TYPE.IDP);
+ HANDLER_TYPE.IDP);
+
saml2HandlerRequest.setRelayState(relayState);
SAML2HandlerResponse saml2HandlerResponse = new DefaultSAML2HandlerResponse();
@@ -416,7 +417,7 @@
requestOptions.put(GeneralConstants.CONFIGURATION, this.idpConfiguration);
Map<String,Object> attribs = this.attribManager.getAttributes(userPrincipal, attributeKeys);
- requestOptions.put(GeneralConstants.ATTRIBUTES, attribs);
+ requestOptions.put(GeneralConstants.ATTRIBUTES, attribs);
saml2HandlerRequest.setOptions(requestOptions);
Added: federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/saml/handlers/SAML2AuthenticationHandlerUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/saml/handlers/SAML2AuthenticationHandlerUnitTestCase.java (rev 0)
+++ federation/trunk/picketlink-web/src/test/java/org/picketlink/test/identity/federation/web/saml/handlers/SAML2AuthenticationHandlerUnitTestCase.java 2011-02-18 02:28:51 UTC (rev 753)
@@ -0,0 +1,157 @@
+/*
+ * 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.test.identity.federation.web.saml.handlers;
+
+import java.security.KeyPair;
+import java.security.Principal;
+import java.security.PublicKey;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.namespace.QName;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.api.saml.v2.response.SAML2Response;
+import org.picketlink.identity.federation.core.config.SPType;
+import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.saml.v2.common.IDGenerator;
+import org.picketlink.identity.federation.core.saml.v2.common.SAMLDocumentHolder;
+import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
+import org.picketlink.identity.federation.core.saml.v2.holders.IssuerInfoHolder;
+import org.picketlink.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerChainConfig;
+import org.picketlink.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerConfig;
+import org.picketlink.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerRequest;
+import org.picketlink.identity.federation.core.saml.v2.impl.DefaultSAML2HandlerResponse;
+import org.picketlink.identity.federation.core.saml.v2.interfaces.SAML2Handler;
+import org.picketlink.identity.federation.core.saml.v2.interfaces.SAML2HandlerChainConfig;
+import org.picketlink.identity.federation.core.saml.v2.interfaces.SAML2HandlerConfig;
+import org.picketlink.identity.federation.core.saml.v2.interfaces.SAML2HandlerRequest;
+import org.picketlink.identity.federation.core.saml.v2.interfaces.SAML2HandlerResponse;
+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.KeyStoreUtil;
+import org.picketlink.identity.federation.core.util.XMLEncryptionUtil;
+import org.picketlink.identity.federation.core.wstrust.WSTrustUtil;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AssertionType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.SubjectType.STSubType;
+import org.picketlink.identity.federation.newmodel.saml.v2.protocol.ResponseType;
+import org.picketlink.identity.federation.saml.v2.SAML2Object;
+import org.picketlink.identity.federation.web.constants.GeneralConstants;
+import org.picketlink.identity.federation.web.core.HTTPContext;
+import org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler;
+import org.picketlink.test.identity.federation.web.mock.MockHttpServletRequest;
+import org.picketlink.test.identity.federation.web.mock.MockHttpServletResponse;
+import org.picketlink.test.identity.federation.web.mock.MockHttpSession;
+import org.picketlink.test.identity.federation.web.mock.MockServletContext;
+import org.w3c.dom.Document;
+
+/**
+ * Unit test the {@link SAML2AuthenticationHandler}
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 17, 2011
+ */
+public class SAML2AuthenticationHandlerUnitTestCase
+{
+ @Test
+ public void handleEncryptedAssertion() throws Exception
+ {
+ SAML2AuthenticationHandler handler = new SAML2AuthenticationHandler();
+
+ SAML2HandlerChainConfig chainConfig = new DefaultSAML2HandlerChainConfig();
+ SAML2HandlerConfig handlerConfig = new DefaultSAML2HandlerConfig();
+
+ Map<String,Object> chainOptions = new HashMap<String, Object>();
+ SPType spType = new SPType();
+ chainOptions.put(GeneralConstants.CONFIGURATION, spType );
+ chainOptions.put( GeneralConstants.ROLE_VALIDATOR_IGNORE, "true" );
+ chainConfig.set(chainOptions);
+
+ //Initialize the handler
+ handler.initChainConfig(chainConfig);
+ handler.initHandlerConfig(handlerConfig);
+
+ //Create a Protocol Context
+ MockHttpSession session = new MockHttpSession();
+ MockServletContext servletContext = new MockServletContext();
+ MockHttpServletRequest servletRequest = new MockHttpServletRequest(session, "POST");
+ MockHttpServletResponse servletResponse = new MockHttpServletResponse();
+ HTTPContext httpContext = new HTTPContext(servletRequest, servletResponse, servletContext);
+
+ SAML2Object saml2Object = new SAML2Object(){};
+
+ KeyPair keypair = KeyStoreUtil.generateKeyPair( "RSA" );
+
+
+ SAML2Response saml2Response = new SAML2Response();
+ IssuerInfoHolder issuerInfoholder = new IssuerInfoHolder( "testIssuer" );
+
+ AssertionType assertion = AssertionUtil.createAssertion( IDGenerator.create("ID_") , new NameIDType() );
+ SubjectType assertionSubject = new SubjectType();
+ STSubType subType = new STSubType();
+ NameIDType anil = new NameIDType();
+ anil.setValue( "anil" );
+ subType.addBaseID( anil );
+ assertionSubject.setSubType(subType);
+ assertion.setSubject(assertionSubject);
+
+ ResponseType responseType =
+ saml2Response.createResponseType(IDGenerator.create("ID_"), issuerInfoholder, assertion);
+
+ String assertionNS = JBossSAMLURIConstants.ASSERTION_NSURI.get();
+
+ QName assertionQName = new QName(assertionNS, "EncryptedAssertion", "saml");
+ Document responseDoc = saml2Response.convert(responseType);
+
+ byte[] secret = WSTrustUtil.createRandomSecret((int) 128 / 8);
+ SecretKey secretKey = new SecretKeySpec(secret, "AES");
+
+ PublicKey publicKey = keypair.getPublic();
+ XMLEncryptionUtil.encryptElement(new QName(assertionNS, "Assertion", "saml" ), responseDoc , publicKey, secretKey, 128, assertionQName, true);
+
+ System.out.println( DocumentUtil.asString(responseDoc));
+
+ SAMLParser parser = new SAMLParser();
+ saml2Object = (SAML2Object) parser.parse( DocumentUtil.getNodeAsStream(responseDoc));
+
+ SAMLDocumentHolder docHolder = new SAMLDocumentHolder(saml2Object, null);
+ IssuerInfoHolder issuerInfo = new IssuerInfoHolder("http://localhost:8080/idp/");
+ SAML2HandlerRequest request = new DefaultSAML2HandlerRequest(httpContext,
+ issuerInfo.getIssuer(), docHolder, SAML2Handler.HANDLER_TYPE.SP);
+ request.addOption( GeneralConstants.DECRYPTING_KEY, keypair.getPrivate() );
+
+ SAML2HandlerResponse response = new DefaultSAML2HandlerResponse();
+
+ session.setAttribute(GeneralConstants.PRINCIPAL_ID, new Principal()
+ {
+ public String getName()
+ {
+ return "Hi";
+ }});
+
+
+ handler.handleStatusResponseType(request, response);
+ }
+}
\ No newline at end of file
14 years, 10 months
Picketlink SVN: r752 - in idm/branches/2.0.0: assembly and 20 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-02-17 14:31:32 -0500 (Thu, 17 Feb 2011)
New Revision: 752
Added:
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/core/
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/core/factories/
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/core/factories/IdentityFactory.java
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityObjectRelationship.java
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStore.java
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStoreRepository.java
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStoreSession.java
idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/test/
idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/test/idm/
idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/test/idm/api/
idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/test/idm/api/model/
idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/test/idm/api/model/CorporateModelUnitTestCase.java
idm/branches/2.0.0/picketlink-idm-core/src/test/resources/configs/
idm/branches/2.0.0/picketlink-idm-core/src/test/resources/configs/memory-config.xml
Modified:
idm/branches/2.0.0/assembly/pom.xml
idm/branches/2.0.0/assembly/scripts/assembly-distro.xml
idm/branches/2.0.0/parent/pom.xml
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/managers/AbstractManager.java
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java
idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/types/SimpleIdentityObjectType.java
idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/idm/impl/SimpleIdentityObjectTypeImpl.java
idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/idm/impl/store/IdentityTypeEnum.java
idm/branches/2.0.0/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/model/IdentityObjectType.java
idm/branches/2.0.0/pom.xml
Log:
add memory based repo/store
Modified: idm/branches/2.0.0/assembly/pom.xml
===================================================================
--- idm/branches/2.0.0/assembly/pom.xml 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/assembly/pom.xml 2011-02-17 19:31:32 UTC (rev 752)
@@ -44,52 +44,8 @@
<artifactId>picketlink-idm-core</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.picketlink.idm</groupId>
- <artifactId>picketlink-idm-hibernate</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.picketlink.idm</groupId>
- <artifactId>picketlink-idm-ldap</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.picketlink.idm</groupId>
- <artifactId>picketlink-idm-cache</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.picketlink.idm.integration</groupId>
- <artifactId>picketlink-idm-jboss5</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.picketlink.idm.integration</groupId>
- <artifactId>picketlink-idm-jboss5-deployer</artifactId>
- <classifier>config</classifier>
- <type>zip</type>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.picketlink.idm.integration</groupId>
- <artifactId>picketlink-idm-jboss5-deployer</artifactId>
- <classifier>deployer</classifier>
- <type>zip</type>
- <version>${project.version}</version>
- </dependency>
<dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-commons-annotations</artifactId>
- <version>${hibernate-commons-annotations}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-tools</artifactId>
- <version>${hibernate-tools-version}</version>
- </dependency>
- <dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${hsqldb-version}</version>
@@ -100,27 +56,11 @@
<version>${apache.ant.version}</version>
</dependency>
- <!-- Database Drivers -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>${mysql.connector.version}</version>
- </dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>${postgresql.version}</version>
- </dependency>
- <dependency>
- <groupId>net.sourceforge.jtds</groupId>
- <artifactId>jtds</artifactId>
- <version>${jtds.version}</version>
- </dependency>
-
</dependencies>
<build>
<plugins>
+<!--
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
@@ -140,6 +80,8 @@
</execution>
</executions>
</plugin>
+
+ -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
Modified: idm/branches/2.0.0/assembly/scripts/assembly-distro.xml
===================================================================
--- idm/branches/2.0.0/assembly/scripts/assembly-distro.xml 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/assembly/scripts/assembly-distro.xml 2011-02-17 19:31:32 UTC (rev 752)
@@ -20,6 +20,8 @@
</dependencySet>
<!-- modules -->
+
+ <!--
<dependencySet>
<outputDirectory>modules</outputDirectory>
<useStrictFiltering>true</useStrictFiltering>
@@ -36,6 +38,9 @@
</includes>
<unpack>true</unpack>
</dependencySet>
+
+ -->
+
</dependencySets>
<fileSets>
@@ -92,6 +97,8 @@
<directory>../picketlink-idm-core/src/main/java</directory>
<outputDirectory>src</outputDirectory>
</fileSet>
+
+ <!--
<fileSet>
<directory>../picketlink-idm-hibernate/src/main/java</directory>
<outputDirectory>src</outputDirectory>
@@ -116,5 +123,7 @@
<directory>../integration/jboss5/src/main/resources</directory>
<outputDirectory>src</outputDirectory>
</fileSet>
+ -->
+
</fileSets>
</assembly>
Modified: idm/branches/2.0.0/parent/pom.xml
===================================================================
--- idm/branches/2.0.0/parent/pom.xml 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/parent/pom.xml 2011-02-17 19:31:32 UTC (rev 752)
@@ -515,7 +515,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <version>4.4</version>
<scope>test</scope>
</dependency>
</dependencies>
Added: idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/core/factories/IdentityFactory.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/core/factories/IdentityFactory.java (rev 0)
+++ idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/core/factories/IdentityFactory.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.idm.core.factories;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.picketlink.idm.api.cfg.IdentityConfiguration;
+import org.picketlink.idm.common.exception.IdentityConfigurationException;
+import org.picketlink.idm.common.exception.IdentityException;
+import org.picketlink.idm.impl.configuration.IdentityConfigurationImpl;
+import org.picketlink.idm.spi.model.IdentityObjectCredentialType;
+import org.picketlink.idm.spi.model.IdentityObjectRelationshipType;
+import org.picketlink.idm.spi.model.IdentityObjectType;
+import org.picketlink.idm.spi.store.FeaturesMetaData;
+import org.picketlink.idm.spi.store.IdentityObjectSearchCriteriaType;
+
+/**
+ * Static Factory to obtain the default factories
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 14, 2011
+ */
+public class IdentityFactory
+{
+ /**
+ * Given a configuration file, return {@link IdentityConfiguration}
+ * @param configFileName
+ * @return
+ * @throws IdentityConfigurationException
+ */
+ public static IdentityConfiguration createConfiguration( String configFileName ) throws IdentityConfigurationException
+ {
+ IdentityConfigurationImpl config = new IdentityConfigurationImpl();
+ return config.configure( configFileName );
+ }
+
+ public static FeaturesMetaData createEmptyFeaturesMetaData()
+ {
+ return new InternalFeaturesMetadata();
+ }
+
+ private static final class InternalFeaturesMetadata implements FeaturesMetaData
+ {
+ public boolean isSearchCriteriaTypeSupported(IdentityObjectType identityObjectType,
+ IdentityObjectSearchCriteriaType storeSearchConstraint)
+ {
+ return false;
+ }
+
+ public boolean isRoleNameSearchCriteriaTypeSupported(IdentityObjectSearchCriteriaType constraint)
+ {
+ return false;
+ }
+
+ public boolean isRelationshipTypeSupported(IdentityObjectType fromType, IdentityObjectType toType,
+ IdentityObjectRelationshipType relationshipType) throws IdentityException
+ {
+ return false;
+ }
+
+ public boolean isRelationshipPropertiesSupported()
+ {
+ return false;
+ }
+
+ public boolean isRelationshipNameAddRemoveSupported()
+ {
+ return false;
+ }
+
+ public boolean isNamedRelationshipsSupported()
+ {
+ return false;
+ }
+
+ public boolean isIdentityObjectTypeSupported(IdentityObjectType identityObjectType)
+ {
+ return false;
+ }
+
+ public boolean isIdentityObjectAddRemoveSupported(IdentityObjectType objectType)
+ {
+ return false;
+ }
+
+ public boolean isCredentialSupported(IdentityObjectType identityObjectType,
+ IdentityObjectCredentialType credentialType)
+ {
+ return false;
+ }
+
+ public Set<String> getSupportedRelationshipTypes()
+ {
+ return new HashSet<String>();
+ }
+
+ public Set<String> getSupportedIdentityObjectTypes()
+ {
+ return new HashSet<String>();
+ }
+ }
+}
\ No newline at end of file
Modified: idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/managers/AbstractManager.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/managers/AbstractManager.java 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/managers/AbstractManager.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -213,7 +213,7 @@
return getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
}
- protected IdentityObjectType getIdentityObjectType(String groupType)
+ protected IdentityObjectType getIdentityObjectType( String groupType)
{
return getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
}
Modified: idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/mapper/DirectIdentityObjectTypeMapperImpl.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -25,6 +25,7 @@
import java.io.Serializable;
import org.picketlink.idm.spi.model.IdentityObjectType;
+import org.picketlink.idm.spi.model.IdentityObjectType.TYPE;
import org.picketlink.idm.impl.types.SimpleIdentityObjectType;
import org.picketlink.idm.impl.api.session.mapper.IdentityObjectTypeMapper;
@@ -44,7 +45,9 @@
public IdentityObjectType getIdentityObjectType()
{
- return new SimpleIdentityObjectType(identityTypeName);
+ SimpleIdentityObjectType simple = new SimpleIdentityObjectType(identityTypeName);
+ simple.setType( TYPE.USER );
+ return simple;
}
public IdentityObjectType getIdentityObjectType(String groupType)
@@ -53,8 +56,10 @@
{
throw new IllegalArgumentException("groupType is null");
}
-
- return new SimpleIdentityObjectType(groupType);
+
+ SimpleIdentityObjectType simple = new SimpleIdentityObjectType(groupType);
+ simple.setType( TYPE.GROUP );
+ return simple;
}
public String getGroupType(IdentityObjectType identityObjectType)
Added: idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityObjectRelationship.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityObjectRelationship.java (rev 0)
+++ idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityObjectRelationship.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.idm.impl.store.memory;
+
+import org.picketlink.idm.spi.model.IdentityObject;
+import org.picketlink.idm.spi.model.IdentityObjectRelationship;
+import org.picketlink.idm.spi.model.IdentityObjectRelationshipType;
+
+/**
+ * A {@link IdentityObjectRelationship} for use in the
+ * {@link MemoryIdentityStore}
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 14, 2011
+ */
+public class MemoryIdentityObjectRelationship implements IdentityObjectRelationship
+{
+ private String name;
+ private IdentityObjectRelationshipType type;
+ private IdentityObject to;
+ private IdentityObject from;
+
+ public MemoryIdentityObjectRelationship( String name, IdentityObjectRelationshipType type,
+ IdentityObject from, IdentityObject to )
+ {
+ this.name = name;
+ this.type = type;
+ this.to = to;
+ this.from = from;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public IdentityObjectRelationshipType getType()
+ {
+ return type;
+ }
+
+ public IdentityObject getFromIdentityObject()
+ {
+ return from;
+ }
+
+ public IdentityObject getToIdentityObject()
+ {
+ return to;
+ }
+}
\ No newline at end of file
Added: idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStore.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStore.java (rev 0)
+++ idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStore.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -0,0 +1,529 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.idm.impl.store.memory;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.picketlink.idm.common.exception.IdentityException;
+import org.picketlink.idm.impl.types.SimpleIdentityObject;
+import org.picketlink.idm.spi.configuration.IdentityStoreConfigurationContext;
+import org.picketlink.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.picketlink.idm.spi.exception.OperationNotSupportedException;
+import org.picketlink.idm.spi.model.IdentityObject;
+import org.picketlink.idm.spi.model.IdentityObjectAttribute;
+import org.picketlink.idm.spi.model.IdentityObjectCredential;
+import org.picketlink.idm.spi.model.IdentityObjectCredentialType;
+import org.picketlink.idm.spi.model.IdentityObjectRelationship;
+import org.picketlink.idm.spi.model.IdentityObjectRelationshipType;
+import org.picketlink.idm.spi.model.IdentityObjectType;
+import org.picketlink.idm.spi.model.IdentityObjectType.TYPE;
+import org.picketlink.idm.spi.search.IdentityObjectSearchCriteria;
+import org.picketlink.idm.spi.store.FeaturesMetaData;
+import org.picketlink.idm.spi.store.IdentityObjectSearchCriteriaType;
+import org.picketlink.idm.spi.store.IdentityStore;
+import org.picketlink.idm.spi.store.IdentityStoreInvocationContext;
+import org.picketlink.idm.spi.store.IdentityStoreSession;
+
+/**
+ * An implementation of {@link IdentityStore} that resides in memory
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 14, 2011
+ */
+public class MemoryIdentityStore implements IdentityStore, Serializable
+{
+ private static final long serialVersionUID = 1L;
+ private String id;
+
+ protected Map<String,IdentityObject> users = new HashMap<String,IdentityObject>();
+
+ protected Map<String, IdentityObject> roles = new HashMap<String,IdentityObject>();
+ protected Map<String, IdentityObject> groups = new HashMap<String,IdentityObject>();
+
+ protected Map<String, Set<IdentityObjectAttribute>> attributes = new HashMap<String, Set<IdentityObjectAttribute>>();
+ /**
+ * General hashmap that is keyed by relationship name.
+ */
+ protected Map<String, List<IdentityObjectRelationship>> relationships = new HashMap<String, List<IdentityObjectRelationship>>();
+
+ protected Set<String> relationshipNames = new TreeSet<String>();
+
+ public MemoryIdentityStore( String id )
+ {
+ this.id = id;
+ }
+
+ public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext invocationContext,
+ IdentityObjectType identityType) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(
+ IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType)
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext invocationContext,
+ IdentityObject identity) throws IdentityException
+ {
+ Map<String, IdentityObjectAttribute> map = new HashMap<String, IdentityObjectAttribute>();
+
+ Set<IdentityObjectAttribute> attrs = attributes.get( identity.getName());
+ if( attrs != null )
+ {
+ for( IdentityObjectAttribute ioa: attrs )
+ {
+ map.put(ioa.getName(), ioa );
+ }
+ }
+ return map;
+ }
+
+ public IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext invocationContext,
+ IdentityObject identity, String name) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void updateAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity,
+ IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void addAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity,
+ IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+ Set<IdentityObjectAttribute> set = this.attributes.get( identity.getName() );
+ if( set == null)
+ {
+ set = new HashSet<IdentityObjectAttribute>();
+ this.attributes.put( identity.getName(), set );
+ }
+ set.addAll( Arrays.asList( attributes ));
+ }
+
+ public void removeAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity,
+ String[] attributeNames) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public IdentityObject findIdentityObjectByUniqueAttribute(IdentityStoreInvocationContext invocationCtx,
+ IdentityObjectType identityObjectType, IdentityObjectAttribute attribute) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public IdentityStoreSession createIdentityStoreSession() throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public IdentityStoreSession createIdentityStoreSession(Map<String, Object> sessionOptions) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void bootstrap(IdentityStoreConfigurationContext configurationContext) throws IdentityException
+ {
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public FeaturesMetaData getSupportedFeatures()
+ {
+ return new FeaturesMetaData()
+ {
+ public boolean isSearchCriteriaTypeSupported(IdentityObjectType identityObjectType,
+ IdentityObjectSearchCriteriaType storeSearchConstraint)
+ {
+ return true;
+ }
+
+ public boolean isRoleNameSearchCriteriaTypeSupported(IdentityObjectSearchCriteriaType constraint)
+ {
+ return true;
+ }
+
+ public boolean isRelationshipTypeSupported(IdentityObjectType fromType, IdentityObjectType toType,
+ IdentityObjectRelationshipType relationshipType) throws IdentityException
+ {
+ return true;
+ }
+
+ public boolean isRelationshipPropertiesSupported()
+ {
+ return true;
+ }
+
+ public boolean isRelationshipNameAddRemoveSupported()
+ {
+ return true;
+ }
+
+ public boolean isNamedRelationshipsSupported()
+ {
+ return true;
+ }
+
+ public boolean isIdentityObjectTypeSupported(IdentityObjectType identityObjectType)
+ {
+ return true;
+ }
+
+ public boolean isIdentityObjectAddRemoveSupported(IdentityObjectType objectType)
+ {
+ return true;
+ }
+
+ public boolean isCredentialSupported(IdentityObjectType identityObjectType,
+ IdentityObjectCredentialType credentialType)
+ {
+ return true;
+ }
+
+ public Set<String> getSupportedRelationshipTypes()
+ {
+ return null;
+ }
+
+ public Set<String> getSupportedIdentityObjectTypes()
+ {
+ return null;
+ }
+ };
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name,
+ IdentityObjectType identityObjectType) throws IdentityException
+ {
+ if( identityObjectType == null )
+ throw new IllegalArgumentException( "Identity Object Type is null" );
+
+ IdentityObject io = null;
+
+ String identityObjectTypeName = identityObjectType.getName();
+
+ TYPE type = identityObjectType.getType();
+
+ if( type == TYPE.GROUP )
+ {
+ io = groups.get(identityObjectTypeName);
+ if( io == null )
+ {
+ io = new SimpleIdentityObject( name, identityObjectType );
+ groups.put(name, io);
+ }
+ }
+ else if( type == TYPE.USER )
+ {
+ io = users.get(identityObjectTypeName);
+ if( io ==null)
+ {
+ io = new SimpleIdentityObject( name, identityObjectType );
+ users.put( name, io );
+ }
+ }
+ else
+ {
+ io = roles.get(identityObjectTypeName);
+ if( io == null )
+ {
+ io = new SimpleIdentityObject( name, identityObjectType );
+ roles.put(identityObjectTypeName, io);
+ }
+ }
+ /*if( identityObjectTypeName.equals( "ORGANIZATION" ) || identityObjectTypeName.equals( "DIVISION" )
+ || identityObjectTypeName.equals( "DEPARTMENT") || identityObjectTypeName.equals( "ORGANIZATION_UNIT")
+ || identityObjectTypeName.equals( "PROJECT" ) || identityObjectTypeName.equals( "PEOPLE" ))
+ {
+ io = generalBucket.get(name);
+
+ if( io == null )
+ {
+ io = new SimpleIdentityObject( name, identityObjectType );
+ generalBucket.put(name, io);
+ }
+ }
+ else if( identityObjectTypeName.equals( "USER" ))
+ {
+ io = users.get( name );
+ if( io == null )
+ {
+ io = new SimpleIdentityObject( name, identityObjectType );
+ users.put(name, io );
+ }
+ }
+ else
+ throw new RuntimeException( "Unknown type : " + identityObjectTypeName );*/
+ return io;
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name,
+ IdentityObjectType identityObjectType, Map<String, String[]> attributes) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void removeIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObject identity)
+ throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public int getIdentityObjectsCount(IdentityStoreInvocationContext invocationCtx, IdentityObjectType identityType)
+ throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationContext, String name,
+ IdentityObjectType identityObjectType) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationContext, String id)
+ throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx,
+ IdentityObjectType identityType, IdentityObjectSearchCriteria criteria) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent,
+ IdentityObjectSearchCriteria criteria) throws IdentityException
+ {
+ Collection<IdentityObject> result = new HashSet<IdentityObject>();
+
+ String relationshipName = relationshipType.getName();
+ List<IdentityObjectRelationship> rels = relationships.get(relationshipName);
+ if( rels != null )
+ {
+ for( IdentityObjectRelationship rel: rels )
+ {
+ String identityName = identity.getName();
+ IdentityObject from = rel.getFromIdentityObject();
+ IdentityObject to = rel.getToIdentityObject();
+
+ if( from.getName().equals(identityName) || to.getName().equals(identityName) )
+ {
+ result.add( from );
+ result.add( to);
+ }
+ }
+ }
+
+ /*TYPE type = identity.getIdentityType().getType();
+ if( type == TYPE.GROUP )
+ {
+ IdentityObject io = groups.get( identity.getName() );
+ System.out.println( io );
+
+ }
+ throw new RuntimeException( "NYI" );*/
+ return result;
+ }
+
+ public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType,
+ String relationshipName, boolean createNames) throws IdentityException
+ {
+ String relationshipTypeName = relationshipType.getName();
+
+ List<IdentityObjectRelationship> rels;
+
+ IdentityObjectRelationship ior = new MemoryIdentityObjectRelationship(relationshipName,
+ relationshipType, fromIdentity, toIdentity);
+
+ if( ! relationships.containsKey(relationshipTypeName) )
+ {
+ rels = new ArrayList<IdentityObjectRelationship>();
+ rels.add(ior);
+ relationships.put(relationshipTypeName, rels );
+ }
+ else
+ {
+ rels = relationships.get(relationshipTypeName);
+ rels.add(ior);
+ }
+ return ior;
+ }
+
+ public void removeRelationship(IdentityStoreInvocationContext invocationCxt, IdentityObject fromIdentity,
+ IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String relationshipName)
+ throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void removeRelationships(IdentityStoreInvocationContext invocationCtx, IdentityObject identity1,
+ IdentityObject identity2, boolean named) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType)
+ throws IdentityException
+ {
+ Set<IdentityObjectRelationship> set = new HashSet<IdentityObjectRelationship>();
+
+ String relationshipTypeName = relationshipType.getName();
+ List<IdentityObjectRelationship> rels = relationships.get(relationshipTypeName);
+ if( rels != null )
+ {
+ for( IdentityObjectRelationship ior : rels )
+ {
+ IdentityObject iroFrom = ior.getFromIdentityObject();
+ IdentityObject iroTo = ior.getToIdentityObject();
+ if( iroFrom.getName().equals( fromIdentity.getName() ) && iroTo.getName().equals( toIdentity.getName() ) )
+ set.add(ior);
+ }
+ }
+ return set;
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent, boolean named,
+ String name) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public String createRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException,
+ OperationNotSupportedException
+ {
+ relationshipNames.add(name);
+ return name;
+ }
+
+ public String removeRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException,
+ OperationNotSupportedException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Map<String, String> getRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name)
+ throws IdentityException, OperationNotSupportedException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void setRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name,
+ Map<String, String> properties) throws IdentityException, OperationNotSupportedException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void removeRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name, Set<String> properties)
+ throws IdentityException, OperationNotSupportedException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Map<String, String> getRelationshipProperties(IdentityStoreInvocationContext ctx,
+ IdentityObjectRelationship relationship) throws IdentityException, OperationNotSupportedException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void setRelationshipProperties(IdentityStoreInvocationContext ctx, IdentityObjectRelationship relationship,
+ Map<String, String> properties) throws IdentityException, OperationNotSupportedException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void removeRelationshipProperties(IdentityStoreInvocationContext ctx,
+ IdentityObjectRelationship relationship, Set<String> properties) throws IdentityException,
+ OperationNotSupportedException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObjectSearchCriteria criteria)
+ throws IdentityException, OperationNotSupportedException
+ {
+ return Collections.unmodifiableSet( relationshipNames );
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity,
+ IdentityObjectSearchCriteria criteria) throws IdentityException, OperationNotSupportedException
+ {
+ Set<String> result = new TreeSet<String>();
+
+ String identityName = identity.getName();
+
+ if( identityName == null )
+ throw new IllegalStateException( "Identity Name null" );
+
+ Set<String> keys = relationships.keySet();
+ for( String key : keys )
+ {
+ List<IdentityObjectRelationship> iors = relationships.get(key);
+ for( IdentityObjectRelationship ior: iors )
+ {
+ if( ior.getName() == null )
+ continue;
+
+ String fromID = ior.getFromIdentityObject().getName();
+ String toID = ior.getToIdentityObject().getName();
+
+ if( fromID.equals( identityName) || toID.equals( identityName ))
+ result.add(ior.getName());
+ }
+ }
+ return result;
+ }
+
+ public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject,
+ IdentityObjectCredential credential) throws IdentityException
+ {
+ return false;
+ }
+
+ public void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject,
+ IdentityObjectCredential credential) throws IdentityException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+}
\ No newline at end of file
Added: idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStoreRepository.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStoreRepository.java (rev 0)
+++ idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStoreRepository.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -0,0 +1,378 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.idm.impl.store.memory;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.picketlink.idm.common.exception.IdentityException;
+import org.picketlink.idm.core.factories.IdentityFactory;
+import org.picketlink.idm.spi.configuration.IdentityRepositoryConfigurationContext;
+import org.picketlink.idm.spi.configuration.IdentityStoreConfigurationContext;
+import org.picketlink.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.picketlink.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
+import org.picketlink.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
+import org.picketlink.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.picketlink.idm.spi.exception.OperationNotSupportedException;
+import org.picketlink.idm.spi.model.IdentityObject;
+import org.picketlink.idm.spi.model.IdentityObjectAttribute;
+import org.picketlink.idm.spi.model.IdentityObjectCredential;
+import org.picketlink.idm.spi.model.IdentityObjectRelationship;
+import org.picketlink.idm.spi.model.IdentityObjectRelationshipType;
+import org.picketlink.idm.spi.model.IdentityObjectType;
+import org.picketlink.idm.spi.repository.IdentityStoreRepository;
+import org.picketlink.idm.spi.search.IdentityObjectSearchCriteria;
+import org.picketlink.idm.spi.store.AttributeStore;
+import org.picketlink.idm.spi.store.FeaturesMetaData;
+import org.picketlink.idm.spi.store.IdentityObjectSearchCriteriaType;
+import org.picketlink.idm.spi.store.IdentityStore;
+import org.picketlink.idm.spi.store.IdentityStoreInvocationContext;
+import org.picketlink.idm.spi.store.IdentityStoreSession;
+
+/**
+ * A {@link IdentityStoreRepository} that resides in memory
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 14, 2011
+ */
+public class MemoryIdentityStoreRepository implements IdentityStoreRepository
+{
+ private static final long serialVersionUID = 1L;
+
+ protected String id = null;
+
+ protected IdentityStore store;
+
+ protected IdentityConfigurationMetaData md;
+
+ protected IdentityRepositoryConfigurationMetaData repoMD = null;
+
+ protected IdentityStoreConfigurationMetaData storeMD = null;
+
+ private static Set<IdentityObjectSearchCriteriaType> supportedIdentityObjectSearchCriteria =
+ new HashSet<IdentityObjectSearchCriteriaType>();
+
+ private static Set<String> supportedCredentialTypes = new HashSet<String>();
+
+ public static final String CREDENTIAL_TYPE_PASSWORD = "PASSWORD";
+
+ public static final String CREDENTIAL_TYPE_BINARY = "BINARY";
+
+ static {
+ // List all supported criteria classes
+
+ supportedIdentityObjectSearchCriteria.add(IdentityObjectSearchCriteriaType.ATTRIBUTE_FILTER);
+ supportedIdentityObjectSearchCriteria.add(IdentityObjectSearchCriteriaType.NAME_FILTER);
+ supportedIdentityObjectSearchCriteria.add(IdentityObjectSearchCriteriaType.PAGE);
+ supportedIdentityObjectSearchCriteria.add(IdentityObjectSearchCriteriaType.SORT);
+
+ // credential types supported by this impl
+ supportedCredentialTypes.add(CREDENTIAL_TYPE_PASSWORD);
+ supportedCredentialTypes.add(CREDENTIAL_TYPE_BINARY);
+
+ }
+
+
+ public MemoryIdentityStoreRepository( String id )
+ {
+ this.id = id;
+ store = new MemoryIdentityStore(id);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public FeaturesMetaData getSupportedFeatures()
+ {
+ return store.getSupportedFeatures();
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name,
+ IdentityObjectType identityObjectType) throws IdentityException
+ {
+ return store.createIdentityObject(invocationCtx, name, identityObjectType);
+ }
+
+ public IdentityObject createIdentityObject(IdentityStoreInvocationContext invocationCtx, String name,
+ IdentityObjectType identityObjectType, Map<String, String[]> attributes) throws IdentityException
+ {
+ return store.createIdentityObject(invocationCtx, name, identityObjectType, attributes );
+ }
+
+ public void removeIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObject identity)
+ throws IdentityException
+ {
+ store.removeIdentityObject(invocationCtx, identity);
+ }
+
+ public int getIdentityObjectsCount(IdentityStoreInvocationContext invocationCtx, IdentityObjectType identityType)
+ throws IdentityException
+ {
+ return store.getIdentityObjectsCount(invocationCtx, identityType);
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationContext, String name,
+ IdentityObjectType identityObjectType) throws IdentityException
+ {
+ return store.findIdentityObject(invocationContext, name, identityObjectType );
+ }
+
+ public IdentityObject findIdentityObject(IdentityStoreInvocationContext invocationContext, String id)
+ throws IdentityException
+ {
+ return store.findIdentityObject(invocationContext, id);
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCtx,
+ IdentityObjectType identityType, IdentityObjectSearchCriteria criteria) throws IdentityException
+ {
+ return store.findIdentityObject(invocationCtx, identityType, criteria);
+ }
+
+ public Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent,
+ IdentityObjectSearchCriteria criteria) throws IdentityException
+ {
+ return store.findIdentityObject(invocationCxt, identity, relationshipType, parent, criteria);
+ }
+
+ public IdentityObjectRelationship createRelationship(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType,
+ String relationshipName, boolean createNames) throws IdentityException
+ {
+ return store.createRelationship(invocationCxt, fromIdentity, toIdentity, relationshipType, relationshipName, createNames);
+ }
+
+ public void removeRelationship(IdentityStoreInvocationContext invocationCxt, IdentityObject fromIdentity,
+ IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType, String relationshipName)
+ throws IdentityException
+ {
+ store.removeRelationship(invocationCxt, fromIdentity, toIdentity, relationshipType, relationshipName);
+ }
+
+ public void removeRelationships(IdentityStoreInvocationContext invocationCtx, IdentityObject identity1,
+ IdentityObject identity2, boolean named) throws IdentityException
+ {
+ store.removeRelationships(invocationCtx, identity1, identity2, named);
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject fromIdentity, IdentityObject toIdentity, IdentityObjectRelationshipType relationshipType)
+ throws IdentityException
+ {
+ return store.resolveRelationships(invocationCxt, fromIdentity, toIdentity, relationshipType);
+ }
+
+ public Set<IdentityObjectRelationship> resolveRelationships(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity, IdentityObjectRelationshipType relationshipType, boolean parent, boolean named,
+ String name) throws IdentityException
+ {
+ return store.resolveRelationships(invocationCxt, identity, relationshipType, parent, named, name );
+ }
+
+ public String createRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException,
+ OperationNotSupportedException
+ {
+ return store.createRelationshipName(ctx, name);
+ }
+
+ public String removeRelationshipName(IdentityStoreInvocationContext ctx, String name) throws IdentityException,
+ OperationNotSupportedException
+ {
+ return store.removeRelationshipName(ctx, name);
+ }
+
+ public Map<String, String> getRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name)
+ throws IdentityException, OperationNotSupportedException
+ {
+ return store.getRelationshipNameProperties(ctx, name);
+ }
+
+ public void setRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name,
+ Map<String, String> properties) throws IdentityException, OperationNotSupportedException
+ {
+ store.setRelationshipNameProperties(ctx, name, properties);
+ }
+
+ public void removeRelationshipNameProperties(IdentityStoreInvocationContext ctx, String name, Set<String> properties)
+ throws IdentityException, OperationNotSupportedException
+ {
+ store.removeRelationshipNameProperties(ctx, name, properties);
+ }
+
+ public Map<String, String> getRelationshipProperties(IdentityStoreInvocationContext ctx,
+ IdentityObjectRelationship relationship) throws IdentityException, OperationNotSupportedException
+ {
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void setRelationshipProperties(IdentityStoreInvocationContext ctx, IdentityObjectRelationship relationship,
+ Map<String, String> properties) throws IdentityException, OperationNotSupportedException
+ {
+
+
+ }
+
+ public void removeRelationshipProperties(IdentityStoreInvocationContext ctx,
+ IdentityObjectRelationship relationship, Set<String> properties) throws IdentityException,
+ OperationNotSupportedException
+ {
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObjectSearchCriteria criteria)
+ throws IdentityException, OperationNotSupportedException
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx, IdentityObject identity,
+ IdentityObjectSearchCriteria criteria) throws IdentityException, OperationNotSupportedException
+ {
+ return store.getRelationshipNames(ctx, identity, criteria);
+ }
+
+ public boolean validateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject,
+ IdentityObjectCredential credential) throws IdentityException
+ {
+ return false;
+ }
+
+ public void updateCredential(IdentityStoreInvocationContext ctx, IdentityObject identityObject,
+ IdentityObjectCredential credential) throws IdentityException
+ {
+ }
+
+ public Set<String> getSupportedAttributeNames(IdentityStoreInvocationContext invocationContext,
+ IdentityObjectType identityType) throws IdentityException
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Map<String, IdentityObjectAttributeMetaData> getAttributesMetaData(
+ IdentityStoreInvocationContext invocationContext, IdentityObjectType identityType)
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Map<String, IdentityObjectAttribute> getAttributes(IdentityStoreInvocationContext invocationContext,
+ IdentityObject identity) throws IdentityException
+ {
+ return store.getAttributes( invocationContext, identity);
+ }
+
+ public IdentityObjectAttribute getAttribute(IdentityStoreInvocationContext invocationContext,
+ IdentityObject identity, String name) throws IdentityException
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+
+ public void updateAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity,
+ IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+ }
+
+ public void addAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity,
+ IdentityObjectAttribute[] attributes) throws IdentityException
+ {
+ store.addAttributes( invocationCtx, identity, attributes);
+ }
+
+ public void removeAttributes(IdentityStoreInvocationContext invocationCtx, IdentityObject identity,
+ String[] attributeNames) throws IdentityException
+ {
+ store.removeAttributes(invocationCtx, identity, attributeNames);
+ }
+
+ public IdentityObject findIdentityObjectByUniqueAttribute(IdentityStoreInvocationContext invocationCtx,
+ IdentityObjectType identityObjectType, IdentityObjectAttribute attribute) throws IdentityException
+ {
+ return store.findIdentityObjectByUniqueAttribute(invocationCtx, identityObjectType, attribute);
+ }
+
+ public IdentityStoreSession createIdentityStoreSession() throws IdentityException
+ {
+ return store.createIdentityStoreSession();
+ }
+
+ public IdentityStoreSession createIdentityStoreSession(Map<String, Object> sessionOptions) throws IdentityException
+ {
+ return new MemoryIdentityStoreSession();
+ }
+
+ public void bootstrap(IdentityRepositoryConfigurationContext configurationContext,
+ Map<String, IdentityStore> bootstrappedIdentityStores, Map<String, AttributeStore> bootstrappedAttributeStores)
+ throws IdentityException
+ {
+ repoMD = configurationContext.getRepositoryConfigurationMetaData();
+ storeMD = configurationContext.getConfigurationMetaData().getIdentityStores().get(0);
+ }
+
+
+ public void bootstrap(IdentityStoreConfigurationContext configurationContext) throws IdentityException
+ {
+ storeMD = configurationContext.getStoreConfigurationMetaData();
+ }
+
+ public Set<IdentityStore> getConfiguredIdentityStores()
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Set<AttributeStore> getConfiguredAttributeStores()
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Map<String, IdentityStore> getIdentityStoreMappings()
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+
+ public Map<String, AttributeStore> getAttributeStoreMappings()
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+
+ public IdentityStore getIdentityStore(IdentityObjectType identityObjectType) throws IdentityException
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+
+ public AttributeStore getAttributeStore(IdentityObjectType identityObjectType) throws IdentityException
+ {
+
+ throw new RuntimeException( "NYI" );
+ }
+}
\ No newline at end of file
Added: idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStoreSession.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStoreSession.java (rev 0)
+++ idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/store/memory/MemoryIdentityStoreSession.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.idm.impl.store.memory;
+
+import org.picketlink.idm.api.IdentitySession;
+import org.picketlink.idm.common.exception.IdentityException;
+import org.picketlink.idm.spi.store.IdentityStoreSession;
+
+/**
+ * A {@link IdentitySession} for memory
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 14, 2011
+ */
+public class MemoryIdentityStoreSession implements IdentityStoreSession
+{
+
+ public Object getSessionContext() throws IdentityException
+ {
+ return null;
+ }
+
+ public void close() throws IdentityException
+ {
+ }
+
+ public void save() throws IdentityException
+ {
+ }
+
+ public void clear() throws IdentityException
+ {
+ }
+
+ public boolean isOpen()
+ {
+
+ return false;
+ }
+
+ public boolean isTransactionSupported()
+ {
+
+ return false;
+ }
+
+ public void startTransaction()
+ {
+
+
+ }
+
+ public void commitTransaction()
+ {
+
+
+ }
+
+ public void rollbackTransaction()
+ {
+
+
+ }
+
+ public boolean isTransactionActive()
+ {
+
+ return false;
+ }
+}
\ No newline at end of file
Modified: idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/types/SimpleIdentityObjectType.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/types/SimpleIdentityObjectType.java 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/types/SimpleIdentityObjectType.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -34,6 +34,8 @@
{
private String name;
+ private TYPE t = TYPE.GROUP;
+
private SimpleIdentityObjectType()
{
}
@@ -88,4 +90,14 @@
{
return name != null ? name.hashCode() : 0;
}
-}
+
+ public void setType( TYPE T)
+ {
+ t = T;
+ }
+
+ public TYPE getType()
+ {
+ return t;
+ }
+}
\ No newline at end of file
Modified: idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/idm/impl/SimpleIdentityObjectTypeImpl.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/idm/impl/SimpleIdentityObjectTypeImpl.java 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/idm/impl/SimpleIdentityObjectTypeImpl.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -23,6 +23,7 @@
package org.picketlink.idm.impl;
import org.picketlink.idm.spi.model.IdentityObjectType;
+import org.picketlink.idm.spi.model.IdentityObjectType.TYPE;
import java.io.Serializable;
@@ -33,6 +34,8 @@
public class SimpleIdentityObjectTypeImpl implements IdentityObjectType, Serializable
{
String name;
+
+ private TYPE t = TYPE.GROUP;
public SimpleIdentityObjectTypeImpl(String name)
{
@@ -66,6 +69,17 @@
return true;
}
+ public void setType( TYPE T)
+ {
+ t = T;
+ }
+
+
+ public TYPE getType()
+ {
+ return t;
+ }
+
@Override
public int hashCode()
{
Modified: idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/idm/impl/store/IdentityTypeEnum.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/idm/impl/store/IdentityTypeEnum.java 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/idm/impl/store/IdentityTypeEnum.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -42,4 +42,9 @@
return this.name();
}
+ public TYPE getType()
+ {
+ return null;
+ }
+
}
\ No newline at end of file
Added: idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/test/idm/api/model/CorporateModelUnitTestCase.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/test/idm/api/model/CorporateModelUnitTestCase.java (rev 0)
+++ idm/branches/2.0.0/picketlink-idm-core/src/test/java/org/picketlink/test/idm/api/model/CorporateModelUnitTestCase.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -0,0 +1,454 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.test.idm.api.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.junit.Test;
+import org.picketlink.idm.api.Attribute;
+import org.picketlink.idm.api.AttributesManager;
+import org.picketlink.idm.api.Group;
+import org.picketlink.idm.api.IdentitySession;
+import org.picketlink.idm.api.IdentitySessionFactory;
+import org.picketlink.idm.api.PersistenceManager;
+import org.picketlink.idm.api.RelationshipManager;
+import org.picketlink.idm.api.RoleManager;
+import org.picketlink.idm.api.RoleType;
+import org.picketlink.idm.api.User;
+import org.picketlink.idm.api.cfg.IdentityConfiguration;
+import org.picketlink.idm.common.p3p.P3PConstants;
+import org.picketlink.idm.core.factories.IdentityFactory;
+import org.picketlink.idm.impl.api.SimpleAttribute;
+
+/**
+ * Unit test a typical corporate model
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 14, 2011
+ */
+public class CorporateModelUnitTestCase
+{
+ private String sampleOrganizationRealmName = "realm://memory";
+
+ String configFileName = "configs/memory-config.xml";
+
+
+ @Test
+ public void testModel() throws Exception
+ {
+ IdentityConfiguration config = IdentityFactory.createConfiguration( configFileName );
+ assertNotNull( config );
+ IdentitySessionFactory sessionFactory = config.buildIdentitySessionFactory();
+ assertNotNull( sessionFactory );
+
+ // GroupType
+
+ String ORGANIZATION = "ORGANIZATION";
+ String ORGANIZATION_UNIT = "ORGANIZATION_UNIT";
+ String DIVISION = "DIVISION";
+ String DEPARTMENT = "DEPARTMENT";
+ String PROJECT = "PROJECT";
+ String PEOPLE = "PEOPLE";
+
+
+ IdentitySession session = sessionFactory .createIdentitySession( sampleOrganizationRealmName );
+
+
+ begin();
+
+ // Organization structure
+
+ PersistenceManager persistenceManager = session.getPersistenceManager();
+ Group rhOrg = persistenceManager.createGroup("RedHat", ORGANIZATION);
+
+ Group jbossDivision = persistenceManager.createGroup("JBoss", DIVISION);
+ Group rhelDivision = persistenceManager.createGroup("RHEL", DIVISION);
+
+ RelationshipManager relationshipManager = session.getRelationshipManager();
+ relationshipManager.associateGroups(rhOrg, jbossDivision);
+ relationshipManager.associateGroups(rhOrg, rhelDivision);
+
+ Group itDepartment = persistenceManager.createGroup("IT", DEPARTMENT);
+ Group hrDepartment = persistenceManager.createGroup("HR", DEPARTMENT);
+
+ relationshipManager.associateGroups(jbossDivision, itDepartment);
+ relationshipManager.associateGroups(jbossDivision, hrDepartment);
+
+ Group rndDepartment = persistenceManager.createGroup("RnD", DEPARTMENT);
+
+ relationshipManager.associateGroups(itDepartment, rndDepartment);
+
+ Group projectsOU = persistenceManager.createGroup("Projects", ORGANIZATION_UNIT);
+ Group commonFrameworksOU = persistenceManager.createGroup("Common Frameworks", ORGANIZATION_UNIT);
+
+ relationshipManager.associateGroups(rndDepartment, projectsOU);
+
+ // Projects
+
+ Group portalProject = persistenceManager.createGroup("Portal", PROJECT);
+ Group soaProject = persistenceManager.createGroup("SOA", PROJECT);
+ Group jbpmProject = persistenceManager.createGroup("jBPM", PROJECT);
+ Group seamProject = persistenceManager.createGroup("Seam", PROJECT);
+ Group asProject = persistenceManager.createGroup("AS", PROJECT);
+ Group securityProject = persistenceManager.createGroup("Security", PROJECT);
+
+ relationshipManager.associateGroups(projectsOU, portalProject);
+ relationshipManager.associateGroups(projectsOU, soaProject);
+ relationshipManager.associateGroups(projectsOU, jbpmProject);
+ relationshipManager.associateGroups(projectsOU, asProject);
+ relationshipManager.associateGroups(projectsOU, seamProject);
+
+ // Check...
+ assertTrue(relationshipManager.isAssociated(projectsOU, portalProject));
+ assertTrue(relationshipManager.isAssociated(projectsOU, soaProject));
+ assertTrue(relationshipManager.isAssociated(projectsOU, jbpmProject));
+ assertTrue(relationshipManager.isAssociated(projectsOU, asProject));
+ assertTrue(relationshipManager.isAssociated(projectsOU, seamProject));
+
+ // Portal is part of common frameworks
+ relationshipManager.associateGroups(commonFrameworksOU, portalProject);
+
+ // People
+
+ Group employeesGroup = persistenceManager.createGroup("Employees", PEOPLE);
+
+ // Management
+
+ User theuteUser = persistenceManager.createUser("theute");
+ User mlittleUser = persistenceManager.createUser("mlittle");
+ User bgeorgesUser = persistenceManager.createUser("bgeorges");
+ User asaldhanaUser = persistenceManager.createUser("asaldhana");
+ User janderseUser = persistenceManager.createUser("janderse");
+
+ // Portal Team
+
+ User bdawidowUser = persistenceManager.createUser("bdawidow");
+ User claprunUser = persistenceManager.createUser("claprun");
+ User whalesUser = persistenceManager.createUser("whales");
+ User sshahUser = persistenceManager.createUser("sshah");
+ User mwringeUser = persistenceManager.createUser("mwringe");
+
+ // Store as employees
+
+ relationshipManager.associateUser(employeesGroup, theuteUser);
+ relationshipManager.associateUser(employeesGroup, mlittleUser);
+ relationshipManager.associateUser(employeesGroup, asaldhanaUser);
+ relationshipManager.associateUser(employeesGroup, bdawidowUser);
+ relationshipManager.associateUser(employeesGroup, claprunUser);
+ relationshipManager.associateUser(employeesGroup, whalesUser);
+ relationshipManager.associateUser(employeesGroup, sshahUser);
+ relationshipManager.associateUser(employeesGroup, mwringeUser);
+
+ // Portal team for management purposes
+
+ Group portalTeamGroup = persistenceManager.createGroup("Portal Team", PEOPLE);
+ relationshipManager.associateUser(portalTeamGroup, bdawidowUser);
+ relationshipManager.associateUser(portalTeamGroup, claprunUser);
+ relationshipManager.associateUser(portalTeamGroup, whalesUser);
+ relationshipManager.associateUser(portalTeamGroup, sshahUser);
+ relationshipManager.associateUser(portalTeamGroup, mwringeUser);
+
+ // Portal team is under common frameworks
+
+ relationshipManager.associateGroups(commonFrameworksOU, portalTeamGroup);
+
+ // Role Types
+
+ RoleManager roleManager = session.getRoleManager();
+ RoleType developerRT = roleManager.createRoleType("Developer");
+ RoleType managerRT = roleManager.createRoleType("Manager");
+ RoleType leadDeveloperRT = roleManager.createRoleType("Lead Developer");
+ RoleType productManagerRT = roleManager.createRoleType("Product Manager");
+
+ // Assign roles
+
+ // Common frameworks manager
+
+ roleManager.createRole(managerRT, bgeorgesUser, commonFrameworksOU);
+
+ // Portal developers
+
+ roleManager.createRole(developerRT, theuteUser, portalProject);
+ roleManager.createRole(developerRT, bdawidowUser, portalProject);
+ roleManager.createRole(developerRT, claprunUser, portalProject);
+ roleManager.createRole(developerRT, whalesUser, portalProject);
+ roleManager.createRole(developerRT, sshahUser, portalProject);
+ roleManager.createRole(developerRT, mwringeUser, portalProject);
+
+ // Portal management
+ roleManager.createRole(leadDeveloperRT, theuteUser, portalProject);
+ roleManager.createRole(managerRT, theuteUser, portalTeamGroup);
+ roleManager.createRole(productManagerRT, janderseUser, portalProject);
+
+ // SOA
+
+ roleManager.createRole(developerRT, mlittleUser, portalProject);
+ roleManager.createRole(productManagerRT, mlittleUser, portalProject);
+
+ // AS & Security
+
+ roleManager.createRole(developerRT, asaldhanaUser, asProject);
+ roleManager.createRole(developerRT, asaldhanaUser, securityProject);
+ roleManager.createRole(leadDeveloperRT, asaldhanaUser, securityProject);
+
+
+ // Check what RoleTypes has user theute
+ Collection<RoleType> roleTypes = roleManager.findUserRoleTypes(theuteUser);
+ assertEquals(3, roleTypes.size());
+ assertTrue(roleTypes.contains(developerRT));
+ assertTrue(roleTypes.contains(leadDeveloperRT));
+ assertTrue(roleTypes.contains(managerRT));
+ assertFalse(roleTypes.contains(productManagerRT));
+
+ assertTrue(roleManager.hasRole(theuteUser, portalProject, developerRT));
+ assertTrue(roleManager.hasRole(theuteUser, portalProject, leadDeveloperRT));
+ assertTrue(roleManager.hasRole(theuteUser, portalTeamGroup, managerRT));
+
+ // Check where anil is Lead Developer and where Developer
+
+ roleTypes = roleManager.findUserRoleTypes(asaldhanaUser);
+ assertEquals(2, roleTypes.size());
+ assertTrue(roleTypes.contains(developerRT));
+ assertTrue(roleTypes.contains(leadDeveloperRT));
+
+ roleTypes = roleManager.findRoleTypes(asaldhanaUser, securityProject);
+ assertEquals(2, roleTypes.size());
+ assertTrue(roleTypes.contains(leadDeveloperRT));
+
+ roleTypes = roleManager.findRoleTypes(asaldhanaUser, asProject);
+ assertEquals(1, roleTypes.size());
+ assertTrue(roleTypes.contains(developerRT));
+
+ // and simpler...
+ assertTrue(roleManager.hasRole(asaldhanaUser, asProject, developerRT));
+
+ // Assert relationships
+
+ Collection<User> identities = relationshipManager.findAssociatedUsers(portalTeamGroup, false);
+ assertEquals(5, identities.size());
+ assertTrue(identities.contains(claprunUser));
+ assertTrue(identities.contains(mwringeUser));
+ assertTrue(identities.contains(sshahUser));
+ assertTrue(identities.contains(whalesUser));
+ assertTrue(identities.contains(bdawidowUser));
+
+ Collection<Group> groups = relationshipManager.findAssociatedGroups(rndDepartment, PROJECT, true, false);
+ assertEquals(0, groups.size());
+
+ // Check to which group Anil belongs
+ groups = relationshipManager.findAssociatedGroups(asaldhanaUser, PEOPLE);
+ assertEquals(1, groups.size());
+ assertTrue(groups.contains(employeesGroup));
+
+ // Now check sshah
+ groups = relationshipManager.findAssociatedGroups(sshahUser, PEOPLE);
+ assertEquals(2, groups.size());
+ assertTrue(groups.contains(employeesGroup));
+ assertTrue(groups.contains(portalTeamGroup));
+
+
+
+
+ // User attributes
+ Attribute[] userInfo = new Attribute[]
+ {
+ new SimpleAttribute(P3PConstants.INFO_USER_NAME_GIVEN, new String[]{"Boleslaw"}),
+ new SimpleAttribute(P3PConstants.INFO_USER_NAME_FAMILY, new String[]{"Dawidowicz"}),
+ //new SimpleAttribute("picture", new byte[][]{picture}),
+ new SimpleAttribute("email", new String[]{"bd(a)example.com"})
+ };
+
+ AttributesManager attributesManager = session.getAttributesManager();
+ attributesManager.addAttributes(bdawidowUser, userInfo);
+
+ Map<String, Attribute> attributes = attributesManager.getAttributes(bdawidowUser);
+ assertEquals(3, attributes.keySet().size());
+ assertEquals("Dawidowicz", (attributes.get(P3PConstants.INFO_USER_NAME_FAMILY)).getValue());
+
+ /* // Check readOnly attribute change
+ userInfo = new Attribute[]
+ {
+ new SimpleAttribute("description", new String[]{"some description"})
+ };
+
+ attributesManager.addAttributes(bdawidowUser, userInfo);
+ attributesManager.updateAttributes(bdawidowUser, userInfo);
+
+ attributes = attributesManager.getAttributes(bdawidowUser);
+ assertEquals(3, attributes.keySet().size());
+ assertEquals(null, (attributes.get("description")));
+
+ // Generate random binary data for binary attribute
+ Random random = new Random();
+
+ // Check that binary attribute picture is mapped
+ AttributeDescription attributeDescription = attributesManager.getAttributeDescription(bdawidowUser, "picture");
+
+ if (attributeDescription != null && attributeDescription.getType().equals("binary"))
+ {
+
+ // 900 kilobytes
+ byte[] picture = new byte[921600];
+ random.nextBytes(picture);
+
+ userInfo = new Attribute[]
+ {
+ new SimpleAttribute("picture", new byte[][]{picture}),
+ };
+
+
+ attributesManager.addAttributes(bdawidowUser, userInfo);
+
+ attributes = attributesManager.getAttributes(bdawidowUser);
+ assertEquals(4, attributes.keySet().size());
+ assertEquals("Dawidowicz", (attributes.get(P3PConstants.INFO_USER_NAME_FAMILY)).getValue());
+ assertTrue(Arrays.equals((byte[])attributes.get("picture").getValue(), picture));
+
+ // Update
+
+ // 500 kilobytes
+ picture = new byte[50600];
+ random.nextBytes(picture);
+
+ userInfo = new Attribute[]
+ {
+ new SimpleAttribute("picture", new byte[][]{picture}),
+ };
+
+
+ attributesManager.updateAttributes(bdawidowUser, userInfo);
+
+ attributes = attributesManager.getAttributes(bdawidowUser);
+ assertEquals(4, attributes.keySet().size());
+ assertTrue(Arrays.equals((byte[])attributes.get("picture").getValue(), picture));
+ }
+
+
+ // Find user by email
+ assertNull(attributesManager.findUserByUniqueAttribute("email", "toto"));
+ User user = attributesManager.findUserByUniqueAttribute("email", "bd(a)example.com");
+ assertEquals(bdawidowUser, user);
+
+
+ // If email is configured as unique it should not be possible to set same value for different user
+
+ attributeDescription = attributesManager.getAttributeDescription(bdawidowUser, "email");
+
+ if (attributeDescription != null && attributeDescription.isUnique())
+ {
+
+
+ // check if same unique email can be used for other user
+ try
+ {
+ userInfo = new Attribute[]
+ {
+ new SimpleAttribute("email", new String[]{"bd(a)example.com"})
+ };
+
+ attributesManager.addAttributes(theuteUser, userInfo);
+ fail();
+ }
+ catch (IdentityException e)
+ {
+ // expected
+ }
+ }
+
+
+
+ // Credential
+ User anotherOne = bdawidowUser; //session.getPersistenceManager().createUser("blah1");
+
+ if (attributesManager.isCredentialTypeSupported(PasswordCredential.TYPE))
+ {
+
+ // There is a known issue that on some LDAP servers (MSAD at least) old password can
+ // still be used for some time together with the new one. Because of this testsuite cannot
+ // assert previously set password values
+
+ // #1
+ attributesManager.updatePassword(anotherOne, "Password2000");
+ assertTrue(attributesManager.validatePassword(anotherOne, "Password2000"));
+ assertFalse(attributesManager.validatePassword(anotherOne, "Password2001"));
+ assertFalse(attributesManager.validatePassword(anotherOne, "Password2002"));
+
+ // #1
+ attributesManager.updatePassword(anotherOne, "Password2002");
+ assertTrue(attributesManager.validatePassword(anotherOne, "Password2002"));
+ assertFalse(attributesManager.validatePassword(anotherOne, "Password2001"));
+ assertFalse(attributesManager.validatePassword(anotherOne, "wirdPasswordValue"));
+// assertFalse(session.getAttributesManager().validatePassword(anotherOne, "Password2000"));
+ assertFalse(attributesManager.validatePassword(anotherOne, "Password2003"));
+
+
+ // #1
+ attributesManager.updatePassword(anotherOne, "Password2003");
+ assertTrue(attributesManager.validatePassword(anotherOne, "Password2003"));
+// assertFalse(session.getAttributesManager().validatePassword(anotherOne, "Password2000"));
+// assertFalse(session.getAttributesManager().validatePassword(anotherOne, "Password2002"));
+ assertFalse(attributesManager.validatePassword(anotherOne, "Password2005"));
+ assertFalse(attributesManager.validatePassword(anotherOne, "Password2006"));
+ assertFalse(attributesManager.validatePassword(anotherOne, "Password2007"));
+
+
+ // #2
+ Credential password = new PasswordCredential("SuperPassword2345");
+ attributesManager.updateCredential(anotherOne, password);
+ assertTrue(attributesManager.validateCredentials(anotherOne, new Credential[]{password}));
+
+ // #3
+ }
+
+ if (attributesManager.isCredentialTypeSupported(BinaryCredential.TYPE))
+ {
+ // 500 kilobytes
+ byte[] cert = new byte[512000];
+ random.nextBytes(cert);
+ Credential binaryCredential = new BinaryCredential(cert);
+ attributesManager.updateCredential(anotherOne, binaryCredential);
+ assertTrue(attributesManager.validateCredentials(anotherOne, new Credential[]{binaryCredential}));
+ }
+
+ persistenceManager.createUser("!(06_13_07 Sche) !(0");
+
+ User u1 = persistenceManager.findUser("!(06_13_07 Sche) !(0");
+
+ assertNotNull(u1);*/
+
+
+ commit();
+ }
+
+
+ public void begin()
+ {}
+
+ public void commit()
+ {}
+}
\ No newline at end of file
Added: idm/branches/2.0.0/picketlink-idm-core/src/test/resources/configs/memory-config.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/src/test/resources/configs/memory-config.xml (rev 0)
+++ idm/branches/2.0.0/picketlink-idm-core/src/test/resources/configs/memory-config.xml 2011-02-17 19:31:32 UTC (rev 752)
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jboss-identity xmlns="urn:picketlink:idm:config:v1_0_0_ga"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:picketlink:idm:config:v1_0_0_ga identity-config.xsd">
+ <realms>
+ <realm>
+ <id>realm://memory</id>
+ <repository-id-ref>Memory based repo</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ </realms>
+ <repositories>
+ <repository>
+ <id>Memory based repo</id>
+ <class>org.picketlink.idm.impl.store.memory.MemoryIdentityStoreRepository</class>
+ <external-config/>
+ <default-identity-store-id>MemoryStore</default-identity-store-id>
+ <default-attribute-store-id>MemoryStore</default-attribute-store-id>
+ <!--<identity-store-mappings>-->
+ <!--<identity-store-mapping>-->
+ <!--<identity-store-id>HibernateTestStore</identity-store-id>-->
+ <!--<identity-object-types/>-->
+ <!--<options/>-->
+ <!--</identity-store-mapping>-->
+ <!--</identity-store-mappings>-->
+ </repository>
+ </repositories>
+ <stores>
+ <attribute-stores/>
+ <identity-stores>
+ <identity-store>
+ <id>MemoryStore</id>
+ <class>org.picketlink.idm.impl.store.memory.MemoryIdentityStore</class>
+ <external-config/>
+ <supported-relationship-types>
+ <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+ <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
+ </supported-relationship-types>
+ <supported-identity-object-types>
+ <identity-object-type>
+ <name>USER</name>
+ <relationships/>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ <credential-type>BINARY</credential-type>
+ </credentials>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>GROUP</name>
+ <relationships/>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ORGANIZATION</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ROLE</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>GROUP</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ <identity-object-type>
+ <name>ROLE</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ </supported-identity-object-types>
+ <options>
+ <!--<option>-->
+ <!--<name>hibernateConfiguration</name>-->
+ <!--<value>hibernate-jboss-identity.cfg.xml</value>-->
+ <!--</option>-->
+ <option>
+ <name>hibernateSessionFactoryJNDIName</name>
+ <value>java:/jbossidentity/HibernateStoreSessionFactory</value>
+ </option>
+ <option>
+ <name>populateRelationshipTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>populateIdentityObjectTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>isRealmAware</name>
+ <value>false</value>
+ </option>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ </options>
+ </identity-store>
+ </identity-stores>
+ </stores>
+</jboss-identity>
\ No newline at end of file
Modified: idm/branches/2.0.0/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/model/IdentityObjectType.java
===================================================================
--- idm/branches/2.0.0/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/model/IdentityObjectType.java 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/model/IdentityObjectType.java 2011-02-17 19:31:32 UTC (rev 752)
@@ -33,5 +33,8 @@
* @return
*/
String getName();
-
+
+ public enum TYPE { USER,ROLE,GROUP};
+
+ TYPE getType();
}
\ No newline at end of file
Modified: idm/branches/2.0.0/pom.xml
===================================================================
--- idm/branches/2.0.0/pom.xml 2011-02-11 21:05:14 UTC (rev 751)
+++ idm/branches/2.0.0/pom.xml 2011-02-17 19:31:32 UTC (rev 752)
@@ -33,15 +33,11 @@
<module>picketlink-idm-spi</module>
<module>picketlink-idm-api</module>
<module>picketlink-idm-core</module>
- <module>picketlink-idm-hibernate</module>
- <module>picketlink-idm-ldap</module>
- <module>picketlink-idm-cache</module>
- <module>picketlink-idm-auth</module>
- <module>picketlink-idm-testsuite</module>
- <module>integration</module>
<module>picketlink-idm-docs</module>
</modules>
</profile>
+
+ <!--
<profile>
<id>all</id>
<modules>
@@ -125,6 +121,8 @@
</build>
</profile>
+ -->
+
</profiles>
<reporting>
14 years, 10 months
Picketlink SVN: r751 - in federation/trunk: picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants and 4 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-02-11 16:05:14 -0500 (Fri, 11 Feb 2011)
New Revision: 751
Added:
federation/trunk/picketlink-fed-core/src/test/resources/saml2/metadata/sp-entitydescOrgContact.xml
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/metadata/SAMLEntityDescriptorParser.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLMetadataWriter.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataParsingUnitTestCase.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java
federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/metadata/EntityDescriptorType.java
Log:
add contact person parsing/writing for entity descriptor
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/metadata/SAMLEntityDescriptorParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/metadata/SAMLEntityDescriptorParser.java 2011-02-11 20:17:13 UTC (rev 750)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/metadata/SAMLEntityDescriptorParser.java 2011-02-11 21:05:14 UTC (rev 751)
@@ -41,6 +41,8 @@
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AttributeAuthorityDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AttributeConsumingServiceType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.ContactType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.ContactTypeType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EndpointType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType.EDTChoiceType;
@@ -136,6 +138,10 @@
entityDescriptorType.setOrganization(organization);
}
+ else if( JBossSAMLConstants.CONTACT_PERSON.get().equals( localPart ))
+ {
+ entityDescriptorType.addContactPerson( parseContactPerson(xmlEventReader));
+ }
else
throw new RuntimeException( "Unknown " + localPart );
}
@@ -478,7 +484,61 @@
}
return org;
}
+
+ private ContactType parseContactPerson( XMLEventReader xmlEventReader ) throws ParsingException
+ {
+ StartElement startElement = StaxParserUtil.getNextStartElement( xmlEventReader );
+ StaxParserUtil.validate(startElement, JBossSAMLConstants.CONTACT_PERSON.get() );
+ Attribute attr = startElement.getAttributeByName( new QName( JBossSAMLConstants.CONTACT_TYPE.get() ));
+ if( attr == null )
+ throw new ParsingException( "attribute contactType required" );
+ ContactType contactType = new ContactType(ContactTypeType.fromValue( StaxParserUtil.getAttributeValue(attr)));
+
+ while( xmlEventReader.hasNext() )
+ {
+ XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
+ if( xmlEvent instanceof EndElement )
+ {
+ EndElement end = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( end , JBossSAMLConstants.CONTACT_PERSON.get() );
+ break;
+ }
+
+ startElement = (StartElement) xmlEvent;
+ String localPart = startElement.getName().getLocalPart();
+
+ if( JBossSAMLConstants.COMPANY.get().equals( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ contactType.setCompany( StaxParserUtil.getElementText(xmlEventReader) );
+ }
+ else if( JBossSAMLConstants.GIVEN_NAME.get().equals( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ contactType.setGivenName( StaxParserUtil.getElementText(xmlEventReader) );
+ }
+ else if( JBossSAMLConstants.SURNAME.get().equals( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ contactType.setSurName( StaxParserUtil.getElementText(xmlEventReader) );
+ }
+ else if( JBossSAMLConstants.EMAIL_ADDRESS.get().equals( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ contactType.addEmailAddress( StaxParserUtil.getElementText(xmlEventReader) );
+ }
+ else if( JBossSAMLConstants.TELEPHONE_NUMBER.get().equals( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ contactType.addTelephone( StaxParserUtil.getElementText(xmlEventReader) );
+ }
+ else
+ throw new RuntimeException( "Unknown " + localPart );
+ }
+ return contactType;
+ }
+
private LocalizedNameType getLocalizedName(XMLEventReader xmlEventReader, StartElement startElement)
throws ParsingException
{
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java 2011-02-11 20:17:13 UTC (rev 750)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java 2011-02-11 21:05:14 UTC (rev 751)
@@ -54,9 +54,13 @@
AUTHN_REQUESTS_SIGNED( "AuthnRequestsSigned" ),
BINDING( "Binding" ),
CACHE_DURATION( "cacheDuration" ),
+ COMPANY( "Company" ),
CONDITIONS( "Conditions" ),
CONSENT( "Consent" ),
+ CONTACT_PERSON( "ContactPerson" ),
+ CONTACT_TYPE( "contactType" ),
DESTINATION( "Destination" ),
+ EMAIL_ADDRESS( "EmailAddress" ),
ENCODING( "Encoding" ),
ENCRYPTED_ASSERTION( "EncryptedAssertion" ),
ENTITY_ID( "entityID" ),
@@ -64,6 +68,7 @@
ENTITIES_DESCRIPTOR( "EntitiesDescriptor" ),
FORMAT( "Format" ),
FRIENDLY_NAME( "FriendlyName" ),
+ GIVEN_NAME( "GivenName" ),
ID( "ID" ),
IDP_SSO_DESCRIPTOR( "IDPSSODescriptor" ),
INDEX( "index" ),
@@ -125,6 +130,8 @@
SUBJECT( "Subject" ),
SUBJECT_CONFIRMATION( "SubjectConfirmation" ),
SUBJECT_CONFIRMATION_DATA( "SubjectConfirmationData" ),
+ SURNAME( "SurName" ),
+ TELEPHONE_NUMBER( "TelephoneNumber" ),
TYPE( "type" ),
USE( "use" ),
VALUE( "Value" ),
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLMetadataWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLMetadataWriter.java 2011-02-11 20:17:13 UTC (rev 750)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLMetadataWriter.java 2011-02-11 21:05:14 UTC (rev 751)
@@ -38,6 +38,8 @@
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AttributeAuthorityDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AttributeConsumingServiceType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AuthnAuthorityDescriptorType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.ContactType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.ContactTypeType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EndpointType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType.EDTChoiceType;
@@ -116,6 +118,12 @@
OrganizationType organization = entityDescriptor.getOrganization();
writeOrganization(organization);
+ List<ContactType> contactPersons = entityDescriptor.getContactPerson();
+ for( ContactType contact : contactPersons )
+ {
+ write( contact );
+ }
+
StaxUtil.writeEndElement(writer);
StaxUtil.flush(writer);
}
@@ -359,6 +367,63 @@
StaxUtil.flush(writer);
}
+ public void write( ContactType contact ) throws ProcessingException
+ {
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.CONTACT_PERSON.get(),
+ METADATA_NSURI.get());
+
+ ContactTypeType attribs = contact.getContactType();
+ StaxUtil.writeAttribute(writer, JBossSAMLConstants.CONTACT_TYPE.get(), attribs.value() );
+
+ //Write the name
+ String company = contact.getCompany();
+ if( company != null )
+ {
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.COMPANY.get(),
+ METADATA_NSURI.get());
+ StaxUtil.writeCharacters(writer, company);
+ StaxUtil.writeEndElement(writer);
+ }
+ String givenName = contact.getGivenName();
+ if( givenName != null )
+ {
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.GIVEN_NAME.get(),
+ METADATA_NSURI.get());
+ StaxUtil.writeCharacters(writer, givenName );
+ StaxUtil.writeEndElement(writer);
+ }
+
+ String surName = contact.getSurName();
+ if( surName != null )
+ {
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.SURNAME.get(),
+ METADATA_NSURI.get());
+ StaxUtil.writeCharacters(writer, surName );
+ StaxUtil.writeEndElement(writer);
+ }
+
+ List<String> emailAddresses = contact.getEmailAddress();
+ for( String email: emailAddresses )
+ {
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.EMAIL_ADDRESS.get(),
+ METADATA_NSURI.get());
+ StaxUtil.writeCharacters(writer, email );
+ StaxUtil.writeEndElement(writer);
+ }
+
+ List<String> tels = contact.getTelephoneNumber();
+ for( String telephone: tels )
+ {
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.TELEPHONE_NUMBER.get(),
+ METADATA_NSURI.get());
+ StaxUtil.writeCharacters(writer, telephone );
+ StaxUtil.writeEndElement(writer);
+ }
+
+ StaxUtil.writeEndElement(writer);
+ StaxUtil.flush(writer);
+ }
+
public void writeKeyDescriptor( KeyDescriptorType keyDescriptor ) throws ProcessingException
{
StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.KEY_DESCRIPTOR.get(),
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataParsingUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataParsingUnitTestCase.java 2011-02-11 20:17:13 UTC (rev 750)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataParsingUnitTestCase.java 2011-02-11 21:05:14 UTC (rev 751)
@@ -21,20 +21,25 @@
*/
package org.picketlink.test.identity.federation.core.saml.v2.metadata;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.security.cert.X509Certificate;
+import java.util.List;
import junit.framework.Assert;
import org.junit.Test;
import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
import org.picketlink.identity.federation.core.saml.v2.util.SAMLMetadataUtil;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.ContactType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntitiesDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.IDPSSODescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.KeyDescriptorType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.OrganizationType;
/**
* Unit test the SAML metadata parsing
@@ -62,4 +67,27 @@
Assert.assertNotNull(cert);
Assert.assertEquals( "CN=test, OU=OpenSSO, O=Sun, L=Santa Clara, ST=California, C=US", cert.getIssuerDN().getName() );
}
+
+ @Test
+ public void parseOrganizationAndContactPerson() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream is =
+ tcl.getResourceAsStream("saml2/metadata/sp-entitydescOrgContact.xml");
+ assertNotNull("Inputstream not null", is);
+
+ SAMLParser parser = new SAMLParser();
+ EntityDescriptorType entity = (EntityDescriptorType) parser.parse(is);
+ assertNotNull( entity );
+ OrganizationType org = entity.getOrganization();
+ assertNotNull( org );
+
+ List<ContactType> contactPersons = entity.getContactPerson();
+ assertNotNull( contactPersons );
+ assertTrue( contactPersons.size() == 1 );
+
+ assertEquals( "technical", contactPersons.get(0).getContactType().value() );
+ assertEquals( "SAML SP Support", contactPersons.get(0).getSurName() );
+ assertEquals( "mailto:saml-support@sp.example.com", contactPersons.get(0).getEmailAddress().get(0) );
+ }
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java 2011-02-11 20:17:13 UTC (rev 750)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java 2011-02-11 21:05:14 UTC (rev 751)
@@ -62,4 +62,26 @@
System.out.println( new String( baos.toByteArray() ));
}
+
+ @Test
+ public void testWriteEntityDescWithContactPerson() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ InputStream is =
+ tcl.getResourceAsStream("saml2/metadata/sp-entitydescOrgContact.xml");
+ assertNotNull("Inputstream not null", is);
+
+ SAMLParser parser = new SAMLParser();
+ EntityDescriptorType entity = (EntityDescriptorType) parser.parse(is);
+ assertNotNull( entity );
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ XMLStreamWriter writer = StaxUtil.getXMLStreamWriter( baos );
+
+ //write it back
+ SAMLMetadataWriter mdWriter = new SAMLMetadataWriter( writer );
+ mdWriter.writeEntityDescriptor( entity ) ;
+
+ System.out.println( new String( baos.toByteArray() ));
+ }
}
\ No newline at end of file
Added: federation/trunk/picketlink-fed-core/src/test/resources/saml2/metadata/sp-entitydescOrgContact.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/resources/saml2/metadata/sp-entitydescOrgContact.xml (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/resources/saml2/metadata/sp-entitydescOrgContact.xml 2011-02-11 21:05:14 UTC (rev 751)
@@ -0,0 +1,21 @@
+<md:EntityDescriptor
+ xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
+ xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
+ xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
+ entityID="https://sp.example.com/SAML2">
+ <md:Organization>
+ <md:OrganizationName xml:lang="en">
+ SAML Service Provider
+ </md:OrganizationName>
+ <md:OrganizationDisplayName xml:lang="en">
+ SAML Service Provider @ Some Location
+ </md:OrganizationDisplayName>
+ <md:OrganizationURL xml:lang="en">
+ http://www.sp.example.com/
+ </md:OrganizationURL>
+ </md:Organization>
+ <md:ContactPerson contactType="technical">
+ <md:SurName>SAML SP Support</md:SurName>
+ <md:EmailAddress>mailto:saml-support@sp.example.com</md:EmailAddress>
+ </md:ContactPerson>
+ </md:EntityDescriptor>
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/metadata/EntityDescriptorType.java
===================================================================
--- federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/metadata/EntityDescriptorType.java 2011-02-11 20:17:13 UTC (rev 750)
+++ federation/trunk/picketlink-fed-model/src/main/java/org/picketlink/identity/federation/newmodel/saml/v2/metadata/EntityDescriptorType.java 2011-02-11 21:05:14 UTC (rev 751)
@@ -267,6 +267,20 @@
}
/**
+ * Add a {@link ContactType} contact person
+ * @param ct
+ */
+ public void addContactPerson( ContactType ct )
+ {
+ contactPerson.add(ct);
+ }
+
+ public void removeContactPerson( ContactType ct )
+ {
+ contactPerson.remove(ct);
+ }
+
+ /**
* Gets the value of the contactPerson property.
* <p>
* Objects of the following type(s) are allowed in the list
14 years, 10 months
Picketlink SVN: r750 - federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-02-11 15:17:13 -0500 (Fri, 11 Feb 2011)
New Revision: 750
Modified:
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
Log:
PLFED-135: update the subject confirmation expiry
Modified: federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
===================================================================
--- federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2011-02-11 20:08:03 UTC (rev 749)
+++ federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2011-02-11 20:17:13 UTC (rev 750)
@@ -198,6 +198,9 @@
sts.issueToken( samlProtocolContext );
assertionType = samlProtocolContext.getIssuedAssertion();
+
+ //Update the subjectConfirmationData expiry based on the assertion
+ subjectConfirmationData.setNotOnOrAfter( assertionType.getConditions().getNotOnOrAfter() );
ResponseType responseType = createResponseType(ID, issuerInfo, assertionType);
14 years, 10 months
Picketlink SVN: r749 - in federation/trunk/picketlink-fed-core/src: main/java/org/picketlink/identity/federation/core/parsers/util and 5 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-02-11 15:08:03 -0500 (Fri, 11 Feb 2011)
New Revision: 749
Added:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/metadata/SAMLEntityDescriptorParser.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/v2/constants/JBossSAMLConstants.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/XMLTimeUtil.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/BaseWriter.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLMetadataWriter.java
federation/trunk/picketlink-fed-core/src/test/resources/saml2/metadata/sp-entitydescriptor.xml
Log:
some more metadata parsing and writing
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/metadata/SAMLEntityDescriptorParser.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/metadata/SAMLEntityDescriptorParser.java 2011-02-10 17:03:12 UTC (rev 748)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/saml/metadata/SAMLEntityDescriptorParser.java 2011-02-11 20:08:03 UTC (rev 749)
@@ -36,9 +36,11 @@
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.v2.constants.JBossSAMLConstants;
-import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
+import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
+import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AttributeAuthorityDescriptorType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AttributeConsumingServiceType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EndpointType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType.EDTChoiceType;
@@ -50,6 +52,8 @@
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.LocalizedNameType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.LocalizedURIType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.OrganizationType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.RequestedAttributeType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.SPSSODescriptorType;
import org.w3c.dom.Element;
/**
@@ -66,10 +70,29 @@
StartElement startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
StaxParserUtil.validate(startElement, EDT );
- Attribute entityID = startElement.getAttributeByName( new QName( "entityID" ));
+ Attribute entityID = startElement.getAttributeByName( new QName( JBossSAMLConstants.ENTITY_ID.get() ));
String entityIDValue = StaxParserUtil.getAttributeValue(entityID);
EntityDescriptorType entityDescriptorType = new EntityDescriptorType( entityIDValue );
+ Attribute validUntil = startElement.getAttributeByName( new QName( JBossSAMLConstants.VALID_UNTIL.get() ));
+ if( validUntil != null )
+ {
+ String validUntilValue = StaxParserUtil.getAttributeValue(validUntil);
+ entityDescriptorType.setValidUntil( XMLTimeUtil.parse(validUntilValue));
+ }
+
+ Attribute id = startElement.getAttributeByName( new QName( JBossSAMLConstants.ID.get() ));
+ if( id != null )
+ {
+ entityDescriptorType.setID( StaxParserUtil.getAttributeValue(id));
+ }
+
+ Attribute cacheDuration = startElement.getAttributeByName( new QName( JBossSAMLConstants.CACHE_DURATION.get() ));
+ if( cacheDuration != null )
+ {
+ entityDescriptorType.setCacheDuration( XMLTimeUtil.parseAsDuration( StaxParserUtil.getAttributeValue( cacheDuration )) );
+ }
+
//Get the Child Elements
while( xmlEventReader.hasNext() )
{
@@ -91,6 +114,14 @@
EDTChoiceType edtChoice = EDTChoiceType.oneValue( edtDescChoice );
entityDescriptorType.addChoiceType(edtChoice);
}
+ else if( JBossSAMLConstants.SP_SSO_DESCRIPTOR.get().equals( localPart ))
+ {
+ SPSSODescriptorType spSSO = parseSPSSODescriptor(xmlEventReader);
+
+ EDTDescriptorChoiceType edtDescChoice = new EDTDescriptorChoiceType( spSSO );
+ EDTChoiceType edtChoice = EDTChoiceType.oneValue( edtDescChoice );
+ entityDescriptorType.addChoiceType(edtChoice);
+ }
else if( JBossSAMLConstants.ATTRIBUTE_AUTHORITY_DESCRIPTOR.get().equals( localPart ))
{
AttributeAuthorityDescriptorType attrAuthority = parseAttributeAuthorityDescriptor( xmlEventReader );
@@ -120,6 +151,99 @@
&& localPart.equals( JBossSAMLConstants.ENTITY_DESCRIPTOR.get() );
}
+
+ private SPSSODescriptorType parseSPSSODescriptor( XMLEventReader xmlEventReader ) throws ParsingException
+ {
+ StartElement startElement = StaxParserUtil.getNextStartElement( xmlEventReader );
+ StaxParserUtil.validate(startElement, JBossSAMLConstants.SP_SSO_DESCRIPTOR.get() );
+
+ List<String> protocolEnum = SAMLParserUtil.parseProtocolEnumeration(startElement);
+ SPSSODescriptorType spSSODescriptor = new SPSSODescriptorType( protocolEnum );
+
+ Attribute wantAssertionsSigned = startElement.getAttributeByName( new QName( JBossSAMLConstants.WANT_ASSERTIONS_SIGNED.get() ) );
+ if( wantAssertionsSigned != null )
+ {
+ spSSODescriptor.setWantAssertionsSigned( Boolean.parseBoolean( StaxParserUtil.getAttributeValue( wantAssertionsSigned )));
+ }
+ Attribute wantAuthnSigned = startElement.getAttributeByName( new QName( JBossSAMLConstants.AUTHN_REQUESTS_SIGNED.get() ) );
+ if( wantAuthnSigned != null )
+ {
+ spSSODescriptor.setAuthnRequestsSigned( Boolean.parseBoolean( StaxParserUtil.getAttributeValue( wantAuthnSigned )));
+ }
+
+ while( xmlEventReader.hasNext() )
+ {
+ XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
+ if( xmlEvent instanceof EndElement )
+ {
+ EndElement end = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( end , JBossSAMLConstants.SP_SSO_DESCRIPTOR.get() );
+ break;
+ }
+
+ startElement = (StartElement) xmlEvent;
+ String localPart = startElement.getName().getLocalPart();
+
+ if( JBossSAMLConstants.ARTIFACT_RESOLUTION_SERVICE.get().equals( localPart ))
+ {
+ IndexedEndpointType endpoint = parseArtifactResolutionService(xmlEventReader, startElement);
+ spSSODescriptor.addArtifactResolutionService(endpoint);
+ }
+ else if( JBossSAMLConstants.ASSERTION_CONSUMER_SERVICE.get().equals( localPart ))
+ {
+ IndexedEndpointType endpoint = parseAssertionConsumerService( xmlEventReader, startElement);
+ spSSODescriptor.addAssertionConsumerService( endpoint );
+ }
+ else if( JBossSAMLConstants.ATTRIBUTE_CONSUMING_SERVICE.get().equals( localPart ))
+ {
+ AttributeConsumingServiceType attributeConsumer = parseAttributeConsumingService(xmlEventReader, startElement);
+ spSSODescriptor.addAttributeConsumerService(attributeConsumer);
+ }
+ else if( JBossSAMLConstants.SINGLE_LOGOUT_SERVICE.get().equals( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ EndpointType endpoint = getEndpointType(startElement);
+
+ EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( endElement, JBossSAMLConstants.SINGLE_LOGOUT_SERVICE.get() );
+
+ spSSODescriptor.addSingleLogoutService( endpoint );
+ }
+ else if( JBossSAMLConstants.MANAGE_NAMEID_SERVICE.get().equals( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ EndpointType endpoint = getEndpointType(startElement);
+
+ EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( endElement, JBossSAMLConstants.MANAGE_NAMEID_SERVICE.get() );
+
+ spSSODescriptor.addManageNameIDService( endpoint );
+ }
+ else if (JBossSAMLConstants.NAMEID_FORMAT.get().equalsIgnoreCase( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ spSSODescriptor.addNameIDFormat( StaxParserUtil.getElementText(xmlEventReader) );
+ }
+ else if (JBossSAMLConstants.KEY_DESCRIPTOR.get().equalsIgnoreCase( localPart ))
+ {
+ KeyDescriptorType keyDescriptor = new KeyDescriptorType();
+ String use = StaxParserUtil.getAttributeValue(startElement, "use" );
+ if( use != null )
+ keyDescriptor.setUse( KeyTypes.fromValue(use) );
+
+ Element key = StaxParserUtil.getDOMElement(xmlEventReader);
+ keyDescriptor.setKeyInfo(key);
+ spSSODescriptor.addKeyDescriptor(keyDescriptor);
+ }
+ else
+ throw new RuntimeException( "Unknown " + localPart );
+ }
+ return spSSODescriptor;
+ }
+
+
+
+
private IDPSSODescriptorType parseIDPSSODescriptor( XMLEventReader xmlEventReader ) throws ParsingException
{
StartElement startElement = StaxParserUtil.getNextStartElement( xmlEventReader );
@@ -149,29 +273,7 @@
if( JBossSAMLConstants.ARTIFACT_RESOLUTION_SERVICE.get().equals( localPart ))
{
- startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
- Attribute bindingAttr = startElement.getAttributeByName( new QName( JBossSAMLConstants.BINDING.get() ) );
- String binding = StaxParserUtil.getAttributeValue(bindingAttr);
-
- Attribute locationAttr = startElement.getAttributeByName( new QName( JBossSAMLConstants.LOCATION.get() ) );
- String location = StaxParserUtil.getAttributeValue( locationAttr );
-
- IndexedEndpointType endpoint = new IndexedEndpointType( URI.create( binding ),
- URI.create( location ));
- Attribute isDefault = startElement.getAttributeByName( new QName( JBossSAMLConstants.ISDEFAULT.get() ));
- if( isDefault != null )
- {
- endpoint.setIsDefault( Boolean.parseBoolean( StaxParserUtil.getAttributeValue( isDefault )));
- }
- Attribute index = startElement.getAttributeByName( new QName( JBossSAMLConstants.INDEX.get() ));
- if( index != null )
- {
- endpoint.setIndex( Integer.parseInt( StaxParserUtil.getAttributeValue( index )));
- }
-
- EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
- StaxParserUtil.validate( endElement, JBossSAMLConstants.ARTIFACT_RESOLUTION_SERVICE.get() );
-
+ IndexedEndpointType endpoint = parseArtifactResolutionService(xmlEventReader, startElement);
idpSSODescriptor.addArtifactResolutionService(endpoint);
}
else if( JBossSAMLConstants.ASSERTION_ID_REQUEST_SERVICE.get().equals( localPart ))
@@ -386,4 +488,116 @@
localName.setValue( StaxParserUtil.getElementText(xmlEventReader));
return localName;
}
+
+ private IndexedEndpointType parseAssertionConsumerService( XMLEventReader xmlEventReader, StartElement startElement ) throws ParsingException
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ IndexedEndpointType endpoint = parseIndexedEndpoint(xmlEventReader, startElement);
+
+ EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( endElement, JBossSAMLConstants.ASSERTION_CONSUMER_SERVICE.get() );
+
+ return endpoint;
+ }
+
+ private IndexedEndpointType parseArtifactResolutionService( XMLEventReader xmlEventReader, StartElement startElement ) throws ParsingException
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ IndexedEndpointType endpoint = parseIndexedEndpoint(xmlEventReader, startElement);
+
+ EndElement endElement = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( endElement, JBossSAMLConstants.ARTIFACT_RESOLUTION_SERVICE.get() );
+
+ return endpoint;
+ }
+
+ private IndexedEndpointType parseIndexedEndpoint( XMLEventReader xmlEventReader, StartElement startElement )
+ {
+ Attribute bindingAttr = startElement.getAttributeByName( new QName( JBossSAMLConstants.BINDING.get() ) );
+ String binding = StaxParserUtil.getAttributeValue(bindingAttr);
+
+ Attribute locationAttr = startElement.getAttributeByName( new QName( JBossSAMLConstants.LOCATION.get() ) );
+ String location = StaxParserUtil.getAttributeValue( locationAttr );
+
+ IndexedEndpointType endpoint = new IndexedEndpointType( URI.create( binding ),
+ URI.create( location ));
+ Attribute isDefault = startElement.getAttributeByName( new QName( JBossSAMLConstants.ISDEFAULT.get() ));
+ if( isDefault != null )
+ {
+ endpoint.setIsDefault( Boolean.parseBoolean( StaxParserUtil.getAttributeValue( isDefault )));
+ }
+ Attribute index = startElement.getAttributeByName( new QName( JBossSAMLConstants.INDEX.get() ));
+ if( index != null )
+ {
+ endpoint.setIndex( Integer.parseInt( StaxParserUtil.getAttributeValue( index )));
+ }
+ return endpoint;
+ }
+
+ private AttributeConsumingServiceType parseAttributeConsumingService( XMLEventReader xmlEventReader, StartElement startElement ) throws ParsingException
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+
+ Attribute indexAttr = startElement.getAttributeByName( new QName( JBossSAMLConstants.INDEX.get() ) );
+ if( indexAttr == null )
+ throw new ParsingException( "attribute index required" );
+
+ AttributeConsumingServiceType attributeConsumer = new AttributeConsumingServiceType( Integer.parseInt( StaxParserUtil.getAttributeValue(indexAttr)));
+ while( xmlEventReader.hasNext() )
+ {
+ XMLEvent xmlEvent = StaxParserUtil.peek(xmlEventReader);
+ if( xmlEvent instanceof EndElement )
+ {
+ EndElement end = StaxParserUtil.getNextEndElement(xmlEventReader);
+ StaxParserUtil.validate( end , JBossSAMLConstants.ATTRIBUTE_CONSUMING_SERVICE.get() );
+ break;
+ }
+
+ startElement = (StartElement) xmlEvent;
+ String localPart = startElement.getName().getLocalPart();
+
+ if( JBossSAMLConstants.SERVICE_NAME.get().equals( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ LocalizedNameType localName = getLocalizedName(xmlEventReader, startElement);
+ attributeConsumer.addServiceName(localName);
+ }
+ else if( JBossSAMLConstants.SERVICE_DESCRIPTION.get().equals( localPart ))
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ LocalizedNameType localName = getLocalizedName(xmlEventReader, startElement);
+ attributeConsumer.addServiceDescription(localName);
+ }
+ else if( JBossSAMLConstants.REQUESTED_ATTRIBUTE.get().equals( localPart ))
+ {
+ RequestedAttributeType attType = parseRequestedAttributeType(xmlEventReader, startElement);
+ attributeConsumer.addRequestedAttribute(attType);
+ }
+ else
+ throw new RuntimeException( "Unknown " + localPart );
+ }
+
+ return attributeConsumer;
+ }
+
+ private RequestedAttributeType parseRequestedAttributeType( XMLEventReader xmlEventReader, StartElement startElement ) throws ParsingException
+ {
+ startElement = StaxParserUtil.getNextStartElement(xmlEventReader);
+ StaxParserUtil.validate( startElement, JBossSAMLConstants.REQUESTED_ATTRIBUTE.get() );
+ RequestedAttributeType attributeType = null;
+
+ Attribute name = startElement.getAttributeByName( new QName( JBossSAMLConstants.NAME.get() ));
+ if( name == null )
+ throw new RuntimeException( "Required attribute Name in Attribute" );
+ attributeType = new RequestedAttributeType( StaxParserUtil.getAttributeValue( name ));
+
+ Attribute isRequired = startElement.getAttributeByName( new QName( JBossSAMLConstants.IS_REQUIRED.get() ));
+ if( isRequired != null )
+ {
+ attributeType.setIsRequired( Boolean.parseBoolean( StaxParserUtil.getAttributeValue(isRequired) ));
+ }
+
+ SAMLParserUtil.parseAttributeType(xmlEventReader, startElement, JBossSAMLConstants.REQUESTED_ATTRIBUTE.get(), attributeType);
+ return attributeType;
+ }
}
\ No newline at end of file
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-02-10 17:03:12 UTC (rev 748)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/SAMLParserUtil.java 2011-02-11 20:08:03 UTC (rev 749)
@@ -107,8 +107,11 @@
if( name == null )
throw new RuntimeException( "Required attribute Name in Attribute" );
attributeType = new AttributeType( StaxParserUtil.getAttributeValue( name ));
+
+ parseAttributeType(xmlEventReader, startElement, JBossSAMLConstants.ATTRIBUTE.get(), attributeType);
+
- //Look for X500 Encoding
+ /*//Look for X500 Encoding
QName x500EncodingName = new QName( JBossSAMLURIConstants.X500_NSURI.get(),
JBossSAMLConstants.ENCODING.get(), JBossSAMLURIConstants.X500_PREFIX.get() );
Attribute x500EncodingAttr = startElement.getAttributeByName( x500EncodingName );
@@ -150,12 +153,64 @@
attributeType.addAttributeValue( attributeValue );
}
else throw new RuntimeException( "Unknown tag:" + tag );
- }
+ }*/
return attributeType;
}
/**
+ * Parse an {@code AttributeType}
+ * @param xmlEventReader
+ * @throws ParsingException
+ */
+ public static void parseAttributeType( XMLEventReader xmlEventReader,
+ StartElement startElement, String rootTag, AttributeType attributeType ) throws ParsingException
+ {
+ //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, 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.addAttributeValue( attributeValue );
+ }
+ else throw new RuntimeException( "Unknown tag:" + tag );
+ }
+ }
+
+ /**
* Parse Attribute value
* @param xmlEventReader
* @return
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java 2011-02-10 17:03:12 UTC (rev 748)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/constants/JBossSAMLConstants.java 2011-02-11 20:08:03 UTC (rev 749)
@@ -32,10 +32,12 @@
ALLOW_CREATE( "AllowCreate" ),
ARTIFACT_RESOLUTION_SERVICE( "ArtifactResolutionService" ),
ASSERTION( "Assertion" ),
+ ASSERTION_CONSUMER_SERVICE( "AssertionConsumerService" ),
ASSERTION_CONSUMER_SERVICE_URL( "AssertionConsumerServiceURL" ),
ASSERTION_ID_REQUEST_SERVICE( "AssertionIDRequestService" ),
ATTRIBUTE( "Attribute" ),
ATTRIBUTE_AUTHORITY_DESCRIPTOR( "AttributeAuthorityDescriptor" ),
+ ATTRIBUTE_CONSUMING_SERVICE( "AttributeConsumingService" ),
ATTRIBUTE_SERVICE( "AttributeService" ),
ATTRIBUTE_STATEMENT( "AttributeStatement" ),
ATTRIBUTE_VALUE( "AttributeValue" ),
@@ -49,7 +51,9 @@
AUTHN_INSTANT( "AuthnInstant" ),
AUTHN_REQUEST( "AuthnRequest" ),
AUTHN_STATEMENT( "AuthnStatement" ),
+ AUTHN_REQUESTS_SIGNED( "AuthnRequestsSigned" ),
BINDING( "Binding" ),
+ CACHE_DURATION( "cacheDuration" ),
CONDITIONS( "Conditions" ),
CONSENT( "Consent" ),
DESTINATION( "Destination" ),
@@ -66,6 +70,7 @@
INPUT_CONTEXT_ONLY( "InputContextOnly" ),
IN_RESPONSE_TO( "InResponseTo" ),
ISDEFAULT( "isDefault" ),
+ IS_REQUIRED( "isRequired" ),
ISSUE_INSTANT( "IssueInstant" ),
ISSUER( "Issuer" ),
KEY_DESCRIPTOR( "KeyDescriptor" ),
@@ -95,13 +100,17 @@
REQUESTED_AUTHN_CONTEXT( "RequestedAuthnContext" ),
RECIPIENT( "Recipient" ),
REQUEST( "Request" ),
+ REQUESTED_ATTRIBUTE( "RequestedAttribute" ),
REQUEST_ABSTRACT( "RequestAbstract" ),
RESPONSE( "Response" ),
RESPONSE_LOCATION( "ResponseLocation" ),
RETURN_CONTEXT( "ReturnContext" ),
SESSION_INDEX( "SessionIndex" ),
+ SERVICE_NAME( "ServiceName" ),
+ SERVICE_DESCRIPTION( "ServiceDescription" ),
SP_PROVIDED_ID( "SPProvidedID" ),
SP_NAME_QUALIFIER( "SPNameQualifier" ),
+ SP_SSO_DESCRIPTOR( "SPSSODescriptor" ),
SIGNATURE( "Signature" ),
SIGNATURE_SHA1_WITH_DSA("http://www.w3.org/2000/09/xmldsig#dsa-sha1"),
SIGNATURE_SHA1_WITH_RSA("http://www.w3.org/2000/09/xmldsig#rsa-sha1"),
@@ -117,10 +126,13 @@
SUBJECT_CONFIRMATION( "SubjectConfirmation" ),
SUBJECT_CONFIRMATION_DATA( "SubjectConfirmationData" ),
TYPE( "type" ),
+ USE( "use" ),
VALUE( "Value" ),
+ VALID_UNTIL( "validUntil" ),
VERSION( "Version" ),
VERSION_2_0("2.0"),
WANT_AUTHN_REQUESTS_SIGNED( "WantAuthnRequestsSigned" ),
+ WANT_ASSERTIONS_SIGNED( "WantAssertionsSigned" ),
XACML_AUTHZ_DECISION_QUERY( "XACMLAuthzDecisionQuery" ),
XACML_AUTHZ_DECISION_QUERY_TYPE( "XACMLAuthzDecisionQueryType" ),
XACML_AUTHZ_DECISION_STATEMENT_TYPE( "XACMLAuthzDecisionStatementType" ),
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/XMLTimeUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/XMLTimeUtil.java 2011-02-10 17:03:12 UTC (rev 748)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/util/XMLTimeUtil.java 2011-02-11 20:08:03 UTC (rev 749)
@@ -152,6 +152,26 @@
}
/**
+ * Given a string, get the Duration object
+ * @param timeValue
+ * @return
+ * @throws ParsingException
+ */
+ public static Duration parseAsDuration( String timeValue ) throws ParsingException
+ {
+ DatatypeFactory factory = null;
+ try
+ {
+ factory = DatatypeFactory.newInstance();
+ }
+ catch (DatatypeConfigurationException e)
+ {
+ throw new ParsingException( e );
+ }
+ return factory.newDuration( Long.parseLong(timeValue));
+ }
+
+ /**
* Given a string representing xml time, parse into {@code XMLGregorianCalendar}
* @param timeString
* @return
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/BaseWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/BaseWriter.java 2011-02-10 17:03:12 UTC (rev 748)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/BaseWriter.java 2011-02-11 20:08:03 UTC (rev 749)
@@ -39,6 +39,7 @@
import org.picketlink.identity.federation.core.util.StringUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.LocalizedNameType;
/**
* Base Class for the Stax writers for SAML
@@ -116,6 +117,14 @@
{
StaxUtil.writeStartElement(writer, ASSERTION_PREFIX, JBossSAMLConstants.ATTRIBUTE.get(), ASSERTION_NSURI.get());
+ writeAttributeTypeWithoutRootTag(attributeType);
+
+ StaxUtil.writeEndElement(writer);
+ StaxUtil.flush(writer);
+ }
+
+ public void writeAttributeTypeWithoutRootTag( AttributeType attributeType ) throws ProcessingException
+ {
String attributeName = attributeType.getName();
if (attributeName != null)
{
@@ -168,8 +177,6 @@
throw new RuntimeException("Unsupported attribute value:" + attributeValue.getClass().getName());
}
}
- StaxUtil.writeEndElement(writer);
- StaxUtil.flush(writer);
}
public void writeStringAttributeValue( String attributeValue ) throws ProcessingException
@@ -182,4 +189,14 @@
StaxUtil.writeCharacters(writer, attributeValue );
StaxUtil.writeEndElement(writer);
}
+
+
+
+ public void writeLocalizedNameType( LocalizedNameType localizedNameType, QName startElement ) throws ProcessingException
+ {
+ StaxUtil.writeStartElement(writer, startElement.getPrefix(), startElement.getLocalPart(), startElement.getNamespaceURI() );
+ StaxUtil.writeAttribute(writer, new QName( JBossSAMLURIConstants.XML.get(), "lang", "xml" ), localizedNameType.getLang() );
+ StaxUtil.writeCharacters(writer, localizedNameType.getValue() );
+ StaxUtil.writeEndElement(writer);
+ }
}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLMetadataWriter.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLMetadataWriter.java 2011-02-10 17:03:12 UTC (rev 748)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/writers/SAMLMetadataWriter.java 2011-02-11 20:08:03 UTC (rev 749)
@@ -36,6 +36,7 @@
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AffiliationDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AttributeAuthorityDescriptorType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AttributeConsumingServiceType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.AuthnAuthorityDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EndpointType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType;
@@ -44,9 +45,11 @@
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.IDPSSODescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.IndexedEndpointType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.KeyDescriptorType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.KeyTypes;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.LocalizedNameType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.LocalizedURIType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.OrganizationType;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.RequestedAttributeType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.SPSSODescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.SSODescriptorType;
import org.w3c.dom.Element;
@@ -74,6 +77,14 @@
StaxUtil.writeNameSpace(writer, "ds", JBossSAMLURIConstants.XMLDSIG_NSURI.get() );
StaxUtil.writeAttribute(writer, JBossSAMLConstants.ENTITY_ID.get(), entityDescriptor.getEntityID() );
+ if( entityDescriptor.getValidUntil() != null )
+ {
+ StaxUtil.writeAttribute(writer, JBossSAMLConstants.VALID_UNTIL.get(), entityDescriptor.getValidUntil().toString() );
+ }
+ if( entityDescriptor.getID() != null )
+ {
+ StaxUtil.writeAttribute(writer, JBossSAMLConstants.ID.get(), entityDescriptor.getID() );
+ }
List<EDTChoiceType> choiceTypes = entityDescriptor.getChoiceType();
for( EDTChoiceType edtChoice : choiceTypes )
@@ -91,7 +102,7 @@
SPSSODescriptorType spSSO = edtDescChoice.getSpDescriptor();
if( spSSO != null )
- throw new RuntimeException( "NYI" );
+ write( spSSO );
AttributeAuthorityDescriptorType attribAuth = edtDescChoice.getAttribDescriptor();
if( attribAuth != null )
@@ -102,6 +113,8 @@
throw new RuntimeException( "NYI" );
}
}
+ OrganizationType organization = entityDescriptor.getOrganization();
+ writeOrganization(organization);
StaxUtil.writeEndElement(writer);
StaxUtil.flush(writer);
@@ -111,9 +124,53 @@
{
throw new RuntimeException( "should not called" );
}
+
public void write( SPSSODescriptorType spSSODescriptor ) throws ProcessingException
{
- throw new RuntimeException( "NYI" );
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.SP_SSO_DESCRIPTOR.get(), METADATA_NSURI.get());
+ StaxUtil.writeAttribute(writer, new QName( JBossSAMLConstants.PROTOCOL_SUPPORT_ENUMERATION.get())
+ , spSSODescriptor.getProtocolSupportEnumeration().get(0) );
+
+ //Get the key descriptors
+ List<KeyDescriptorType> keyDescriptors = spSSODescriptor.getKeyDescriptor();
+ for( KeyDescriptorType keyDescriptor :keyDescriptors )
+ {
+ writeKeyDescriptor(keyDescriptor);
+ }
+
+ List<EndpointType> sloServices = spSSODescriptor.getSingleLogoutService();
+ for( EndpointType endpoint: sloServices )
+ {
+ writeSingleLogoutService(endpoint);
+ }
+
+
+ List<IndexedEndpointType> artifactResolutions = spSSODescriptor.getArtifactResolutionService();
+ for( IndexedEndpointType artifactResolution: artifactResolutions )
+ {
+ writeArtifactResolutionService( artifactResolution );
+ }
+
+ List<String> nameIDFormats = spSSODescriptor.getNameIDFormat();
+ for( String nameIDFormat : nameIDFormats )
+ {
+ writeNameIDFormat(nameIDFormat);
+ }
+
+ List<IndexedEndpointType> assertionConsumers = spSSODescriptor.getAssertionConsumerService();
+ for( IndexedEndpointType assertionConsumer: assertionConsumers )
+ {
+ writeAssertionConsumerService( assertionConsumer );
+ }
+
+ List<AttributeConsumingServiceType> attributeConsumers = spSSODescriptor.getAttributeConsumingService();
+ for( AttributeConsumingServiceType attributeConsumer : attributeConsumers )
+ {
+ writeAttributeConsumingService(attributeConsumer);
+ }
+
+ StaxUtil.writeEndElement(writer);
+ StaxUtil.flush(writer);
}
public void write( IDPSSODescriptorType idpSSODescriptor ) throws ProcessingException
@@ -197,13 +254,65 @@
{
StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.ARTIFACT_RESOLUTION_SERVICE.get(), METADATA_NSURI.get());
+ writeIndexedEndpointType(indexedEndpoint);
+ }
+
+ public void writeAssertionConsumerService( IndexedEndpointType indexedEndpoint ) throws ProcessingException
+ {
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.ASSERTION_CONSUMER_SERVICE.get(), METADATA_NSURI.get());
+ writeIndexedEndpointType(indexedEndpoint);
+ }
+
+ public void writeIndexedEndpointType( IndexedEndpointType indexedEndpoint ) throws ProcessingException
+ {
writeEndpointType( indexedEndpoint );
+ if( indexedEndpoint.isIsDefault() != null )
+ StaxUtil.writeAttribute(writer, JBossSAMLConstants.ISDEFAULT.get(), ""+ indexedEndpoint.isIsDefault() );
+
+ StaxUtil.writeAttribute(writer, JBossSAMLConstants.INDEX.get(), ""+ indexedEndpoint.getIndex() );
+
+ StaxUtil.writeEndElement(writer);
+ StaxUtil.flush(writer);
+ }
+
+ public void writeAttributeConsumingService( AttributeConsumingServiceType attributeConsumer ) throws ProcessingException
+ {
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.ATTRIBUTE_CONSUMING_SERVICE.get(), METADATA_NSURI.get());
+
- StaxUtil.writeAttribute(writer, JBossSAMLConstants.ISDEFAULT.get(), ""+ indexedEndpoint.isIsDefault() );
- StaxUtil.writeAttribute(writer, JBossSAMLConstants.INDEX.get(), ""+ indexedEndpoint.getIndex() );
+ StaxUtil.writeAttribute(writer, JBossSAMLConstants.ISDEFAULT.get(), ""+ attributeConsumer.isIsDefault() );
+ StaxUtil.writeAttribute(writer, JBossSAMLConstants.INDEX.get(), ""+ attributeConsumer.getIndex() );
+ //Service Name
+ List<LocalizedNameType> serviceNames = attributeConsumer.getServiceName();
+ for( LocalizedNameType serviceName: serviceNames )
+ {
+ writeLocalizedNameType( serviceName, new QName(METADATA_NSURI.get(), JBossSAMLConstants.SERVICE_NAME.get(),
+ METADATA_PREFIX ));
+ }
+
+ List<LocalizedNameType> serviceDescriptions = attributeConsumer.getServiceDescription();
+ for( LocalizedNameType serviceDescription: serviceDescriptions )
+ {
+ writeLocalizedNameType( serviceDescription, new QName(METADATA_NSURI.get(), JBossSAMLConstants.SERVICE_DESCRIPTION.get(),
+ METADATA_PREFIX ));
+ }
+
+ List<RequestedAttributeType> requestedAttributes = attributeConsumer.getRequestedAttribute();
+ for( RequestedAttributeType requestedAttribute : requestedAttributes )
+ {
+ StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.REQUESTED_ATTRIBUTE.get(), METADATA_NSURI.get());
+ Boolean isRequired = requestedAttribute.isIsRequired();
+ if( isRequired != null )
+ {
+ StaxUtil.writeAttribute(writer, new QName( JBossSAMLConstants.IS_REQUIRED.get()), isRequired.toString() );
+ }
+ writeAttributeTypeWithoutRootTag(requestedAttribute);
+ StaxUtil.writeEndElement(writer);
+ }
+
StaxUtil.writeEndElement(writer);
- StaxUtil.flush(writer);
+ StaxUtil.flush(writer);
}
public void writeOrganization( OrganizationType org ) throws ProcessingException
@@ -255,6 +364,10 @@
StaxUtil.writeStartElement(writer, METADATA_PREFIX, JBossSAMLConstants.KEY_DESCRIPTOR.get(),
METADATA_NSURI.get());
+ KeyTypes keyTypes = keyDescriptor.getUse();
+ if( keyTypes != null )
+ StaxUtil.writeAttribute(writer, new QName( JBossSAMLConstants.USE.get()), keyTypes.toString() );
+
Element keyInfo = keyDescriptor.getKeyInfo();
StaxUtil.writeDOMElement(writer, keyInfo);
StaxUtil.writeEndElement(writer);
Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/saml/v2/metadata/SAMLMetadataWriterUnitTestCase.java 2011-02-11 20:08:03 UTC (rev 749)
@@ -0,0 +1,65 @@
+/*
+ * 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.test.identity.federation.core.saml.v2.metadata;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.stream.XMLStreamWriter;
+
+import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.saml.SAMLParser;
+import org.picketlink.identity.federation.core.saml.v2.writers.SAMLMetadataWriter;
+import org.picketlink.identity.federation.core.util.StaxUtil;
+import org.picketlink.identity.federation.newmodel.saml.v2.metadata.EntityDescriptorType;
+
+
+/**
+ * Unit test the {@code SAMLMetadataWriter}
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Feb 11, 2011
+ */
+public class SAMLMetadataWriterUnitTestCase
+{
+ @Test
+ public void testWriteSPSSODescriptor() throws Exception
+ {
+ String fileName = "saml2/metadata/sp-entitydescriptor.xml";
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( fileName );
+ assertNotNull( is );
+
+ SAMLParser parser = new SAMLParser();
+ EntityDescriptorType entityDesc = (EntityDescriptorType) parser.parse(is);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ XMLStreamWriter writer = StaxUtil.getXMLStreamWriter( baos );
+
+ //write it back
+ SAMLMetadataWriter mdWriter = new SAMLMetadataWriter( writer );
+ mdWriter.writeEntityDescriptor( entityDesc ) ;
+
+ System.out.println( new String( baos.toByteArray() ));
+ }
+}
\ No newline at end of file
Modified: federation/trunk/picketlink-fed-core/src/test/resources/saml2/metadata/sp-entitydescriptor.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/resources/saml2/metadata/sp-entitydescriptor.xml 2011-02-10 17:03:12 UTC (rev 748)
+++ federation/trunk/picketlink-fed-core/src/test/resources/saml2/metadata/sp-entitydescriptor.xml 2011-02-11 20:08:03 UTC (rev 749)
@@ -1,4 +1,8 @@
-<md:EntityDescriptor entityID="https://service.example.org/shibboleth" validUntil="2010-01-01T00:00:00Z">
+<md:EntityDescriptor entityID="https://service.example.org/shibboleth" validUntil="2010-01-01T00:00:00Z"
+ xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd"
+ >
<md:SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:1.1:protocol urn:oasis:names:tc:SAML:2.0:protocol">
14 years, 10 months
Picketlink SVN: r748 - picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-02-10 12:03:12 -0500 (Thu, 10 Feb 2011)
New Revision: 748
Modified:
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlMetaDataProvider.java
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlSingleSignOnReceiver.java
Log:
fixes
Modified: picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlMetaDataProvider.java
===================================================================
--- picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlMetaDataProvider.java 2011-02-08 23:08:31 UTC (rev 747)
+++ picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlMetaDataProvider.java 2011-02-10 17:03:12 UTC (rev 748)
@@ -30,6 +30,7 @@
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
+import org.picketlink.identity.federation.api.util.KeyUtil;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLMetadataWriter;
@@ -82,8 +83,6 @@
spSsoDescriptor.addSingleLogoutService( sloRedirectEndpoint );
spSsoDescriptor.addSingleLogoutService( sloPostEndpoint );
- spSsoDescriptor.getProtocolSupportEnumeration().add(JBossSAMLURIConstants.PROTOCOL_NSURI.get());
-
spSsoDescriptor.addNameIDFormat( "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent");
spSsoDescriptor.addNameIDFormat( "urn:oasis:names:tc:SAML:2.0:nameid-format:transient");
spSsoDescriptor.addNameIDFormat( "urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified");
@@ -146,11 +145,11 @@
}
private Element getKeyInfoDOM( X509Certificate certificate )
- {
+ {
try
{
StringBuilder builder = new StringBuilder( "<ds:KeyInfo><ds:X509Data><ds:X509Certificate>");
- builder.append( new String( certificate.getEncoded() )).append( "</ds:X509Certificate></ds:X509Data></ds:KeyInfo>");
+ builder.append( KeyUtil.encodeAsString( certificate )).append( "</ds:X509Certificate></ds:X509Data></ds:KeyInfo>");
return DocumentUtil.getDocument(builder.toString()).getDocumentElement();
}
catch ( Exception e)
@@ -159,4 +158,4 @@
}
}
-}
+}
\ No newline at end of file
Modified: picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlSingleSignOnReceiver.java
===================================================================
--- picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlSingleSignOnReceiver.java 2011-02-08 23:08:31 UTC (rev 747)
+++ picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/SamlSingleSignOnReceiver.java 2011-02-10 17:03:12 UTC (rev 748)
@@ -48,6 +48,7 @@
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeStatementType.ASTChoiceType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AttributeType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.AuthnStatementType;
+import org.picketlink.identity.federation.newmodel.saml.v2.assertion.EncryptedAssertionType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.EncryptedElementType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.StatementAbstractType;
@@ -147,10 +148,19 @@
{
SeamSamlPrincipal principal = null;
- for (Object assertion : responseType.getAssertions() )
+ List<RTChoiceType> assertions = responseType.getAssertions();
+
+ for (RTChoiceType rtChoice : assertions )
{
- if (assertion instanceof AssertionType)
+ EncryptedAssertionType encAssertionType = rtChoice.getEncryptedAssertion();
+ if( encAssertionType != null )
{
+ /* assertion instanceof EncryptedElementType */
+ log.warn("Encountered encrypted assertion. Skipping it because decryption is not yet supported.");
+ }
+ else
+ {
+ AssertionType assertion = rtChoice.getAssertion();
SeamSamlPrincipal assertionSubject = handleAssertion((AssertionType) assertion, requestContext);
if (principal == null)
{
@@ -159,13 +169,8 @@
else
{
log.warn("Multiple authenticated users found in assertions. Using the first one.");
- }
- }
- else
- {
- /* assertion instanceof EncryptedElementType */
- log.warn("Encountered encrypted assertion. Skipping it because decryption is not yet supported.");
- }
+ }
+ }
}
return principal;
}
@@ -256,6 +261,12 @@
List<SubjectConfirmationType> subjectConfirmations = subjectSubType.getConfirmation();
+ //Sometime the subjectconfirmation be at the top level in subject
+ if( subjectConfirmations.size() == 0 )
+ {
+ subjectConfirmations = subject.getConfirmation();
+ }
+
for( SubjectConfirmationType confirmation: subjectConfirmations )
{
if (confirmation.getMethod().equals(SamlConstants.CONFIRMATION_METHOD_BEARER))
@@ -276,6 +287,7 @@
}
}
}
+
/*for (JAXBElement<?> contentElement : assertion.getSubject().getContent())
{
if (contentElement.getValue() instanceof NameIDType)
14 years, 10 months
Picketlink SVN: r747 - in idm/branches/2.0.0: assembly and 18 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-02-08 18:08:31 -0500 (Tue, 08 Feb 2011)
New Revision: 747
Modified:
idm/branches/2.0.0/assembly/pom.xml
idm/branches/2.0.0/example/auth-simple/pom.xml
idm/branches/2.0.0/example/auth/pom.xml
idm/branches/2.0.0/example/simple/pom.xml
idm/branches/2.0.0/integration/deployer/pom.xml
idm/branches/2.0.0/integration/jboss5/pom.xml
idm/branches/2.0.0/integration/pom.xml
idm/branches/2.0.0/parent/pom.xml
idm/branches/2.0.0/picketlink-idm-api/pom.xml
idm/branches/2.0.0/picketlink-idm-auth/pom.xml
idm/branches/2.0.0/picketlink-idm-cache/pom.xml
idm/branches/2.0.0/picketlink-idm-common/pom.xml
idm/branches/2.0.0/picketlink-idm-core/pom.xml
idm/branches/2.0.0/picketlink-idm-docs/ReferenceGuide/pom.xml
idm/branches/2.0.0/picketlink-idm-docs/pom.xml
idm/branches/2.0.0/picketlink-idm-hibernate/pom.xml
idm/branches/2.0.0/picketlink-idm-ldap/pom.xml
idm/branches/2.0.0/picketlink-idm-spi/pom.xml
idm/branches/2.0.0/picketlink-idm-testsuite/pom.xml
idm/branches/2.0.0/pom.xml
Log:
change the version numbers
Modified: idm/branches/2.0.0/assembly/pom.xml
===================================================================
--- idm/branches/2.0.0/assembly/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/assembly/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -8,7 +8,7 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
Modified: idm/branches/2.0.0/example/auth/pom.xml
===================================================================
--- idm/branches/2.0.0/example/auth/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/example/auth/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.picketlink.idm.example</groupId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<artifactId>example-auth</artifactId>
<packaging>jar</packaging>
<name>Example - JEE authentication</name>
Modified: idm/branches/2.0.0/example/auth-simple/pom.xml
===================================================================
--- idm/branches/2.0.0/example/auth-simple/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/example/auth-simple/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.picketlink.idm.example</groupId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<artifactId>example-auth-simple</artifactId>
<packaging>jar</packaging>
<name>Example - JEE authentication (using deployer)</name>
Modified: idm/branches/2.0.0/example/simple/pom.xml
===================================================================
--- idm/branches/2.0.0/example/simple/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/example/simple/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.picketlink.idm.example</groupId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<artifactId>example-simple</artifactId>
<packaging>jar</packaging>
<name>Example - Simple PicketLink IDM Maven2 project</name>
Modified: idm/branches/2.0.0/integration/deployer/pom.xml
===================================================================
--- idm/branches/2.0.0/integration/deployer/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/integration/deployer/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-integration</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<properties>
Modified: idm/branches/2.0.0/integration/jboss5/pom.xml
===================================================================
--- idm/branches/2.0.0/integration/jboss5/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/integration/jboss5/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-integration</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<dependencies>
Modified: idm/branches/2.0.0/integration/pom.xml
===================================================================
--- idm/branches/2.0.0/integration/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/integration/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -6,14 +6,14 @@
<description>PicketLink IDM Integration</description>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-integration</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<!-- Parent -->
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: idm/branches/2.0.0/parent/pom.xml
===================================================================
--- idm/branches/2.0.0/parent/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/parent/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -8,7 +8,7 @@
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
<packaging>pom</packaging>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<name>PicketLink IDM- Parent</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
<description>PicketLink is a cross-cutting project that handles identity needs for the JEMS projects</description>
Modified: idm/branches/2.0.0/picketlink-idm-api/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-api/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-api/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,12 +2,12 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-api</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PicketLink IDM API</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
Modified: idm/branches/2.0.0/picketlink-idm-auth/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-auth/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-auth/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,12 +2,12 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-auth</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PicketLink IDM Auth</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
Modified: idm/branches/2.0.0/picketlink-idm-cache/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-cache/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-cache/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,12 +2,12 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-cache</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PicketLink IDM Cache</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
Modified: idm/branches/2.0.0/picketlink-idm-common/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-common/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-common/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,12 +2,12 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-common</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PicketLink IDM Common</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
Modified: idm/branches/2.0.0/picketlink-idm-core/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-core/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-core/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,12 +2,12 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-core</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PicketLink IDM Implementation</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
Modified: idm/branches/2.0.0/picketlink-idm-docs/ReferenceGuide/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-docs/ReferenceGuide/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-docs/ReferenceGuide/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,14 +2,14 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>Reference-Guide-${translation}</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>User Guide (${translation})</name>
Modified: idm/branches/2.0.0/picketlink-idm-docs/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-docs/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-docs/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,13 +2,13 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.picketlink.docs</groupId>
<artifactId>picketlink-idm-docs</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>PicketLink IDM Docs</name>
<url>http://www.jboss.com/products/jbossidentity</url>
Modified: idm/branches/2.0.0/picketlink-idm-hibernate/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-hibernate/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-hibernate/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,12 +2,12 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-hibernate</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PicketLink IDM Hibernate</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
Modified: idm/branches/2.0.0/picketlink-idm-ldap/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-ldap/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-ldap/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,12 +2,12 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-ldap</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PicketLink IDM LDAP</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
Modified: idm/branches/2.0.0/picketlink-idm-spi/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-spi/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-spi/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,12 +2,12 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-spi</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PicketLink IDM SPI</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
Modified: idm/branches/2.0.0/picketlink-idm-testsuite/pom.xml
===================================================================
--- idm/branches/2.0.0/picketlink-idm-testsuite/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/picketlink-idm-testsuite/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,12 +2,12 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>picketlink-idm-testsuite</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PicketLink IDM Testsuite</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
Modified: idm/branches/2.0.0/pom.xml
===================================================================
--- idm/branches/2.0.0/pom.xml 2011-02-08 23:00:03 UTC (rev 746)
+++ idm/branches/2.0.0/pom.xml 2011-02-08 23:08:31 UTC (rev 747)
@@ -2,13 +2,13 @@
<parent>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-parent</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<relativePath>parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.picketlink.idm</groupId>
<artifactId>jboss-identity-idm-pom</artifactId>
- <version>1.2.0.CR02-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>PicketLink IDM - Aggregator</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
14 years, 10 months
Picketlink SVN: r746 - idm/branches.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-02-08 18:00:03 -0500 (Tue, 08 Feb 2011)
New Revision: 746
Added:
idm/branches/2.0.0/
Log:
branch 2
Copied: idm/branches/2.0.0 (from rev 745, idm/branches/1.2.0)
14 years, 10 months
Picketlink SVN: r745 - in federation/trunk: picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response and 8 other directories.
by picketlink-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2011-02-07 23:13:27 -0500 (Mon, 07 Feb 2011)
New Revision: 745
Modified:
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/request/SAML2Request.java
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/sig/SAML2Signature.java
federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/util/KeyUtil.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/metadata/store/FileBasedMetadataConfigurationStore.java
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustUtil.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/filters/SPFilter.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/handlers/saml2/SAML2LogOutHandler.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/CircleOfTrustServlet.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/SOAPSAMLXACMLServlet.java
federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/util/RedirectBindingSignatureUtil.java
Log:
remove jaxb remnants
Modified: federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/request/SAML2Request.java
===================================================================
--- federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/request/SAML2Request.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/request/SAML2Request.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -28,11 +28,7 @@
import java.io.OutputStream;
import java.io.Writer;
import java.net.URI;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
+
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.parsers.ParserConfigurationException;
@@ -48,10 +44,8 @@
import org.picketlink.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLRequestWriter;
import org.picketlink.identity.federation.core.saml.v2.writers.SAMLResponseWriter;
-import org.picketlink.identity.federation.core.util.JAXBUtil;
import org.picketlink.identity.federation.core.util.StaxUtil;
import org.picketlink.identity.federation.newmodel.saml.v2.assertion.NameIDType;
-import org.picketlink.identity.federation.newmodel.saml.v2.profiles.xacml.protocol.XACMLAuthzDecisionQueryType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.AuthnRequestType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.LogoutRequestType;
import org.picketlink.identity.federation.newmodel.saml.v2.protocol.NameIDPolicyType;
@@ -143,25 +137,14 @@
{
if(is == null)
throw new IllegalStateException("InputStream is null");
-
+
Document samlDocument = DocumentUtil.getDocument(is);
-
- /*try
- {*/
- /*Binder<Node> binder = getBinder();
- JAXBElement<SAML2Object> jaxbAuthnRequestType = (JAXBElement<SAML2Object>) binder.unmarshal(samlDocument);
- SAML2Object requestType = jaxbAuthnRequestType.getValue();*/
-
- SAMLParser samlParser = new SAMLParser();
- SAML2Object requestType = (SAML2Object) samlParser.parse( DocumentUtil.getNodeAsStream( samlDocument ));
-
- samlDocumentHolder = new SAMLDocumentHolder(requestType, samlDocument);
- return requestType;
- /*}
- catch (JAXBException e)
- {
- throw new ParsingException(e);
- }*/
+
+ SAMLParser samlParser = new SAMLParser();
+ SAML2Object requestType = (SAML2Object) samlParser.parse( DocumentUtil.getNodeAsStream( samlDocument ));
+
+ samlDocumentHolder = new SAMLDocumentHolder(requestType, samlDocument);
+ return requestType;
}
/**
@@ -184,9 +167,6 @@
SAMLParser samlParser = new SAMLParser();
RequestAbstractType requestType = (RequestAbstractType) samlParser.parse( DocumentUtil.getNodeAsStream(samlDocument));
- /*Binder<Node> binder = getBinder();
- JAXBElement<RequestAbstractType> jaxbAuthnRequestType = (JAXBElement<RequestAbstractType>) binder.unmarshal(samlDocument);
- RequestAbstractType requestType = jaxbAuthnRequestType.getValue();*/
samlDocumentHolder = new SAMLDocumentHolder(requestType, samlDocument);
return requestType;
}
@@ -203,20 +183,14 @@
public AuthnRequestType getAuthnRequestType(InputStream is) throws ConfigurationException, ProcessingException, ParsingException
{
if(is == null)
- throw new IllegalStateException("InputStream is null");
- //String key = PicketLinkFederationConstants.JAXB_SCHEMA_VALIDATION;
- //boolean validate = Boolean.parseBoolean(SecurityActions.getSystemProperty(key, "false"));
+ throw new IllegalStateException("InputStream is null");
Document samlDocument = DocumentUtil.getDocument( is );
SAMLParser samlParser = new SAMLParser();
AuthnRequestType requestType = (AuthnRequestType) samlParser.parse( DocumentUtil.getNodeAsStream(samlDocument));
samlDocumentHolder = new SAMLDocumentHolder(requestType, samlDocument);
- return requestType;
-
- /*Unmarshaller un = JBossSAMLAuthnRequestFactory.getValidatingUnmarshaller(validate);
- JAXBElement<AuthnRequestType> jaxbAuthnRequestType = (JAXBElement<AuthnRequestType>) un.unmarshal(is);
- return jaxbAuthnRequestType.getValue();*/
+ return requestType;
}
@@ -250,48 +224,6 @@
}
/**
- * Parse an XACML Authorization Decision Query from an xml file
- * @param resourceName
- * @return
- * @throws JAXBException
- */
- public XACMLAuthzDecisionQueryType parseXACMLDecisionQuery(String resourceName) throws JAXBException
- {
- ClassLoader tcl = SecurityActions.getContextClassLoader();
- InputStream is = tcl.getResourceAsStream(resourceName);
- return this.parseXACMLDecisionQuery(is);
- }
-
- /**
- * XACMLAuthorizationDecisionQuery from an input stream
- * @param is The InputStream where the xacml query exists
- * @return
- * @throws JAXBException
- */
- @SuppressWarnings("unchecked")
- public XACMLAuthzDecisionQueryType parseXACMLDecisionQuery(InputStream is) throws JAXBException
- {
- if(is == null)
- throw new IllegalArgumentException("Inputstream is null");
-
- String samlPath = "org.picketlink.identity.federation.saml.v2.protocol";
- String xacmlPath = "org.jboss.security.xacml.core.model.context";
- String xsAssert = "org.picketlink.identity.federation.saml.v2.profiles.xacml.assertion";
- String xsProto = "org.picketlink.identity.federation.saml.v2.profiles.xacml.protocol";
- String path = samlPath + ":" + xacmlPath + ":" + xsAssert + ":" + xsProto;
-
- JAXBContext jaxb = JAXBUtil.getJAXBContext(path);
- Unmarshaller un = jaxb.createUnmarshaller();
-
- JAXBElement<RequestAbstractType> jaxbRequestType = (JAXBElement<RequestAbstractType>) un.unmarshal(is);
- RequestAbstractType req = jaxbRequestType.getValue();
- if(req instanceof XACMLAuthzDecisionQueryType == false)
- throw new IllegalStateException("Not of type XACMLAuthzDecisionQueryType");
-
- return (XACMLAuthzDecisionQueryType) req;
- }
-
- /**
* Return the DOM object
* @param rat
* @return
@@ -299,9 +231,6 @@
* @throws ParsingException
* @throws ConfigurationException
*/
- /*public Document convert(RequestAbstractType rat)
- throws SAXException, IOException, JAXBException, ConfigurationException */
-
public Document convert(RequestAbstractType rat)
throws ProcessingException, ConfigurationException, ParsingException
{
@@ -317,21 +246,13 @@
writer.write( (LogoutRequestType) rat);
}
- return DocumentUtil.getDocument( new String( bos.toByteArray() ));
-
- /*JAXBContext jaxb = JAXBUtil.getJAXBContext(RequestAbstractType.class);
- Binder<Node> binder = jaxb.createBinder();
-
- Document doc = DocumentUtil.createDocument();
- binder.marshal(JAXBElementMappingUtil.get(rat), doc);
- return doc;*/
+ return DocumentUtil.getDocument( new String( bos.toByteArray() ));
}
/**
* Convert a SAML2 Response into a Document
* @param responseType
- * @return
- * @throws JAXBException
+ * @return
* @throws ParserConfigurationException
*/
public Document convert( ResponseType responseType) throws ProcessingException, ParsingException, ConfigurationException
@@ -347,19 +268,11 @@
/**
* Marshall the AuthnRequestType to an output stream
* @param requestType
- * @param os
- * @throws JAXBException
+ * @param os
* @throws SAXException
*/
public void marshall(RequestAbstractType requestType, OutputStream os) throws ProcessingException
- {
- /*String key = PicketLinkFederationConstants.JAXB_SCHEMA_VALIDATION;
- boolean validate = Boolean.parseBoolean(SecurityActions.getSystemProperty(key, "false"));
-
- Marshaller marshaller = JBossSAMLAuthnRequestFactory.getValidatingMarshaller(validate);
- JAXBElement<?> j = JAXBElementMappingUtil.get(requestType);
- marshaller.marshal(j, os);
- */
+ {
SAMLRequestWriter samlRequestWriter = new SAMLRequestWriter( StaxUtil.getXMLStreamWriter(os));
if( requestType instanceof AuthnRequestType )
{
@@ -376,19 +289,11 @@
/**
* Marshall the AuthnRequestType to a writer
* @param requestType
- * @param writer
- * @throws JAXBException
+ * @param writer
* @throws SAXException
*/
public void marshall(RequestAbstractType requestType, Writer writer) throws ProcessingException
- {
- /*String key = PicketLinkFederationConstants.JAXB_SCHEMA_VALIDATION;
- boolean validate = Boolean.parseBoolean(SecurityActions.getSystemProperty(key, "false"));
-
- Marshaller marshaller = JBossSAMLAuthnRequestFactory.getValidatingMarshaller(validate);
- JAXBElement<?> j = JAXBElementMappingUtil.get(requestType);
- marshaller.marshal(j, writer);*/
-
+ {
SAMLRequestWriter samlRequestWriter = new SAMLRequestWriter( StaxUtil.getXMLStreamWriter( writer ));
if( requestType instanceof AuthnRequestType )
{
Modified: federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java
===================================================================
--- federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/response/SAML2Response.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -32,7 +32,6 @@
import java.net.URI;
import java.util.Arrays;
-import javax.xml.bind.JAXBException;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
@@ -358,7 +357,6 @@
* @return
* @throws ParsingException
* @throws ConfigurationException
- * @throws JAXBException
* @throws ParserConfigurationException
*/
public Document convert( StatusResponseType responseType) throws ProcessingException, ConfigurationException, ParsingException
Modified: federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/sig/SAML2Signature.java
===================================================================
--- federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/sig/SAML2Signature.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/saml/v2/sig/SAML2Signature.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -25,8 +25,7 @@
import java.security.GeneralSecurityException;
import java.security.KeyPair;
import java.security.PublicKey;
-
-import javax.xml.bind.JAXBException;
+
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.dsig.DigestMethod;
import javax.xml.crypto.dsig.SignatureMethod;
@@ -87,14 +86,13 @@
* @param signatureMethod (Example: SignatureMethod.DSA_SHA1)
* @return
* @throws ParserConfigurationException
- * @throws JAXBException
* @throws IOException
* @throws SAXException
* @throws XMLSignatureException
* @throws MarshalException
* @throws GeneralSecurityException
*/
- public Document sign(RequestAbstractType request, KeyPair keypair) throws SAXException, IOException, JAXBException, ParserConfigurationException, GeneralSecurityException, MarshalException, XMLSignatureException
+ public Document sign(RequestAbstractType request, KeyPair keypair) throws SAXException, IOException, ParserConfigurationException, GeneralSecurityException, MarshalException, XMLSignatureException
{
SAML2Request saml2Request = new SAML2Request();
Document doc = saml2Request.convert(request);
@@ -115,13 +113,12 @@
* @param digestMethod (Example: DigestMethod.SHA1)
* @param signatureMethod (Example: SignatureMethod.DSA_SHA1)
* @return
- * @throws ParserConfigurationException
- * @throws JAXBException
+ * @throws ParserConfigurationException
* @throws XMLSignatureException
* @throws MarshalException
* @throws GeneralSecurityException
*/
- public Document sign(ResponseType response,KeyPair keypair) throws JAXBException, ParserConfigurationException, GeneralSecurityException, MarshalException, XMLSignatureException
+ public Document sign(ResponseType response,KeyPair keypair) throws ParserConfigurationException, GeneralSecurityException, MarshalException, XMLSignatureException
{
SAML2Response saml2Request = new SAML2Response();
Document doc = saml2Request.convert(response);
@@ -137,15 +134,14 @@
* @param digestMethod (Example: DigestMethod.SHA1)
* @param signatureMethod (Example: SignatureMethod.DSA_SHA1)
* @return
- * @throws ParserConfigurationException
- * @throws JAXBException
+ * @throws ParserConfigurationException
* @throws XMLSignatureException
* @throws MarshalException
* @throws GeneralSecurityException
*/
public Document sign(Document doc,
String referenceID,
- KeyPair keypair) throws JAXBException,
+ KeyPair keypair) throws
ParserConfigurationException, GeneralSecurityException, MarshalException, XMLSignatureException
{
String referenceURI = "#" + referenceID;
@@ -163,8 +159,7 @@
* @param keypair
* @param referenceURI
* @return
- * @throws ParserConfigurationException
- * @throws JAXBException
+ * @throws ParserConfigurationException
* @throws TransformerException
* @throws TransformerFactoryConfigurationError
* @throws XPathException
@@ -175,7 +170,7 @@
public Document sign(ResponseType response,
String idValueOfAssertion,
KeyPair keypair,
- String referenceURI) throws JAXBException, ParserConfigurationException, XPathException, TransformerFactoryConfigurationError, TransformerException, GeneralSecurityException, MarshalException, XMLSignatureException
+ String referenceURI) throws ParserConfigurationException, XPathException, TransformerFactoryConfigurationError, TransformerException, GeneralSecurityException, MarshalException, XMLSignatureException
{
SAML2Response saml2Response = new SAML2Response();
Document doc = saml2Response.convert(response);
@@ -190,7 +185,6 @@
* @param keypair
* @param referenceURI
* @return
- * @throws JAXBException
* @throws ParserConfigurationException
* @throws XPathException
* @throws TransformerFactoryConfigurationError
@@ -202,7 +196,7 @@
public Document sign(Document doc,
String idValueOfAssertion,
KeyPair keypair,
- String referenceURI) throws JAXBException, ParserConfigurationException, XPathException, TransformerFactoryConfigurationError, TransformerException, GeneralSecurityException, MarshalException, XMLSignatureException
+ String referenceURI) throws ParserConfigurationException, XPathException, TransformerFactoryConfigurationError, TransformerException, GeneralSecurityException, MarshalException, XMLSignatureException
{
Node assertionNode = DocumentUtil.getNodeWithAttribute(doc,
Modified: federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/util/KeyUtil.java
===================================================================
--- federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/util/KeyUtil.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-fed-api/src/main/java/org/picketlink/identity/federation/api/util/KeyUtil.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -28,8 +28,6 @@
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
-import javax.xml.bind.JAXBException;
-
import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.exceptions.ParsingException;
import org.picketlink.identity.federation.core.exceptions.ProcessingException;
@@ -60,8 +58,7 @@
/**
* Given a certificate, build a keyinfo type
* @param certificate
- * @return
- * @throws JAXBException
+ * @return
* @throws CertificateException
* @throws ProcessingException
* @throws ParsingException
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/metadata/store/FileBasedMetadataConfigurationStore.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/metadata/store/FileBasedMetadataConfigurationStore.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/saml/v2/metadata/store/FileBasedMetadataConfigurationStore.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -182,23 +182,7 @@
catch (ParsingException e)
{
throw new RuntimeException( e );
- }/*
- Unmarshaller un;
- try
- {
-
- un = JAXBUtil.getUnmarshaller(pkgName);
- JAXBElement<EntityDescriptorType> je =
- (JAXBElement<EntityDescriptorType>) un.unmarshal(persistedFile);
- return je.getValue();
}
- catch (JAXBException e)
- {
- IOException ioe =new IOException(e.getLocalizedMessage());
- ioe.initCause(e);
- throw ioe;
- }*/
-
}
/**
Modified: federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustUtil.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustUtil.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/wstrust/WSTrustUtil.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -37,8 +37,6 @@
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
import javax.xml.namespace.QName;
import org.apache.log4j.Logger;
@@ -47,7 +45,6 @@
import org.picketlink.identity.federation.core.config.STSType;
import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
import org.picketlink.identity.federation.core.util.Base64;
-import org.picketlink.identity.federation.core.util.JAXBUtil;
import org.picketlink.identity.federation.core.util.XMLEncryptionUtil;
import org.picketlink.identity.federation.core.wstrust.wrappers.Lifetime;
import org.picketlink.identity.federation.core.wstrust.wrappers.RequestSecurityToken;
@@ -78,7 +75,6 @@
*
* @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a>
*/
-@SuppressWarnings("unchecked")
public class WSTrustUtil
{
@@ -284,10 +280,9 @@
* Marshall the {@code STSType} to an outputstream
* </p>
* @param stsConfiguration
- * @param outputStream
- * @throws JAXBException
+ * @param outputStream
*/
- public static void persistSTSConfiguration(STSType stsConfiguration, OutputStream outputStream) throws JAXBException
+ public static void persistSTSConfiguration(STSType stsConfiguration, OutputStream outputStream)
{
throw new RuntimeException();
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/filters/SPFilter.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/filters/SPFilter.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/filters/SPFilter.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -50,7 +50,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import javax.xml.bind.JAXBException;
import javax.xml.crypto.MarshalException;
import javax.xml.crypto.dsig.CanonicalizationMethod;
import javax.xml.crypto.dsig.XMLSignatureException;
@@ -591,7 +590,7 @@
protected void sendRequestToIDP(AuthnRequestType authnRequest, String relayState,
HttpServletResponse response)
- throws IOException, SAXException, JAXBException,GeneralSecurityException
+ throws IOException, SAXException, GeneralSecurityException
{
SAML2Request saml2Request = new SAML2Request();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -607,7 +606,7 @@
String destination,
HttpServletResponse response,
boolean request)
- throws IOException, SAXException, JAXBException,GeneralSecurityException
+ throws IOException, SAXException, GeneralSecurityException
{
if(!ignoreSignatures)
{
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/handlers/saml2/SAML2LogOutHandler.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/handlers/saml2/SAML2LogOutHandler.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/handlers/saml2/SAML2LogOutHandler.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -315,18 +315,7 @@
{
throw new ProcessingException( e );
}
- /*catch(JAXBException pe)
- {
- throw new ProcessingException(pe);
- }
- catch(IOException pe)
- {
- throw new ProcessingException(pe);
- }
- catch(SAXException pe)
- {
- throw new ProcessingException(pe);
- }*/
+
return;
}
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/CircleOfTrustServlet.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/CircleOfTrustServlet.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/CircleOfTrustServlet.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -33,7 +33,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import javax.xml.bind.JAXBException;
import org.picketlink.identity.federation.core.saml.v2.metadata.store.FileBasedMetadataConfigurationStore;
import org.picketlink.identity.federation.core.saml.v2.metadata.store.IMetadataConfigurationStore;
@@ -147,7 +146,7 @@
}
private void addIDP(HttpServletRequest request, HttpServletResponse response)
- throws IOException, JAXBException
+ throws IOException
{
String spName = request.getParameter("spname");
String idpName = request.getParameter("idpname");
@@ -179,7 +178,7 @@
}
private void addSP(HttpServletRequest request, HttpServletResponse response)
- throws JAXBException, IOException
+ throws IOException
{
String idpName = request.getParameter("idpname");
String spName = request.getParameter("spname");
@@ -209,7 +208,7 @@
}
- private EntityDescriptorType getMetaData(String metadataURL) throws JAXBException, IOException
+ private EntityDescriptorType getMetaData(String metadataURL) throws IOException
{
throw new RuntimeException();
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/SOAPSAMLXACMLServlet.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/SOAPSAMLXACMLServlet.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/servlets/saml/SOAPSAMLXACMLServlet.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -281,12 +281,6 @@
//Create a SOAP Envelope to hold the SAML response
envelope = this.createEnvelope(jaxbResponse); */
}
- /*catch (JAXBException e)r
- {
- String id = IDGenerator.create();
- log.error(id + "::Exception parsing SOAP:", e);
- envelope = this.createEnvelope(this.createFault("Parsing Error. Reference::" + id));
- } */
catch ( Exception e )
{
e.printStackTrace();
Modified: federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/util/RedirectBindingSignatureUtil.java
===================================================================
--- federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/util/RedirectBindingSignatureUtil.java 2011-02-08 03:51:59 UTC (rev 744)
+++ federation/trunk/picketlink-web/src/main/java/org/picketlink/identity/federation/web/util/RedirectBindingSignatureUtil.java 2011-02-08 04:13:27 UTC (rev 745)
@@ -31,8 +31,6 @@
import java.security.PrivateKey;
import java.security.PublicKey;
-import javax.xml.bind.JAXBException;
-
import org.picketlink.identity.federation.api.saml.v2.request.SAML2Request;
import org.picketlink.identity.federation.api.saml.v2.response.SAML2Response;
import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
@@ -60,13 +58,12 @@
* @param relayState
* @param signingKey
* @return
- * @throws JAXBException
* @throws SAXException
* @throws IOException
* @throws GeneralSecurityException
*/
public static String getSAMLRequestURLWithSignature(AuthnRequestType authRequest, String relayState,
- PrivateKey signingKey) throws SAXException, JAXBException, IOException, GeneralSecurityException
+ PrivateKey signingKey) throws SAXException, IOException, GeneralSecurityException
{
SAML2Request saml2Request = new SAML2Request();
@@ -94,11 +91,10 @@
* @param signingKey
* @return
* @throws IOException
- * @throws GeneralSecurityException
- * @throws JAXBException
+ * @throws GeneralSecurityException
*/
public static String getSAMLResponseURLWithSignature(ResponseType responseType, String relayState,
- PrivateKey signingKey) throws IOException, GeneralSecurityException, JAXBException
+ PrivateKey signingKey) throws IOException, GeneralSecurityException
{
SAML2Response saml2Response = new SAML2Response();
14 years, 10 months