You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by be...@apache.org on 2008/08/18 01:05:38 UTC

svn commit: r686658 - in /incubator/shindig/trunk/java/common/src: main/java/org/apache/shindig/common/crypto/BasicBlobCrypter.java test/java/org/apache/shindig/common/crypto/BlobCrypterTest.java

Author: beaton
Date: Sun Aug 17 16:05:37 2008
New Revision: 686658

URL: http://svn.apache.org/viewvc?rev=686658&view=rev
Log:
"Refactoring" managed to break both build and code.  I am clearly in 
fine form today.


Modified:
    incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/crypto/BasicBlobCrypter.java
    incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/crypto/BlobCrypterTest.java

Modified: incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/crypto/BasicBlobCrypter.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/crypto/BasicBlobCrypter.java?rev=686658&r1=686657&r2=686658&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/crypto/BasicBlobCrypter.java (original)
+++ incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/crypto/BasicBlobCrypter.java Sun Aug 17 16:05:37 2008
@@ -151,6 +151,8 @@
       throw new BlobCrypterException("Invalid token signature", e);
     } catch (ArrayIndexOutOfBoundsException e) {
       throw new BlobCrypterException("Invalid token format", e);
+    } catch (NegativeArraySizeException e) {
+      throw new BlobCrypterException("Invalid token format", e);
     } catch (UnsupportedEncodingException e) {
       throw new BlobCrypterException(e);
     }

Modified: incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/crypto/BlobCrypterTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/crypto/BlobCrypterTest.java?rev=686658&r1=686657&r2=686658&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/crypto/BlobCrypterTest.java (original)
+++ incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/crypto/BlobCrypterTest.java Sun Aug 17 16:05:37 2008
@@ -69,6 +69,24 @@
     Map<String, String> out = crypter.unwrap(blob, 0);
     assertEquals(string, out.get("a"));
   }
+  
+  @Test
+  public void testDecryptGarbage() throws Exception {
+    StringBuilder sb = new StringBuilder();
+    for (int i=0; i < 100; ++i) {
+      assertThrowsBlobCrypterException(sb.toString());
+      sb.append("a");
+    }
+  }
+  
+  private void assertThrowsBlobCrypterException(String in) {
+    try {
+      crypter.unwrap(in, 1000);
+      fail("Should have thrown BlobCrypterException for input " + in);
+    } catch (BlobCrypterException e) {
+      // Good.
+    }
+  }
 
   @Test
   public void testManyEntries() throws Exception {