Permalink
Browse files

clean up blowfish code - formatting and include exception cause

  • Loading branch information...
1 parent 0267c00 commit 141aad4ba84e6d52884c3bf2524f915a14929522 @nathanmarz committed Feb 18, 2013
Showing with 26 additions and 26 deletions.
  1. +26 −26 src/jvm/backtype/storm/security/serialization/BlowfishTupleSerializer.java
@@ -30,45 +30,45 @@
private BlowfishSerializer _serializer;
public BlowfishTupleSerializer(Kryo kryo, Map storm_conf) {
- String encryption_key = null;
- try {
- encryption_key = (String)storm_conf.get(SECRET_KEY);
- LOG.debug("Blowfish serializer being constructed ...");
- if (encryption_key == null) {
- LOG.error("Encryption key not specified");
- throw new RuntimeException("Blowfish encryption key not specified");
- }
- byte[] bytes = Hex.decodeHex(encryption_key.toCharArray());
- _serializer = new BlowfishSerializer(new ListDelegateSerializer(), bytes);
- } catch (org.apache.commons.codec.DecoderException ex) {
- LOG.error("Invalid encryption key");
- throw new RuntimeException("Blowfish encryption key invalid");
- }
+ String encryption_key = null;
+ try {
+ encryption_key = (String)storm_conf.get(SECRET_KEY);
+ LOG.debug("Blowfish serializer being constructed ...");
+ if (encryption_key == null) {
+ LOG.error("Encryption key not specified");
+ throw new RuntimeException("Blowfish encryption key not specified");
+ }
+ byte[] bytes = Hex.decodeHex(encryption_key.toCharArray());
+ _serializer = new BlowfishSerializer(new ListDelegateSerializer(), bytes);
+ } catch (org.apache.commons.codec.DecoderException ex) {
+ LOG.error("Invalid encryption key", ex);
+ throw new RuntimeException("Blowfish encryption key invalid", ex);
+ }
}
@Override
public void write(Kryo kryo, Output output, ListDelegate object) {
- _serializer.write(kryo, output, object);
+ _serializer.write(kryo, output, object);
}
@Override
public ListDelegate read(Kryo kryo, Input input, Class<ListDelegate> type) {
- return (ListDelegate)_serializer.read(kryo, input, type);
+ return (ListDelegate)_serializer.read(kryo, input, type);
}
/**
* Produce a blowfish key to be used in "Storm jar" command
*/
public static void main(String[] args) {
- try{
- KeyGenerator kgen = KeyGenerator.getInstance("Blowfish");
- SecretKey skey = kgen.generateKey();
- byte[] raw = skey.getEncoded();
- String keyString = new String(Hex.encodeHex(raw));
- System.out.println("storm -c "+SECRET_KEY+"="+keyString+" -c "+Config.TOPOLOGY_TUPLE_SERIALIZER+"="+BlowfishTupleSerializer.class.getName() + " ..." );
- } catch (Exception ex) {
- LOG.error(ex.getMessage());
- ex.printStackTrace();
- }
+ try{
+ KeyGenerator kgen = KeyGenerator.getInstance("Blowfish");
+ SecretKey skey = kgen.generateKey();
+ byte[] raw = skey.getEncoded();
+ String keyString = new String(Hex.encodeHex(raw));
+ System.out.println("storm -c "+SECRET_KEY+"="+keyString+" -c "+Config.TOPOLOGY_TUPLE_SERIALIZER+"="+BlowfishTupleSerializer.class.getName() + " ..." );
+ } catch (Exception ex) {
+ LOG.error(ex.getMessage());
+ ex.printStackTrace();
+ }
}
}

0 comments on commit 141aad4

Please sign in to comment.