Author: lindner
Date: Mon Dec  8 15:05:53 2008
New Revision: 724545

URL: http://svn.apache.org/viewvc?rev=724545&view=rev
Log:
Merge from trunk 724510:724522 
SHINDIG-772 | patch from Henning Schmiedehausen | unneccessary 
backport-concurrent references in shindig code
SHINDIG-669 | Add an encryptWithIV helper method from Rodrigo Gallardo
SHINDIG-767 | Patch from Ben Smith - PropertiesModule should be able to 
property files other than the default


Modified:
    incubator/shindig/branches/1.0.x-incubating/   (props changed)
    
incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/PropertiesModule.java
    
incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/crypto/Crypto.java
    
incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java
    
incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/test/java/org/apache/shindig/gadgets/GadgetFeatureRegistryTest.java

Propchange: incubator/shindig/branches/1.0.x-incubating/
------------------------------------------------------------------------------
    svn:mergeinfo = /incubator/shindig/trunk:724511-724522

Modified: 
incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/PropertiesModule.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/PropertiesModule.java?rev=724545&r1=724544&r2=724545&view=diff
==============================================================================
--- 
incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/PropertiesModule.java
 (original)
+++ 
incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/PropertiesModule.java
 Mon Dec  8 15:05:53 2008
@@ -32,7 +32,8 @@
 import java.util.Properties;
 
 /**
- * Injects everything from the shindig.properties as a Named value.
+ * Injects everything from the a property file as a Named value
+ * Uses the default shindig.properties file if no other is provided
  */
 public class PropertiesModule extends AbstractModule {
 
@@ -41,14 +42,31 @@
   private final Properties properties;
   
   public PropertiesModule() {
+    this.properties = readPropertyFile(DEFAULT_PROPERTIES);
+  }
+
+  public PropertiesModule(String propertyFile) {
+    this.properties = readPropertyFile(propertyFile);
+  }
+  
+  public PropertiesModule(Properties properties) {
+    this.properties = properties;
+  }
+
+  @Override
+  protected void configure() {
+    Names.bindProperties(this.binder(), properties);
+  }
+  
+  private Properties readPropertyFile(String propertyFile) {
+    Properties properties = new Properties();
     InputStream is = null;
     try {
-      is = ResourceLoader.openResource(DEFAULT_PROPERTIES);
-      properties = new Properties();
+      is = ResourceLoader.openResource(propertyFile);
       properties.load(is);
     } catch (IOException e) {
       throw new CreationException(Arrays.asList(
-          new Message("Unable to load properties: " + DEFAULT_PROPERTIES)));
+          new Message("Unable to load properties: " + propertyFile)));
     } finally {
       try {
         if (is != null) {
@@ -58,15 +76,8 @@
         // weird
       }
     }
-  }
-  
-  public PropertiesModule(Properties properties) {
-    this.properties = properties;
-  }
-
-  @Override
-  protected void configure() {
-    Names.bindProperties(this.binder(), properties);
+    
+    return properties;
   }
 
 }

Modified: 
incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/crypto/Crypto.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/crypto/Crypto.java?rev=724545&r1=724544&r2=724545&view=diff
==============================================================================
--- 
incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/crypto/Crypto.java
 (original)
+++ 
incubator/shindig/branches/1.0.x-incubating/java/common/src/main/java/org/apache/shindig/common/crypto/Crypto.java
 Mon Dec  8 15:05:53 2008
@@ -154,14 +154,31 @@
   public static byte[] aes128cbcEncrypt(byte[] key, byte[] plain)
   throws GeneralSecurityException {
     Cipher cipher = Cipher.getInstance(CIPHER_TYPE);
-    Key cipherKey = new SecretKeySpec(key, CIPHER_KEY_TYPE);
     byte iv[] = getRandomBytes(cipher.getBlockSize());
+    return concat(iv, aes128cbcEncryptWithIV(key, iv, plain));
+  }
+
+  /**
+   * AES-128-CBC encryption with a given IV.
+   *
+   * @param key
+   * @param iv
+   * @param plain
+   *
+   * @return the cipher text
+   *
+   * @throws GeneralSecurityException
+   */
+  public static byte[] aes128cbcEncryptWithIV(byte[] key, byte[] iv, byte[] 
plain)
+  throws GeneralSecurityException {
+    Cipher cipher = Cipher.getInstance(CIPHER_TYPE);
+    Key cipherKey = new SecretKeySpec(key, CIPHER_KEY_TYPE);
     IvParameterSpec ivSpec = new IvParameterSpec(iv);
     cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ivSpec);
-    byte[] cipherText = cipher.doFinal(plain);
-    return concat(iv, cipherText);
+    return cipher.doFinal(plain);
   }
 
+
   /**
    * AES-128-CBC decryption.  The IV is assumed to be the first 16 bytes
    * of the cipher text.

Modified: 
incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java?rev=724545&r1=724544&r2=724545&view=diff
==============================================================================
--- 
incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java
 (original)
+++ 
incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/View.java
 Mon Dec  8 15:05:53 2008
@@ -25,7 +25,7 @@
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
 
-import edu.emory.mathcs.backport.java.util.Collections;
+import java.util.Collections;
 
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -305,4 +305,4 @@
       return "url".equals(value) ? URL : HTML;
     }
   }
-}
\ No newline at end of file
+}

Modified: 
incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/test/java/org/apache/shindig/gadgets/GadgetFeatureRegistryTest.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/test/java/org/apache/shindig/gadgets/GadgetFeatureRegistryTest.java?rev=724545&r1=724544&r2=724545&view=diff
==============================================================================
--- 
incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/test/java/org/apache/shindig/gadgets/GadgetFeatureRegistryTest.java
 (original)
+++ 
incubator/shindig/branches/1.0.x-incubating/java/gadgets/src/test/java/org/apache/shindig/gadgets/GadgetFeatureRegistryTest.java
 Mon Dec  8 15:05:53 2008
@@ -26,7 +26,7 @@
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
-import edu.emory.mathcs.backport.java.util.Collections;
+import java.util.Collections;
 
 import org.junit.Before;
 import org.junit.Test;


Reply via email to