Author: anil.saldhana(a)jboss.com
Date: 2009-01-06 20:51:41 -0500 (Tue, 06 Jan 2009)
New Revision: 190
Added:
identity-federation/trunk/identity-fed-core/src/test/java/org/
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/test/
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/test/identity/
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/test/identity/federation/
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/test/identity/federation/core/
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/test/identity/federation/core/util/
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/test/identity/federation/core/util/XMLTimeUtilUnitTestCase.java
Modified:
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/holders/IDPInfoHolder.java
Log:
util for xml time test
Modified:
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/holders/IDPInfoHolder.java
===================================================================
---
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/holders/IDPInfoHolder.java 2009-01-07
01:51:05 UTC (rev 189)
+++
identity-federation/trunk/identity-fed-core/src/main/java/org/jboss/identity/federation/core/saml/v2/holders/IDPInfoHolder.java 2009-01-07
01:51:41 UTC (rev 190)
@@ -36,6 +36,18 @@
private String nameIDFormat = JBossSAMLURIConstants.NAMEID_FORMAT_TRANSIENT.get();
private String nameIDFormatValue;
+ private int assertionValidityDuration = 5; //5 Minutes
+
+ public int getAssertionValidityDuration()
+ {
+ return assertionValidityDuration;
+ }
+
+ public void setAssertionValidityDuration(int assertionValidityDuration)
+ {
+ this.assertionValidityDuration = assertionValidityDuration;
+ }
+
public String getSubjectConfirmationMethod()
{
return subjectConfirmationMethod;
Added:
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/test/identity/federation/core/util/XMLTimeUtilUnitTestCase.java
===================================================================
---
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/test/identity/federation/core/util/XMLTimeUtilUnitTestCase.java
(rev 0)
+++
identity-federation/trunk/identity-fed-core/src/test/java/org/jboss/test/identity/federation/core/util/XMLTimeUtilUnitTestCase.java 2009-01-07
01:51:41 UTC (rev 190)
@@ -0,0 +1,70 @@
+/*
+ * 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.test.identity.federation.core.util;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.jboss.identity.federation.core.saml.v2.util.XMLTimeUtil;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit Test the XML Time Util
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jan 6, 2009
+ */
+public class XMLTimeUtilUnitTestCase extends TestCase
+{
+ public void testAdd() throws Exception
+ {
+ XMLGregorianCalendar now = XMLTimeUtil.getIssueInstant();
+ long min5 = XMLTimeUtil.inMilis(5);
+
+ XMLGregorianCalendar after5M = XMLTimeUtil.add(now, min5);
+ assertTrue(now.compare(after5M) == DatatypeConstants.LESSER);
+
+ GregorianCalendar nowG = now.toGregorianCalendar();
+ GregorianCalendar now5M = after5M.toGregorianCalendar();
+
+ //Add 5 minutes
+ nowG.roll(Calendar.MINUTE, 5);
+
+ assertTrue(nowG.compareTo(now5M) == 0);
+ }
+
+ public void testIsValid() throws Exception
+ {
+ XMLGregorianCalendar now = XMLTimeUtil.getIssueInstant();
+
+ long milisFor5Mins = XMLTimeUtil.inMilis(5);
+
+ XMLGregorianCalendar after5M = XMLTimeUtil.add(now, milisFor5Mins);
+ XMLGregorianCalendar after10M = XMLTimeUtil.add(now, milisFor5Mins * 2);
+
+ //isValid(now, notbefore, notOnOrAfter)
+ assertTrue(XMLTimeUtil.isValid(after5M, now, after10M));
+ }
+}
\ No newline at end of file