harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r467238 - in /incubator/harmony/enhanced/classlib/trunk/modules/auth/src: main/java/common/javax/security/auth/kerberos/KerberosTicket.java test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/KerberosTicketTest.java
Date Tue, 24 Oct 2006 04:27:40 GMT
Author: smishura
Date: Mon Oct 23 21:27:39 2006
New Revision: 467238

URL: http://svn.apache.org/viewvc?view=rev&rev=467238
Log:
Fixes for KerberosTicket: getAuthTime() and getEndTime() + regression tests

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosTicket.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/KerberosTicketTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosTicket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosTicket.java?view=diff&rev=467238&r1=467237&r2=467238
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosTicket.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosTicket.java
Mon Oct 23 21:27:39 2006
@@ -158,11 +158,12 @@
         }
 
         if (startTime.getTime() > endTime.getTime()) {
+            // TODO: make correct description of the exception  
             throw new IllegalArgumentException(Messages.getString("auth.42")); //$NON-NLS-1$
         }
 
-        this.authTime = authTime;
-        this.endTime = endTime;
+        this.authTime = new Date(authTime.getTime());
+        this.endTime = new Date(endTime.getTime());
 
         if (clientAddresses != null) {
             this.clientAddresses = new InetAddress[clientAddresses.length];
@@ -245,7 +246,7 @@
 
     public final Date getAuthTime() {
         checkState();
-        return authTime;
+        return new Date(authTime.getTime());
     }
 
     public final Date getStartTime() {
@@ -255,7 +256,7 @@
 
     public final Date getEndTime() {
         checkState();
-        return endTime;
+        return new Date(endTime.getTime());
     }
 
     public final Date getRenewTill() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/KerberosTicketTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/KerberosTicketTest.java?view=diff&rev=467238&r1=467237&r2=467238
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/KerberosTicketTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/KerberosTicketTest.java
Mon Oct 23 21:27:39 2006
@@ -68,6 +68,32 @@
     }
 
     /**
+     * @tests javax.security.auth.kerberos.KerberosTicket#getAuthTime() 
+     */
+    public void test_getAuthTime() throws Exception {
+
+        KerberosTicket krbTicket = new KerberosTicket(ticket, pClient, pServer,
+                sessionKey, KEY_TYPE, flags, authTime, startTime, endTime,
+                renewTill, addesses);
+
+        assertEquals(0, krbTicket.getAuthTime().getTime());
+
+        // initial value is copied
+        assertNotSame(authTime, krbTicket.getAuthTime());
+
+        // KerberosTicket instance is immutable 
+        assertNotSame(krbTicket.getAuthTime(), krbTicket.getAuthTime());
+
+        // auth time: null value is illegal for contructor
+        try {
+            new KerberosTicket(ticket, pClient, pServer, sessionKey, KEY_TYPE,
+                    flags, null, startTime, endTime, renewTill, addesses);
+            fail("No expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+        }
+    }
+
+    /**
      * @tests javax.security.auth.kerberos.KerberosTicket#getClient() 
      */
     public void test_getClient() throws Exception {
@@ -132,6 +158,32 @@
         try {
             new KerberosTicket(null, pClient, pServer, sessionKey, KEY_TYPE,
                     flags, authTime, startTime, endTime, renewTill, addesses);
+            fail("No expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+        }
+    }
+
+    /**
+     * @tests javax.security.auth.kerberos.KerberosTicket#getEndTime() 
+     */
+    public void test_getEndTime() throws Exception {
+
+        KerberosTicket krbTicket = new KerberosTicket(ticket, pClient, pServer,
+                sessionKey, KEY_TYPE, flags, authTime, startTime, endTime,
+                renewTill, addesses);
+
+        assertEquals(2, krbTicket.getEndTime().getTime());
+
+        // initial value is copied
+        assertNotSame(endTime, krbTicket.getEndTime());
+
+        // KerberosTicket instance is immutable 
+        assertNotSame(krbTicket.getEndTime(), krbTicket.getEndTime());
+
+        // end time: null value is illegal for contructor
+        try {
+            new KerberosTicket(ticket, pClient, pServer, sessionKey, KEY_TYPE,
+                    flags, authTime, startTime, null, renewTill, addesses);
             fail("No expected IllegalArgumentException");
         } catch (IllegalArgumentException e) {
         }



Mime
View raw message