[jboss-cvs] JBossAS SVN: r95963 - projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Nov 3 11:19:45 EST 2009


Author: alesj
Date: 2009-11-03 11:19:44 -0500 (Tue, 03 Nov 2009)
New Revision: 95963

Modified:
   projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/Tools.java
Log:
Simplify tool.

Modified: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/Tools.java
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/Tools.java	2009-11-03 16:17:50 UTC (rev 95962)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/Tools.java	2009-11-03 16:19:44 UTC (rev 95963)
@@ -25,23 +25,14 @@
 import java.security.Key;
 import java.util.Arrays;
 
-import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFS;
 
 /**
  * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
  */
 public class Tools
 {
-   private File jarToCrypt;
-   private Key key;
-
-   public Tools(File jarToCrypt, Key key)
-   {
-      this.jarToCrypt = jarToCrypt;
-      this.key = key;
-   }
-
    public static void main(String[] args)
    {
       if (args == null || args.length < 2)
@@ -54,30 +45,26 @@
       try
       {
          File keystore = new File(args[1]);
+
          KeyProvider keyProvider = KeyProviderFactory.createKeyProvider(keystore);
          if (keystore.exists() == false)
             keyProvider.writeKeys();
 
          Key key = keyProvider.getEncryptionKey();
-         Tools tools = new Tools(archive, key);
-         tools.crypt();
+         Crypter crypter = CipherCrypter.getEncrypter(key);
+
+         VirtualFile root = VFS.getRoot(archive.toURI());
+         CryptVisitor visitor = new CryptVisitor(root, crypter);
+         File file = visitor.getFile();
+         File copy = new File(archive.getParentFile(), file.getName());
+         if (file.renameTo(copy) == false)
+         {
+            System.err.println("Cannot move file: " + copy);
+         }
       }
       catch (Exception e)
       {
          e.printStackTrace();
       }
    }
-
-   public void crypt() throws Exception
-   {
-      VirtualFile root = VFS.getRoot(jarToCrypt.toURI());
-      Crypter crypter = CipherCrypter.getEncrypter(key);
-      CryptVisitor visitor = new CryptVisitor(root, crypter);
-      File file = visitor.getFile();
-      File copy = new File(jarToCrypt.getParentFile(), file.getName());
-      if (file.renameTo(copy) == false)
-      {
-         System.err.println("Cannot move file: " + copy);
-      }
-   }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list