Author: anil.saldhana(a)jboss.com
Date: 2009-06-03 10:09:21 -0400 (Wed, 03 Jun 2009)
New Revision: 566
Added:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/AssertionUtil.java
Log:
JBID-125: assertion util
Added:
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/AssertionUtil.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/AssertionUtil.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/util/AssertionUtil.java 2009-06-03
14:09:21 UTC (rev 566)
@@ -0,0 +1,62 @@
+/*
+ * 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.util;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+
+import org.jboss.identity.federation.core.exceptions.ConfigurationException;
+import org.jboss.identity.federation.saml.v2.assertion.AssertionType;
+import org.jboss.identity.federation.saml.v2.assertion.ConditionsType;
+
+/**
+ * Utility to deal with assertions
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jun 3, 2009
+ */
+public class AssertionUtil
+{
+ /**
+ * Check whether the assertion has expired
+ * @param assertion
+ * @return
+ * @throws ConfigurationException
+ */
+ public static boolean hasExpired(AssertionType assertion) throws
ConfigurationException
+ {
+ //Check for validity of assertion
+ ConditionsType conditionsType = assertion.getConditions();
+ if(conditionsType != null)
+ {
+ try
+ {
+ return XMLTimeUtil.isValid(XMLTimeUtil.getIssueInstant(),
+ conditionsType.getNotBefore(), conditionsType.getNotOnOrAfter());
+ }
+ catch (DatatypeConfigurationException e)
+ {
+ throw new ConfigurationException(e);
+ }
+ }
+ //TODO: if conditions do not exist, assume the assertion to be everlasting?
+ return true;
+ }
+}
\ No newline at end of file