[jboss-cvs] JBossAS SVN: r96007 - in projects/demos/microcontainer/trunk: classloader/src/main/java/org/jboss/demos/classloader/crypt and 14 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 4 11:40:39 EST 2009


Author: alesj
Date: 2009-11-04 11:40:39 -0500 (Wed, 04 Nov 2009)
New Revision: 96007

Added:
   projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/NoMetaInfFilter.java
   projects/demos/microcontainer/trunk/encrypted/
   projects/demos/microcontainer/trunk/encrypted/pom.xml
   projects/demos/microcontainer/trunk/encrypted/src/
   projects/demos/microcontainer/trunk/encrypted/src/main/
   projects/demos/microcontainer/trunk/encrypted/src/main/java/
   projects/demos/microcontainer/trunk/encrypted/src/main/java/org/
   projects/demos/microcontainer/trunk/encrypted/src/main/java/org/jboss/
   projects/demos/microcontainer/trunk/encrypted/src/main/java/org/jboss/demos/
   projects/demos/microcontainer/trunk/encrypted/src/main/java/org/jboss/demos/encrypted/
   projects/demos/microcontainer/trunk/encrypted/src/main/java/org/jboss/demos/encrypted/services/
   projects/demos/microcontainer/trunk/encrypted/src/main/java/org/jboss/demos/encrypted/services/EncryptedService.java
   projects/demos/microcontainer/trunk/encrypted/src/main/resources/
   projects/demos/microcontainer/trunk/encrypted/src/main/resources/META-INF/
   projects/demos/microcontainer/trunk/encrypted/src/main/resources/META-INF/encrypted-beans.xml
   projects/demos/microcontainer/trunk/encrypted/src/main/resources/config/
   projects/demos/microcontainer/trunk/encrypted/src/main/resources/config/properties.xml
   projects/demos/microcontainer/trunk/encrypted/src/main/resources/config/settings.txt
Modified:
   projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/CryptVisitor.java
   projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterURLStreamHandler.java
   projects/demos/microcontainer/trunk/classloader/src/main/resources/META-INF/classloader-beans.xml
   projects/demos/microcontainer/trunk/pom.xml
Log:
Add Encrypted module.

Modified: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/CryptVisitor.java
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/CryptVisitor.java	2009-11-04 16:19:16 UTC (rev 96006)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/CryptVisitor.java	2009-11-04 16:40:39 UTC (rev 96007)
@@ -30,6 +30,7 @@
 
 import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
 import org.jboss.virtual.VirtualFileVisitor;
 import org.jboss.virtual.VisitorAttributes;
 import org.jboss.virtual.plugins.vfs.helpers.AbstractVirtualFileFilterWithAttributes;
@@ -41,6 +42,9 @@
 {
    private VirtualFile root;
    private Crypter crypter;
+   private VirtualFileFilter filter = NoMetaInfFilter.INSTANCE;
+   private VisitorAttributes attributes;
+
    private File file;
    private JarOutputStream jos;
 
@@ -72,7 +76,7 @@
 
    public boolean accepts(VirtualFile file)
    {
-      return file.getName().endsWith(".class");
+      return filter == null || filter.accepts(file);
    }
 
    public void visit(VirtualFile vf)
@@ -101,4 +105,9 @@
       VFSUtils.copyStreamAndClose(vf.openStream(), baos);
       return baos.toByteArray();
    }
+
+   public void setFilter(VirtualFileFilter filter)
+   {
+      this.filter = filter;
+   }
 }

