harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r400069 - in /incubator/harmony/enhanced/classlib/trunk/modules/auth/src: main/java/common/javax/security/auth/kerberos/KerberosKey.java test/java/common/javax/security/auth/kerberos/KerberosKeyTest.java
Date Fri, 05 May 2006 13:02:57 GMT
Author: smishura
Date: Fri May  5 06:02:55 2006
New Revision: 400069

URL: http://svn.apache.org/viewcvs?rev=400069&view=rev
Log:
Adding regression test for KerberosKey.destroy()

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosKey.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosKeyTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosKey.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosKey.java?rev=400069&r1=400068&r2=400069&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosKey.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosKey.java
Fri May  5 06:02:55 2006
@@ -210,8 +210,9 @@
         }
 
         keyType = 3; // DES algorithm
-
-        //FIXME: implement grenerating key from password 
+        keyBytes = new byte[8];
+        
+        //FIXME: implement key generation from password 
     }
     
     /**
@@ -305,6 +306,10 @@
 
    // TODO: write a object to a stream
    private void writeObject(ObjectOutputStream s) throws IOException {
+       
+       if(destroyed){
+           throw new IOException("Key was destroyed");
+       }
        s.defaultWriteObject();
    }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosKeyTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosKeyTest.java?rev=400069&r1=400068&r2=400069&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosKeyTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosKeyTest.java
Fri May  5 06:02:55 2006
@@ -16,6 +16,9 @@
 
 package javax.security.auth.kerberos;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
 import java.util.Arrays;
 
 import junit.framework.TestCase;
@@ -116,6 +119,74 @@
         // bytes are copied each time we invoke the method
         assertNotSame("keyBytes immutability 1 ", keyBytes, keyBytes1);
         assertNotSame("keyBytes immutability 2 ", keyBytes1, key.getEncoded());
+    }
+
+    /**
+     * @tests javax.security.auth.kerberos.KerberosKey#destroy()
+     */
+    public void test_destroy() throws Exception {
+
+        KerberosKey key = new KerberosKey(principal, new char[10], "DES");
+
+        assertFalse("not destroyed", key.isDestroyed());
+        
+        key.destroy();
+        assertTrue("destroyed", key.isDestroyed());
+
+        // no exceptions for second destroy() call
+        key.destroy();
+
+        // check that IllegalStateException is thrown for certain methods
+        try {
+            key.getAlgorithm();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            key.getEncoded();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            key.getFormat();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            key.getKeyType();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            key.getPrincipal();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            key.getVersionNumber();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            // but for serialization IOException is expected
+            ObjectOutputStream out = new ObjectOutputStream(
+                    new ByteArrayOutputStream());
+            out.writeObject(key);
+            fail("No expected IOException");
+        } catch (IOException e) {
+        }
+
+        try {
+            key.toString();
+            fail("No expected IllegalStateException");
+        } catch (IllegalStateException e) {
+        }
     }
 
     public static void main(String[] args) {



Mime
View raw message