[jboss-cvs] JBossAS SVN: r95974 - in projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader: deployers and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 3 13:29:51 EST 2009
Author: alesj
Date: 2009-11-03 13:29:50 -0500 (Tue, 03 Nov 2009)
New Revision: 95974
Added:
projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterClassLoaderPolicy.java
projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterURLStreamHandler.java
Removed:
projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherClassLoaderPolicy.java
projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherURLStreamHandler.java
Modified:
projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/CipherCrypter.java
projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/Crypter.java
projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/deployers/DecrypterClassLoaderPolicyModule.java
Log:
Remove Cipher hack.
Modified: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/CipherCrypter.java
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/CipherCrypter.java 2009-11-03 17:57:12 UTC (rev 95973)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/CipherCrypter.java 2009-11-03 18:29:50 UTC (rev 95974)
@@ -24,8 +24,10 @@
import java.security.Key;
import java.security.PrivateKey;
import java.security.PublicKey;
+import java.io.InputStream;
import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
/**
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
@@ -69,11 +71,6 @@
cipher.init(mode, key);
}
- public Cipher getCipher()
- {
- return cipher;
- }
-
public static Encrypter getEncrypter(Key key) throws Exception
{
return new CipherCrypter(null, Cipher.ENCRYPT_MODE, key);
@@ -99,6 +96,11 @@
return cipher.doFinal(bytes);
}
+ public InputStream crypt(InputStream stream)
+ {
+ return new CipherInputStream(stream, cipher);
+ }
+
public byte[] encrypt(byte[] bytes) throws Exception
{
return crypt(bytes);
Modified: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/Crypter.java
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/Crypter.java 2009-11-03 17:57:12 UTC (rev 95973)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/Crypter.java 2009-11-03 18:29:50 UTC (rev 95974)
@@ -21,6 +21,8 @@
*/
package org.jboss.demos.classloader.crypt;
+import java.io.InputStream;
+
/**
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
@@ -29,4 +31,6 @@
public static final String ALGORITHM = "AES";
byte[] crypt(byte[] bytes) throws Exception;
+
+ InputStream crypt(InputStream stream);
}
Modified: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/deployers/DecrypterClassLoaderPolicyModule.java
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/deployers/DecrypterClassLoaderPolicyModule.java 2009-11-03 17:57:12 UTC (rev 95973)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/deployers/DecrypterClassLoaderPolicyModule.java 2009-11-03 18:29:50 UTC (rev 95974)
@@ -24,12 +24,9 @@
import java.util.List;
import java.util.Set;
-import javax.crypto.Cipher;
-
import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
-import org.jboss.demos.classloader.crypt.CipherCrypter;
import org.jboss.demos.classloader.crypt.Decrypter;
-import org.jboss.demos.classloader.policy.CipherClassLoaderPolicy;
+import org.jboss.demos.classloader.policy.CrypterClassLoaderPolicy;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderClassPathDeployer;
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
@@ -71,8 +68,7 @@
@Override
protected VFSClassLoaderPolicy determinePolicy()
{
- Cipher cipher = CipherCrypter.class.cast(decrypter).getCipher(); // hack to get cipher
- CipherClassLoaderPolicy policy = new CipherClassLoaderPolicy(getContextName(), vfsRoots, excludedRoots, cipher);
+ CrypterClassLoaderPolicy policy = new CrypterClassLoaderPolicy(getContextName(), vfsRoots, excludedRoots, decrypter);
String[] packageNames = getPackageNames();
policy.setExportedPackages(packageNames);
policy.setIncluded(getIncluded());
Deleted: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherClassLoaderPolicy.java
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherClassLoaderPolicy.java 2009-11-03 17:57:12 UTC (rev 95973)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherClassLoaderPolicy.java 2009-11-03 18:29:50 UTC (rev 95974)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.demos.classloader.policy;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.crypto.Cipher;
-import javax.crypto.CipherInputStream;
-
-import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class CipherClassLoaderPolicy extends VFSClassLoaderPolicy
-{
- private Cipher cipher;
-
- public CipherClassLoaderPolicy(String name, VirtualFile[] roots, VirtualFile[] excludedRoots, Cipher cipher)
- {
- super(name, roots, excludedRoots);
- this.cipher = cipher;
- }
-
- @Override
- public URL getResource(String path)
- {
- try
- {
- URL resource = super.getResource(path);
- return wrap(resource);
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public InputStream getResourceAsStream(String path)
- {
- InputStream stream = super.getResourceAsStream(path);
- return new CipherInputStream(stream, cipher);
- }
-
- @Override
- public void getResources(String name, Set<URL> urls) throws IOException
- {
- super.getResources(name, urls);
- Set<URL> temp = new HashSet<URL>(urls.size());
- for (URL url : urls)
- {
- temp.add(wrap(url));
- }
- urls.clear();
- urls.addAll(temp);
- }
-
- protected URL wrap(URL url) throws IOException
- {
- return new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile(), new CipherURLStreamHandler(cipher));
- }
-}
Deleted: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherURLStreamHandler.java
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherURLStreamHandler.java 2009-11-03 17:57:12 UTC (rev 95973)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherURLStreamHandler.java 2009-11-03 18:29:50 UTC (rev 95974)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.demos.classloader.policy;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-
-import javax.crypto.Cipher;
-import javax.crypto.CipherInputStream;
-
-import org.jboss.net.protocol.DelegatingURLConnection;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class CipherURLStreamHandler extends URLStreamHandler
-{
- private Cipher cipher;
-
- public CipherURLStreamHandler(Cipher cipher)
- {
- this.cipher = cipher;
- }
-
- protected URLConnection openConnection(URL url) throws IOException
- {
- return new CipherURLConnection(url);
- }
-
- private class CipherURLConnection extends DelegatingURLConnection
- {
- private CipherURLConnection(URL url) throws IOException
- {
- super(url);
- }
-
- @Override
- public InputStream getInputStream() throws IOException
- {
- InputStream inputStream = super.getInputStream();
- return new CipherInputStream(inputStream, cipher);
- }
- }
-}
\ No newline at end of file
Copied: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterClassLoaderPolicy.java (from rev 95970, projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherClassLoaderPolicy.java)
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterClassLoaderPolicy.java (rev 0)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterClassLoaderPolicy.java 2009-11-03 18:29:50 UTC (rev 95974)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.demos.classloader.policy;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
+import org.jboss.demos.classloader.crypt.Crypter;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class CrypterClassLoaderPolicy extends VFSClassLoaderPolicy
+{
+ private Crypter crypter;
+
+ public CrypterClassLoaderPolicy(String name, VirtualFile[] roots, VirtualFile[] excludedRoots, Crypter crypter)
+ {
+ super(name, roots, excludedRoots);
+ this.crypter = crypter;
+ }
+
+ @Override
+ public URL getResource(String path)
+ {
+ try
+ {
+ URL resource = super.getResource(path);
+ return wrap(resource);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public InputStream getResourceAsStream(String path)
+ {
+ InputStream stream = super.getResourceAsStream(path);
+ return crypter.crypt(stream);
+ }
+
+ @Override
+ public void getResources(String name, Set<URL> urls) throws IOException
+ {
+ super.getResources(name, urls);
+ Set<URL> temp = new HashSet<URL>(urls.size());
+ for (URL url : urls)
+ {
+ temp.add(wrap(url));
+ }
+ urls.clear();
+ urls.addAll(temp);
+ }
+
+ protected URL wrap(URL url) throws IOException
+ {
+ return new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile(), new CrypterURLStreamHandler(crypter));
+ }
+}
Copied: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterURLStreamHandler.java (from rev 95970, projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CipherURLStreamHandler.java)
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterURLStreamHandler.java (rev 0)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterURLStreamHandler.java 2009-11-03 18:29:50 UTC (rev 95974)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.demos.classloader.policy;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+import org.jboss.demos.classloader.crypt.Crypter;
+import org.jboss.net.protocol.DelegatingURLConnection;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class CrypterURLStreamHandler extends URLStreamHandler
+{
+ private Crypter crypter;
+
+ public CrypterURLStreamHandler(Crypter crypter)
+ {
+ this.crypter = crypter;
+ }
+
+ protected URLConnection openConnection(URL url) throws IOException
+ {
+ return new CrypterURLConnection(url);
+ }
+
+ private class CrypterURLConnection extends DelegatingURLConnection
+ {
+ private CrypterURLConnection(URL url) throws IOException
+ {
+ super(url);
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException
+ {
+ InputStream inputStream = super.getInputStream();
+ return crypter.crypt(inputStream);
+ }
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list