[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/marshal/encryption ...

Anil Saldhana anil.saldhana at jboss.com
Fri Aug 25 17:09:03 EDT 2006


  User: asaldhana
  Date: 06/08/25 17:09:03

  Modified:    src/main/org/jboss/remoting/marshal/encryption  
                        EncryptionManager.java
  Added:       src/main/org/jboss/remoting/marshal/encryption  
                        EncryptionUtil.java
  Log:
  JBREM-419: Enc.Util to seal/unseal objects
  
  Revision  Changes    Path
  1.5       +15 -8     JBossRemoting/src/main/org/jboss/remoting/marshal/encryption/EncryptionManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: EncryptionManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/marshal/encryption/EncryptionManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- EncryptionManager.java	18 Aug 2006 13:37:39 -0000	1.4
  +++ EncryptionManager.java	25 Aug 2006 21:09:03 -0000	1.5
  @@ -32,7 +32,7 @@
   import java.security.Key;
   import java.util.Map;
   
  -//$Id: EncryptionManager.java,v 1.4 2006/08/18 13:37:39 telrod Exp $
  +//$Id: EncryptionManager.java,v 1.5 2006/08/25 21:09:03 asaldhana Exp $
   
   /**
    *  Manager that deals with the generation of the Cipher
  @@ -48,7 +48,7 @@
                          version 1.5, Nov 1993.
    *  @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
    *  @since  Aug 11, 2006
  - *  @version $Revision: 1.4 $
  + *  @version $Revision: 1.5 $
    */
   public class EncryptionManager
   {
  @@ -69,18 +69,25 @@
   
      private static IvParameterSpec iv16 = new IvParameterSpec(salt16);
   
  -   public static final String DEFAULT_CIPHER_ALGORITHM = "DES";
  +   
  +   public static final String TRIPLEDES = "DESede";
  +   public static final String DES = "DES";
  +   public static final String AES = "AES";
  +   public static final String BLOWFISH = "Blowfish";
  +   public static final String RC4 = "RC4"; 
  +
  +   public static final String DEFAULT_CIPHER_ALGORITHM = DES;
   
      static
      {
         //Generate Keys for the common algorithms
         try
         {
  -         keys.put("AES", loadKey("AES"));
  -         keys.put("DES", loadKey("DES"));
  -         keys.put("DESede", loadKey("DESede"));
  -         keys.put("Blowfish", loadKey("Blowfish"));
  -         keys.put("RC4", loadKey("RC4"));
  +         keys.put("AES", loadKey(AES));
  +         keys.put("DES", loadKey(DES));
  +         keys.put("DESede", loadKey(TRIPLEDES));
  +         keys.put("Blowfish", loadKey(BLOWFISH));
  +         keys.put("RC4", loadKey(RC4));
         }
         catch (Exception e)
         {
  
  
  
  1.1      date: 2006/08/25 21:09:03;  author: asaldhana;  state: Exp;JBossRemoting/src/main/org/jboss/remoting/marshal/encryption/EncryptionUtil.java
  
  Index: EncryptionUtil.java
  ===================================================================
  /*
    * JBoss, Home of Professional Open Source
    * Copyright 2005, JBoss Inc., and individual contributors as indicated
    * by the @authors tag. See the copyright.txt in the distribution for a
    * full listing of individual contributors.
    *
    * This is free software; you can redistribute it and/or modify it
    * under the terms of the GNU Lesser General Public License as
    * published by the Free Software Foundation; either version 2.1 of
    * the License, or (at your option) any later version.
    *
    * This software is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    * Lesser General Public License for more details.
    *
    * You should have received a copy of the GNU Lesser General Public
    * License along with this software; if not, write to the Free
    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
    */
  package org.jboss.remoting.marshal.encryption;
  
  import java.io.Serializable;
  
  import javax.crypto.Cipher;
  import javax.crypto.SealedObject;
  
  //$Id: EncryptionUtil.java,v 1.1 2006/08/25 21:09:03 asaldhana Exp $
  
  /**
   *  Utility for Encryption Needs
   *  @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
   *  @since  Aug 25, 2006 
   *  @version $Revision: 1.1 $
   */
  public class EncryptionUtil
  {
     private static String algo = EncryptionManager.TRIPLEDES;
     
     public static Serializable unsealObject(SealedObject so)
     throws Exception
     {
        Cipher ci = EncryptionManager.getCipher(Cipher.DECRYPT_MODE, algo);
        Serializable ser = (Serializable)so.getObject(ci);
        return ser; 
     }
     
     public static SealedObject sealObject(Serializable ser)
     throws Exception
     {
        Cipher ci = EncryptionManager.getCipher(Cipher.ENCRYPT_MODE, algo);
        return new SealedObject(ser,ci); 
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list