JBoss Identity SVN: r154 - in identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2: exceptions and 1 other directories.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2008-12-12 17:37:07 -0500 (Fri, 12 Dec 2008)
New Revision: 154
Added:
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/exceptions/
identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/exceptions/AssertionExpiredException.java
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/JBossSAMLBaseFactory.java
Log:
new stuff
Added: identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/exceptions/AssertionExpiredException.java
===================================================================
--- identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/exceptions/AssertionExpiredException.java (rev 0)
+++ identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/exceptions/AssertionExpiredException.java 2008-12-12 22:37:07 UTC (rev 154)
@@ -0,0 +1,52 @@
+/*
+ * 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.api.saml.v2.exceptions;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * Security Exception indicating expiration of SAML2 assertion
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Dec 12, 2008
+ */
+public class AssertionExpiredException extends GeneralSecurityException
+{
+ private static final long serialVersionUID = 1L;
+
+ public AssertionExpiredException()
+ {
+ }
+
+ public AssertionExpiredException(String message, Throwable cause)
+ {
+ }
+
+ public AssertionExpiredException(String msg)
+ {
+ super(msg);
+ }
+
+ public AssertionExpiredException(Throwable cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
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-12 22:34:12 UTC (rev 153)
+++ identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLAuthnRequestFactory.java 2008-12-12 22:37:07 UTC (rev 154)
@@ -66,7 +66,7 @@
* @throws Exception
*/
public static AuthnRequestType createAuthnRequestType(String id,
- String assertionConsumerURL, String issuerValue) throws Exception
+ String assertionConsumerURL, String destination, String issuerValue) throws Exception
{
XMLGregorianCalendar issueInstant = JBossSAMLBaseFactory.getIssueInstant();
@@ -74,6 +74,7 @@
authnRequest.setID(id);
authnRequest.setVersion(JBossSAMLConstants.VERSION_2_0.get());
authnRequest.setAssertionConsumerServiceURL(assertionConsumerURL);
+ authnRequest.setDestination(destination);
authnRequest.setIssueInstant(issueInstant);
//Create an issuer
Modified: identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLBaseFactory.java
===================================================================
--- identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLBaseFactory.java 2008-12-12 22:34:12 UTC (rev 153)
+++ identity-federation/trunk/identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/factories/JBossSAMLBaseFactory.java 2008-12-12 22:37:07 UTC (rev 154)
@@ -36,11 +36,14 @@
import javax.xml.validation.SchemaFactory;
import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
+import org.jboss.identity.federation.saml.v2.assertion.AttributeStatementType;
+import org.jboss.identity.federation.saml.v2.assertion.AttributeType;
import org.jboss.identity.federation.saml.v2.assertion.NameIDType;
import org.jboss.identity.federation.saml.v2.assertion.ObjectFactory;
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.jboss.JBossSAMLURIConstants;
/**
* Base methods for the factories
@@ -56,6 +59,42 @@
return assertionObjectFactory.createAssertionType();
}
+ public static AttributeStatementType createAttributeStatement()
+ {
+ return assertionObjectFactory.createAttributeStatementType();
+ }
+
+ public static AttributeType createAttribute(String attributeValue)
+ {
+ AttributeType att = assertionObjectFactory.createAttributeType();
+ JAXBElement<Object> attValue = assertionObjectFactory.createAttributeValue(attributeValue);
+ att.getAttributeValue().add(attValue);
+ return att;
+ }
+
+ public static AttributeType createAttributeForRole(String roleName)
+ {
+ AttributeType att = assertionObjectFactory.createAttributeType();
+ att.setFriendlyName("role");
+ att.setName("role");
+ att.setNameFormat(JBossSAMLURIConstants.ATTRIBUTE_FORMAT_BASIC.get());
+
+ //rolename
+ att.getAttributeValue().add(roleName);
+
+ return att;
+ }
+
+ public static AttributeStatementType createAttributeStatement(String attributeValue)
+ {
+ AttributeStatementType attribStatement = assertionObjectFactory.createAttributeStatementType();
+ AttributeType att = assertionObjectFactory.createAttributeType();
+ JAXBElement<Object> attValue = assertionObjectFactory.createAttributeValue(attributeValue);
+ att.getAttributeValue().add(attValue);
+ attribStatement.getAttributeOrEncryptedAttribute().add(att);
+ return attribStatement;
+ }
+
public static NameIDType createNameID()
{
return assertionObjectFactory.createNameIDType();
@@ -160,6 +199,7 @@
JAXBContext jc = JAXBContext.newInstance(pkgName);
Marshaller marshaller = jc.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
//Validate against schema
ClassLoader tcl = SecurityActions.getContextClassLoader();
URL schemaURL = tcl.getResource(schemaLocation);
@@ -187,7 +227,7 @@
throw new IllegalArgumentException("pkgName is null");
JAXBContext jc = JAXBContext.newInstance(pkgName);
- Unmarshaller unmarshaller = jc.createUnmarshaller();
+ Unmarshaller unmarshaller = jc.createUnmarshaller();
//Validate against schema
ClassLoader tcl = SecurityActions.getContextClassLoader();
URL schemaURL = tcl.getResource(schemaLocation);