Author: anil.saldhana(a)jboss.com
Date: 2008-12-11 12:33:57 -0500 (Thu, 11 Dec 2008)
New Revision: 148
Modified:
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLAuthnRequestFactory.java
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLAuthnResponseFactory.java
Log:
update the factories
Modified:
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLAuthnRequestFactory.java
===================================================================
---
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLAuthnRequestFactory.java 2008-12-11
15:29:24 UTC (rev 147)
+++
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLAuthnRequestFactory.java 2008-12-11
17:33:57 UTC (rev 148)
@@ -23,11 +23,15 @@
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.Writer;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
+import javax.xml.datatype.XMLGregorianCalendar;
+import org.jboss.identity.federation.saml.v2.assertion.NameIDType;
+import org.jboss.identity.federation.saml.v2.jboss.JBossSAMLConstants;
import org.jboss.identity.federation.saml.v2.protocol.AuthnRequestType;
import org.jboss.identity.federation.saml.v2.protocol.ObjectFactory;
@@ -44,6 +48,55 @@
private static ObjectFactory protocolObjectFactory = new ObjectFactory();
/**
+ * Create a AuthnRequestType
+ * @return
+ */
+ public static AuthnRequestType createAuthnRequestType()
+ {
+ AuthnRequestType authnRequestType =
protocolObjectFactory.createAuthnRequestType();
+ return authnRequestType;
+ }
+
+ /**
+ * Create an AuthnRequestType
+ * @param id Id of the request
+ * @param assertionConsumerURL URL of the requestor where the response assertion is
requested
+ * @param issuerValue URL of the issuer
+ * @return
+ * @throws Exception
+ */
+ public static AuthnRequestType createAuthnRequestType(String id,
+ String assertionConsumerURL, String issuerValue) throws Exception
+ {
+ XMLGregorianCalendar issueInstant = JBossSAMLBaseFactory.getIssueInstant();
+
+ AuthnRequestType authnRequest = protocolObjectFactory.createAuthnRequestType();
+ authnRequest.setID(id);
+ authnRequest.setVersion(JBossSAMLConstants.VERSION_2_0.get());
+ authnRequest.setAssertionConsumerServiceURL(assertionConsumerURL);
+ authnRequest.setIssueInstant(issueInstant);
+
+ //Create an issuer
+ NameIDType issuer = JBossSAMLBaseFactory.createNameID();
+ issuer.setValue(issuerValue);
+
+ authnRequest.setIssuer(issuer);
+
+ return authnRequest;
+
+ }
+
+ /**
+ * Create a JAXBElement for the AuthnRequestType
+ * @param authnRequestType
+ * @return
+ */
+ public static JAXBElement<AuthnRequestType>
createAuthnRequestType(AuthnRequestType authnRequestType)
+ {
+ return protocolObjectFactory.createAuthnRequest(authnRequestType);
+ }
+
+ /**
* Get AuthnRequestType from a file
* @param fileName file with the serialized AuthnRequestType
* @return AuthnRequestType
@@ -77,10 +130,29 @@
return jaxbAuthnRequestType.getValue();
}
+ /**
+ * Marshall the AuthnRequestType to an output stream
+ * @param requestType
+ * @param os
+ * @throws Exception
+ */
public static void marshall(AuthnRequestType requestType, OutputStream os) throws
Exception
{
Marshaller marshaller = JBossSAMLBaseFactory.getValidatingMarshaller(pkgName,
schemaLocation);
JAXBElement<AuthnRequestType> jaxb =
protocolObjectFactory.createAuthnRequest(requestType);
marshaller.marshal(jaxb, os);
}
+
+ /**
+ * Marshall the AuthnRequestType to a writer
+ * @param requestType
+ * @param writer
+ * @throws Exception
+ */
+ public static void marshall(AuthnRequestType requestType, Writer writer) throws
Exception
+ {
+ Marshaller marshaller = JBossSAMLBaseFactory.getValidatingMarshaller(pkgName,
schemaLocation);
+ JAXBElement<AuthnRequestType> jaxb =
protocolObjectFactory.createAuthnRequest(requestType);
+ marshaller.marshal(jaxb, writer);
+ }
}
\ No newline at end of file
Modified:
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLAuthnResponseFactory.java
===================================================================
---
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLAuthnResponseFactory.java 2008-12-11
15:29:24 UTC (rev 147)
+++
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLAuthnResponseFactory.java 2008-12-11
17:33:57 UTC (rev 148)
@@ -23,6 +23,7 @@
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.Writer;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
@@ -54,6 +55,11 @@
private static ObjectFactory protocolObjectFactory = new ObjectFactory();
+ /**
+ * Create a StatusType given the status code uri
+ * @param statusCodeURI
+ * @return
+ */
public static StatusType createStatusType(String statusCodeURI)
{
StatusCodeType sct = protocolObjectFactory.createStatusCodeType();
@@ -64,6 +70,15 @@
return statusType;
}
+ /**
+ * Create a ResponseType
+ * @param ID id of the response
+ * @param sp holder with the information about the Service Provider
+ * @param idp holder with the information on the Identity Provider
+ * @param issuerInfo holder with information on the issuer
+ * @return
+ * @throws Exception
+ */
public static ResponseType createResponseType(String ID, SPInfoHolder sp,
IDPInfoHolder idp, IssuerInfoHolder issuerInfo) throws Exception
{
ResponseType responseType = protocolObjectFactory.createResponseType();
@@ -131,6 +146,12 @@
return responseType;
}
+ /**
+ * Read a ResponseType from an input stream
+ * @param is
+ * @return
+ * @throws Exception
+ */
@SuppressWarnings("unchecked")
public static ResponseType getResponseType(InputStream is) throws Exception
{
@@ -158,4 +179,17 @@
JAXBElement<ResponseType> jaxb =
protocolObjectFactory.createResponse(responseType);
marshaller.marshal(jaxb, os);
}
+
+ /**
+ * Marshall the ResponseType into a writer
+ * @param responseType
+ * @param writer
+ * @throws Exception
+ */
+ public static void marshall(ResponseType responseType, Writer writer) throws
Exception
+ {
+ Marshaller marshaller = JBossSAMLBaseFactory.getValidatingMarshaller(pkgName,
schemaLocation);
+ JAXBElement<ResponseType> jaxb =
protocolObjectFactory.createResponse(responseType);
+ marshaller.marshal(jaxb, writer);
+ }
}
\ No newline at end of file
Show replies by date