Copied: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/NoMetaInfFilter.java (from rev 95966, projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/CryptVisitor.java)
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/NoMetaInfFilter.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/crypt/NoMetaInfFilter.java	2009-11-04 16:40:39 UTC (rev 96007)
@@ -0,0 +1,38 @@
+/*
+ * 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.crypt;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class NoMetaInfFilter implements VirtualFileFilter
+{
+   public static final VirtualFileFilter INSTANCE = new NoMetaInfFilter();
+   
+   public boolean accepts(VirtualFile file)
+   {
+      return file.getPathName().toUpperCase().contains("META-INF") == false;
+   }
+}
\ No newline at end of file

Modified: projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterURLStreamHandler.java
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterURLStreamHandler.java	2009-11-04 16:19:16 UTC (rev 96006)
+++ projects/demos/microcontainer/trunk/classloader/src/main/java/org/jboss/demos/classloader/policy/CrypterURLStreamHandler.java	2009-11-04 16:40:39 UTC (rev 96007)
@@ -55,6 +55,13 @@
       }
 
       @Override
+      protected URL makeDelegateUrl(URL url) throws IOException
+      {
+         // get back the old url - so we don't loop on the handler
+         return new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile());
+      }
+
+      @Override
       public InputStream getInputStream() throws IOException
       {
          InputStream inputStream = super.getInputStream();

Modified: projects/demos/microcontainer/trunk/classloader/src/main/resources/META-INF/classloader-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/classloader/src/main/resources/META-INF/classloader-beans.xml	2009-11-04 16:19:16 UTC (rev 96006)
+++ projects/demos/microcontainer/trunk/classloader/src/main/resources/META-INF/classloader-beans.xml	2009-11-04 16:40:39 UTC (rev 96007)
@@ -5,7 +5,7 @@
       <parameter>
         <bean class="java.io.File">
           <constructor>
-            <parameter>${demos.home}/tmp/keystore.txt</parameter>
+            <parameter>${demos.home}/encrypted/keystore.txt</parameter>
           </constructor>
         </bean>
       </parameter>

Added: projects/demos/microcontainer/trunk/encrypted/pom.xml
===================================================================
--- projects/demos/microcontainer/trunk/encrypted/pom.xml	                        (rev 0)
+++ projects/demos/microcontainer/trunk/encrypted/pom.xml	2009-11-04 16:40:39 UTC (rev 96007)
@@ -0,0 +1,14 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.jboss.demos</groupId>
+    <artifactId>jboss-demos</artifactId>
+    <version>2.0.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.jboss.demos</groupId>
+  <artifactId>jboss-demos-encrypted</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss MC Demos Encrypted</name>
+  <url>http://www.jboss.org/jbossmc</url>
+  <description>JBoss MC Demos</description>  
+</project>
\ No newline at end of file

Added: projects/demos/microcontainer/trunk/encrypted/src/main/java/org/jboss/demos/encrypted/services/EncryptedService.java
===================================================================
--- projects/demos/microcontainer/trunk/encrypted/src/main/java/org/jboss/demos/encrypted/services/EncryptedService.java	                        (rev 0)
+++ projects/demos/microcontainer/trunk/encrypted/src/main/java/org/jboss/demos/encrypted/services/EncryptedService.java	2009-11-04 16:40:39 UTC (rev 96007)
@@ -0,0 +1,71 @@
+/*
+ * 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.encrypted.services;
+
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class EncryptedService
+{
+   public void start() throws Exception
+   {
+      ClassLoader cl = getClass().getClassLoader();
+
+      URL url = cl.getResource("/config/settings.txt");
+      if (url == null)
+         throw new IllegalArgumentException("No such settings.txt.");
+
+      System.out.println("Printing settings:\n");
+      InputStream is = url.openStream();
+      print(is);
+
+      is = cl.getResourceAsStream("/config/properties.xml");
+      if (is == null)
+         throw new IllegalArgumentException("No such properties.xml.");
+
+      System.out.println("\nPrinting properties:\n");
+      print(is);
+   }
+
+   protected void print(InputStream is) throws IOException
+   {
+      try
+      {
+         BufferedReader buffer = new BufferedReader(new InputStreamReader(is));
+         String line;
+         while((line = buffer.readLine()) != null)
+         {
+            System.out.println(line);
+         }
+      }
+      finally
+      {
+         is.close();
+      }
+   }
+}

Added: projects/demos/microcontainer/trunk/encrypted/src/main/resources/META-INF/encrypted-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/encrypted/src/main/resources/META-INF/encrypted-beans.xml	                        (rev 0)
+++ projects/demos/microcontainer/trunk/encrypted/src/main/resources/META-INF/encrypted-beans.xml	2009-11-04 16:40:39 UTC (rev 96007)
@@ -0,0 +1,5 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="EncryptedService" class="org.jboss.demos.encrypted.services.EncryptedService"/>
+
+</deployment>

Added: projects/demos/microcontainer/trunk/encrypted/src/main/resources/config/properties.xml
===================================================================
--- projects/demos/microcontainer/trunk/encrypted/src/main/resources/config/properties.xml	                        (rev 0)
+++ projects/demos/microcontainer/trunk/encrypted/src/main/resources/config/properties.xml	2009-11-04 16:40:39 UTC (rev 96007)
@@ -0,0 +1,10 @@
+<properties>
+  <property>
+    <key>Author</key>
+    <value>Ales Justin</value>
+  </property>
+  <property>
+    <key>Title</key>
+    <value>MC ClassLoading</value>
+  </property>
+</properties>

Added: projects/demos/microcontainer/trunk/encrypted/src/main/resources/config/settings.txt
===================================================================
--- projects/demos/microcontainer/trunk/encrypted/src/main/resources/config/settings.txt	                        (rev 0)
+++ projects/demos/microcontainer/trunk/encrypted/src/main/resources/config/settings.txt	2009-11-04 16:40:39 UTC (rev 96007)
@@ -0,0 +1,3 @@
+This are confidential settings. :-)
+
+-Ales

Modified: projects/demos/microcontainer/trunk/pom.xml
===================================================================
--- projects/demos/microcontainer/trunk/pom.xml	2009-11-04 16:19:16 UTC (rev 96006)
+++ projects/demos/microcontainer/trunk/pom.xml	2009-11-04 16:40:39 UTC (rev 96007)
@@ -32,6 +32,7 @@
     <module>bundle</module>
     <module>bundle_user</module>
     <module>vfs</module>
+    <module>encrypted</module>
     <!-- <module>osgi</module> -->
     <module>build</module>
   </modules>




More information about the jboss-cvs-commits mailing list