harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r469380 - 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, 31 Oct 2006 05:54:42 GMT
Author: smishura
Date: Mon Oct 30 21:54:41 2006
New Revision: 469380

URL: http://svn.apache.org/viewvc?view=rev&rev=469380
Log:
Fixes for KerberosTicket + 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=469380&r1=469379&r2=469380
==============================================================================
--- 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 30 21:54:41 2006
@@ -174,12 +174,10 @@
     }
 
     public final KerberosPrincipal getClient() {
-        checkState();
         return client;
     }
 
     public final KerberosPrincipal getServer() {
-        checkState();
         return server;
     }
 
@@ -237,7 +235,9 @@
     }
 
     public final boolean[] getFlags() {
-        checkState();
+        if (destroyed) {
+            return null;
+        }
         boolean[] tmp = new boolean[flags.length];
         System.arraycopy(flags, 0, tmp, 0, tmp.length);
         return tmp;
@@ -245,7 +245,9 @@
     }
 
     public final Date getAuthTime() {
-        checkState();
+        if (destroyed) {
+            return null;
+        }
         return new Date(authTime.getTime());
     }
 
@@ -255,17 +257,20 @@
     }
 
     public final Date getEndTime() {
-        checkState();
+        if (destroyed) {
+            return null;
+        }
         return new Date(endTime.getTime());
     }
 
     public final Date getRenewTill() {
-        checkState();
+        if (destroyed) {
+            return null;
+        }
         return renewTill;
     }
 
     public final InetAddress[] getClientAddresses() {
-        checkState();
         if (this.clientAddresses != null) {
             InetAddress[] tmp = new InetAddress[this.clientAddresses.length];
             System.arraycopy(clientAddresses, 0, tmp, 0, tmp.length);
@@ -275,22 +280,20 @@
     }
 
     public void destroy() throws DestroyFailedException {
-        if (!destroyed) {
-            Arrays.fill(this.asn1Encoding, (byte) 0);
-            this.client = null;
-            this.server = null;
-            this.sessionKey.destroy();
-            this.flags = null;
-            this.authTime = null;
-            this.startTime = null;
-            this.endTime = null;
-            this.renewTill = null;
-            this.clientAddresses = null;
-            destroyed = true;
-        } else {
-            throw new DestroyFailedException(Messages.getString("auth.43")); //$NON-NLS-1$
+        if (destroyed) {
+            return;
         }
-
+        Arrays.fill(this.asn1Encoding, (byte) 0);
+        this.client = null;
+        this.server = null;
+        this.sessionKey.destroy();
+        this.flags = null;
+        this.authTime = null;
+        this.startTime = null;
+        this.endTime = null;
+        this.renewTill = null;
+        this.clientAddresses = null;
+        destroyed = true;
     }
 
     public boolean isDestroyed() {

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=469380&r1=469379&r2=469380
==============================================================================
--- 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 30 21:54:41 2006
@@ -286,4 +286,56 @@
         assertEquals(authTime, krbTicket.getStartTime());
         assertNotSame(authTime, krbTicket.getStartTime());
     }
+    
+    /**
+     * @tests javax.security.auth.kerberos.KerberosTicket#destroy()
+     * @tests javax.security.auth.kerberos.KerberosTicket#isDestroyed()
+     */
+    public void test_Destroyable() throws Exception {
+
+        KerberosTicket kt = new KerberosTicket(ticket, pClient, pServer,
+                sessionKey, KEY_TYPE, flags, authTime, startTime, endTime,
+                renewTill, addesses);
+
+        assertFalse(kt.isDestroyed());
+
+        kt.destroy();
+        assertTrue(kt.isDestroyed());
+
+        // no exceptions for second destroy
+        kt.destroy();
+
+        assertNull(kt.getAuthTime());
+        assertNull(kt.getClient());
+        assertNull(kt.getClientAddresses());
+
+        try {
+            kt.getEncoded();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+
+        assertNull(kt.getEndTime());
+        assertNull(kt.getFlags());
+        assertNull(kt.getRenewTill());
+        assertNull(kt.getServer());
+
+        try {
+            kt.getSessionKey();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            kt.getSessionKeyType();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            kt.toString();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+    }
 }



Mime
View raw message