[jboss-identity-commits] JBoss Identity SVN: r257 - in identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2: holders and 1 other directories.
jboss-identity-commits at lists.jboss.org
jboss-identity-commits at lists.jboss.org
Wed Jan 28 17:29:06 EST 2009
Author: anil.saldhana at jboss.com
Date: 2009-01-28 17:29:06 -0500 (Wed, 28 Jan 2009)
New Revision: 257
Added:
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAMLAssertionFactory.java
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAMLProtocolFactory.java
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SOAPFactory.java
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/XACMLStatementFactory.java
Modified:
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnRequestFactory.java
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/holders/IssuerInfoHolder.java
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/JAXBElementMappingUtil.java
Log:
add factories to get to respective object factory
Modified: identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnRequestFactory.java
===================================================================
--- identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnRequestFactory.java 2009-01-27 15:43:56 UTC (rev 256)
+++ identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnRequestFactory.java 2009-01-28 22:29:06 UTC (rev 257)
@@ -30,7 +30,6 @@
import org.jboss.identity.federation.core.saml.v2.util.XMLTimeUtil;
import org.jboss.identity.federation.saml.v2.assertion.NameIDType;
import org.jboss.identity.federation.saml.v2.protocol.AuthnRequestType;
-import org.jboss.identity.federation.saml.v2.protocol.ObjectFactory;
/**
* Factory for SAML2 AuthnRequest
@@ -41,8 +40,6 @@
{
private static String pkgName = "org.jboss.identity.federation.saml.v2.protocol:org.jboss.identity.xmlsec.w3.xmldsig";
private static String schemaLocation = "schema/saml/v2/saml-schema-protocol-2.0.xsd";
-
- private static ObjectFactory protocolObjectFactory = new ObjectFactory();
/**
* Create a AuthnRequestType
@@ -50,7 +47,7 @@
*/
public static AuthnRequestType createAuthnRequestType()
{
- AuthnRequestType authnRequestType = protocolObjectFactory.createAuthnRequestType();
+ AuthnRequestType authnRequestType = SAMLProtocolFactory.getObjectFactory().createAuthnRequestType();
return authnRequestType;
}
@@ -67,7 +64,7 @@
{
XMLGregorianCalendar issueInstant = XMLTimeUtil.getIssueInstant();
- AuthnRequestType authnRequest = protocolObjectFactory.createAuthnRequestType();
+ AuthnRequestType authnRequest = SAMLProtocolFactory.getObjectFactory().createAuthnRequestType();
authnRequest.setID(id);
authnRequest.setVersion(JBossSAMLConstants.VERSION_2_0.get());
authnRequest.setAssertionConsumerServiceURL(assertionConsumerURL);
@@ -91,19 +88,10 @@
*/
public static JAXBElement<AuthnRequestType> createAuthnRequestType(AuthnRequestType authnRequestType)
{
- return protocolObjectFactory.createAuthnRequest(authnRequestType);
+ return SAMLProtocolFactory.getObjectFactory().createAuthnRequest(authnRequestType);
}
/**
- * Get the Object Factory useful for dealing with SAML2 requests
- * @return
- */
- public static ObjectFactory getObjectFactory()
- {
- return protocolObjectFactory;
- }
-
- /**
* Get the validating marshaller
* @return
* @throws Exception
Modified: identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java
===================================================================
--- identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java 2009-01-27 15:43:56 UTC (rev 256)
+++ identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/JBossSAMLAuthnResponseFactory.java 2009-01-28 22:29:06 UTC (rev 257)
@@ -35,7 +35,6 @@
import org.jboss.identity.federation.saml.v2.assertion.SubjectConfirmationDataType;
import org.jboss.identity.federation.saml.v2.assertion.SubjectConfirmationType;
import org.jboss.identity.federation.saml.v2.assertion.SubjectType;
-import org.jboss.identity.federation.saml.v2.protocol.ObjectFactory;
import org.jboss.identity.federation.saml.v2.protocol.ResponseType;
import org.jboss.identity.federation.saml.v2.protocol.StatusCodeType;
import org.jboss.identity.federation.saml.v2.protocol.StatusType;
@@ -50,8 +49,6 @@
private static String pkgName = "org.jboss.identity.federation.saml.v2.protocol:org.jboss.identity.xmlsec.w3.xmldsig";
private static String schemaLocation = "schema/saml/v2/saml-schema-protocol-2.0.xsd";
- private static ObjectFactory protocolObjectFactory = new ObjectFactory();
-
/**
* Create a StatusType given the status code uri
* @param statusCodeURI
@@ -59,10 +56,10 @@
*/
public static StatusType createStatusType(String statusCodeURI)
{
- StatusCodeType sct = protocolObjectFactory.createStatusCodeType();
+ StatusCodeType sct = SAMLProtocolFactory.getObjectFactory().createStatusCodeType();
sct.setValue(statusCodeURI);
- StatusType statusType = protocolObjectFactory.createStatusType();
+ StatusType statusType = SAMLProtocolFactory.getObjectFactory().createStatusType();
statusType.setStatusCode(sct);
return statusType;
}
@@ -78,7 +75,7 @@
*/
public static ResponseType createResponseType(String ID, SPInfoHolder sp, IDPInfoHolder idp, IssuerInfoHolder issuerInfo) throws Exception
{
- ResponseType responseType = protocolObjectFactory.createResponseType();
+ /*ResponseType responseType = protocolObjectFactory.createResponseType();
responseType.setVersion(issuerInfo.getSamlVersion());
//ID
@@ -103,15 +100,19 @@
XMLGregorianCalendar issueInstant = XMLTimeUtil.getIssueInstant();
//IssueInstant
- responseType.setIssueInstant(issueInstant);
+ responseType.setIssueInstant(issueInstant);*/
+ String responseDestinationURI = sp.getResponseDestinationURI();
+
+ XMLGregorianCalendar issueInstant = XMLTimeUtil.getIssueInstant();
+
//Create an assertion
AssertionType assertionType = JBossSAMLBaseFactory.createAssertion();
assertionType.setID("ID_" + JBossSAMLBaseFactory.createUUID());
assertionType.setVersion(issuerInfo.getSamlVersion());
assertionType.setIssueInstant(issueInstant);
- assertionType.setIssuer(issuer);
+ assertionType.setIssuer(issuerInfo.getIssuer());
//Create assertion -> subject
SubjectType subjectType = JBossSAMLBaseFactory.createSubject();
@@ -138,17 +139,42 @@
assertionType.setSubject(subjectType);
- responseType.getAssertionOrEncryptedAssertion().add(assertionType);
+ ResponseType responseType = createResponseType(ID, issuerInfo, assertionType);
+ //InResponseTo ID
+ responseType.setInResponseTo(sp.getRequestID());
+ //Destination
+ responseType.setDestination(responseDestinationURI);
+
return responseType;
}
- /**
- * Return the JAXB2 object factory (mainly for invocation chaining)
- * @return
- */
- public static ObjectFactory getObjectFactory()
+ public static ResponseType createResponseType(String ID, IssuerInfoHolder issuerInfo, AssertionType assertionType)
+ throws Exception
{
- return protocolObjectFactory;
+ ResponseType responseType = SAMLProtocolFactory.getObjectFactory().createResponseType();
+ 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.getAssertionOrEncryptedAssertion().add(assertionType);
+ return responseType;
}
/**
Added: identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAMLAssertionFactory.java
===================================================================
--- identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAMLAssertionFactory.java (rev 0)
+++ identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAMLAssertionFactory.java 2009-01-28 22:29:06 UTC (rev 257)
@@ -0,0 +1,39 @@
+/*
+ * 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.jboss.identity.federation.core.saml.v2.factories;
+
+import org.jboss.identity.federation.saml.v2.assertion.ObjectFactory;
+
+/**
+ * Get the SAML Assertion Object Factory
+ * @author Anil.Saldhana at redhat.com
+ * @since Jan 28, 2009
+ */
+public class SAMLAssertionFactory
+{
+ private static ObjectFactory factory = new ObjectFactory();
+
+ public static ObjectFactory getObjectFactory()
+ {
+ return factory;
+ }
+}
\ No newline at end of file
Added: identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAMLProtocolFactory.java
===================================================================
--- identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAMLProtocolFactory.java (rev 0)
+++ identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SAMLProtocolFactory.java 2009-01-28 22:29:06 UTC (rev 257)
@@ -0,0 +1,40 @@
+/*
+ * 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.jboss.identity.federation.core.saml.v2.factories;
+
+import org.jboss.identity.federation.saml.v2.protocol.ObjectFactory;
+
+/**
+ * Provides an handle to the ObjectFactory
+ * for creating SAML Protocol objects
+ * @author Anil.Saldhana at redhat.com
+ * @since Jan 28, 2009
+ */
+public class SAMLProtocolFactory
+{
+ private static ObjectFactory factory = new ObjectFactory();
+
+ public static ObjectFactory getObjectFactory()
+ {
+ return factory;
+ }
+}
\ No newline at end of file
Added: identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SOAPFactory.java
===================================================================
--- identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SOAPFactory.java (rev 0)
+++ identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/SOAPFactory.java 2009-01-28 22:29:06 UTC (rev 257)
@@ -0,0 +1,40 @@
+/*
+ * 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.jboss.identity.federation.core.saml.v2.factories;
+
+import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.ObjectFactory;
+
+/**
+ * Provides an handle to the ObjectFactory that is capable
+ * of creating SOAP objects
+ * @author Anil.Saldhana at redhat.com
+ * @since Jan 28, 2009
+ */
+public class SOAPFactory
+{
+ private static ObjectFactory factory = new ObjectFactory();
+
+ public static ObjectFactory getObjectFactory()
+ {
+ return factory;
+ }
+}
\ No newline at end of file
Added: identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/XACMLStatementFactory.java
===================================================================
--- identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/XACMLStatementFactory.java (rev 0)
+++ identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/factories/XACMLStatementFactory.java 2009-01-28 22:29:06 UTC (rev 257)
@@ -0,0 +1,45 @@
+/*
+ * 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.jboss.identity.federation.core.saml.v2.factories;
+
+import org.jboss.identity.federation.saml.v2.profiles.xacml.assertion.ObjectFactory;
+
+/**
+ * Factory for dealing with XACML Statements
+ * sent as SAML statements
+ * @author Anil.Saldhana at redhat.com
+ * @since Jan 28, 2009
+ */
+public class XACMLStatementFactory
+{
+ private static ObjectFactory factory = new ObjectFactory();
+
+ /**
+ * Return the object factory to be
+ * used in chain of method invocation
+ * @return
+ */
+ public static ObjectFactory getObjectFactory()
+ {
+ return factory;
+ }
+}
\ No newline at end of file
Modified: identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/holders/IssuerInfoHolder.java
===================================================================
--- identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/holders/IssuerInfoHolder.java 2009-01-27 15:43:56 UTC (rev 256)
+++ identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/holders/IssuerInfoHolder.java 2009-01-28 22:29:06 UTC (rev 257)
@@ -22,6 +22,7 @@
package org.jboss.identity.federation.core.saml.v2.holders;
import org.jboss.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
+import org.jboss.identity.federation.core.saml.v2.constants.JBossSAMLURIConstants;
import org.jboss.identity.federation.saml.v2.assertion.NameIDType;
import org.jboss.identity.federation.saml.v2.assertion.ObjectFactory;
@@ -35,7 +36,7 @@
{
private NameIDType issuer;
- private String statusCodeURI;
+ private String statusCodeURI = JBossSAMLURIConstants.STATUS_SUCCESS.get();
private String samlVersion = JBossSAMLConstants.VERSION_2_0.get();
Modified: identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/JAXBElementMappingUtil.java
===================================================================
--- identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/JAXBElementMappingUtil.java 2009-01-27 15:43:56 UTC (rev 256)
+++ identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/JAXBElementMappingUtil.java 2009-01-28 22:29:06 UTC (rev 257)
@@ -23,55 +23,80 @@
import javax.xml.bind.JAXBElement;
+import org.jboss.identity.federation.core.saml.v2.factories.SAMLProtocolFactory;
+import org.jboss.identity.federation.core.saml.v2.factories.SOAPFactory;
+import org.jboss.identity.federation.core.saml.v2.factories.XACMLStatementFactory;
+import org.jboss.identity.federation.org.xmlsoap.schemas.soap.envelope.Envelope;
+import org.jboss.identity.federation.saml.v2.profiles.xacml.assertion.XACMLAuthzDecisionStatementType;
import org.jboss.identity.federation.saml.v2.protocol.ArtifactResolveType;
import org.jboss.identity.federation.saml.v2.protocol.AssertionIDRequestType;
import org.jboss.identity.federation.saml.v2.protocol.AuthnRequestType;
import org.jboss.identity.federation.saml.v2.protocol.LogoutRequestType;
import org.jboss.identity.federation.saml.v2.protocol.ManageNameIDRequestType;
import org.jboss.identity.federation.saml.v2.protocol.NameIDMappingRequestType;
-import org.jboss.identity.federation.saml.v2.protocol.ObjectFactory;
import org.jboss.identity.federation.saml.v2.protocol.RequestAbstractType;
+import org.jboss.identity.federation.saml.v2.protocol.ResponseType;
/**
+ * Maps various saml/xacml types to their corresponding JAXBElement
* @author Anil.Saldhana at redhat.com
* @since Jan 22, 2009
*/
public class JAXBElementMappingUtil
{
+ /**
+ * Get the JAXBElement for the request type
+ * @param requestAbstractType
+ * @return
+ */
public static JAXBElement<?> get(RequestAbstractType requestAbstractType)
- {
- ObjectFactory factory = new ObjectFactory();
+ {
if(requestAbstractType instanceof AuthnRequestType)
{
AuthnRequestType art = (AuthnRequestType) requestAbstractType;
- return factory.createAuthnRequest(art);
+ return SAMLProtocolFactory.getObjectFactory().createAuthnRequest(art);
}
if(requestAbstractType instanceof LogoutRequestType)
{
LogoutRequestType lrt = (LogoutRequestType) requestAbstractType;
- return factory.createLogoutRequest(lrt);
+ return SAMLProtocolFactory.getObjectFactory().createLogoutRequest(lrt);
}
if(requestAbstractType instanceof AssertionIDRequestType)
{
AssertionIDRequestType airt = (AssertionIDRequestType) requestAbstractType;
- return factory.createAssertionIDRequest(airt);
+ return SAMLProtocolFactory.getObjectFactory().createAssertionIDRequest(airt);
}
if(requestAbstractType instanceof NameIDMappingRequestType)
{
NameIDMappingRequestType airt = (NameIDMappingRequestType) requestAbstractType;
- return factory.createNameIDMappingRequest(airt);
+ return SAMLProtocolFactory.getObjectFactory().createNameIDMappingRequest(airt);
}
if(requestAbstractType instanceof ArtifactResolveType)
{
ArtifactResolveType airt = (ArtifactResolveType) requestAbstractType;
- return factory.createArtifactResolve(airt);
+ return SAMLProtocolFactory.getObjectFactory().createArtifactResolve(airt);
}
if(requestAbstractType instanceof ManageNameIDRequestType)
{
ManageNameIDRequestType airt = (ManageNameIDRequestType) requestAbstractType;
- return factory.createManageNameIDRequest(airt);
+ return SAMLProtocolFactory.getObjectFactory().createManageNameIDRequest(airt);
}
throw new IllegalArgumentException("Unknown Type:"+requestAbstractType);
}
+
+ public static JAXBElement<?> get(ResponseType responseType)
+ {
+ return SAMLProtocolFactory.getObjectFactory().createResponse(responseType);
+ }
+
+ public static JAXBElement<?> get(Envelope envelope)
+ {
+ return SOAPFactory.getObjectFactory().createEnvelope(envelope);
+ }
+
+ public static JAXBElement<?> get(XACMLAuthzDecisionStatementType xacmlStatement)
+ {
+ return XACMLStatementFactory.getObjectFactory().createXACMLAuthzDecisionStatement(xacmlStatement);
+ }
}
\ No newline at end of file
More information about the jboss-identity-commits
mailing list