myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r427513 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java example/security/src/main/java/org/apache/myfaces/tobago/example/security/CheckAuthorisationMethodBinding.java
Date Tue, 01 Aug 2006 10:20:44 GMT
Author: bommel
Date: Tue Aug  1 03:20:41 2006
New Revision: 427513

URL: http://svn.apache.org/viewvc?rev=427513&view=rev
Log:
try to get resouces from classpath if protocol is unknown

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java
    myfaces/tobago/trunk/example/security/src/main/java/org/apache/myfaces/tobago/example/security/CheckAuthorisationMethodBinding.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java?rev=427513&r1=427512&r2=427513&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java
Tue Aug  1 03:20:41 2006
@@ -124,50 +124,10 @@
         // weblogic uses zip
         // IBM WebSphere uses wsjar
         if ("jar".equals(protocol) || "zip".equals(protocol) || "wsjar".equals(protocol))
{
-          LOG.info("themeUrl = '" + themeUrl + "'");
-          String fileName = themeUrl.toString().substring(
-              protocol.length() + 1, themeUrl.toString().indexOf("!"));
-          URL jarFile;
-          try {
-            jarFile = new URL(fileName);
-          } catch (MalformedURLException e) {
-            // workaround for weblogic on windows
-            jarFile = new URL("file:" + fileName);
-          }
-          InputStream stream = null;
-          try {
-            stream = jarFile.openStream();
-            ZipInputStream zip = new ZipInputStream(stream);
-            while (zip.available() > 0) {
-              ZipEntry nextEntry = zip.getNextEntry();
-              if (nextEntry == null || nextEntry.isDirectory()) {
-                continue;
-              }
-              String name = "/" + nextEntry.getName();
-              if (name.startsWith(prefix)) {
-                if (name.endsWith(".class")) {
-                  // ignore the class files
-                } else if (name.endsWith(".properties")) {
-                  LOG.info("** " + name.substring(1));
-                  InputStream inputStream = classLoader.getResourceAsStream(name.substring(1));
-                  addProperties(inputStream, resources, name, false);
-                } else if (name.endsWith(".properties.xml")) {
-                  LOG.info("** " + name.substring(1));
-                  InputStream inputStream = classLoader.getResourceAsStream(name.substring(1));
-                  LOG.info(inputStream);
-                  addProperties(inputStream, resources, name, true);
-                } else {
-                  resources.add(name);
-                }
-              }
-            }
-          } finally {
-            IOUtils.closeQuietly(stream);
-          }
+          addResources(classLoader, resources, themeUrl, protocol, prefix);
         } else {
-          String error = "Unknown protocol '" + themeUrl + "'";
-          LOG.error(error);
-          throw new Exception(error);
+          LOG.warn("Unknown protocol '" + themeUrl + "'");
+          addResources(classLoader, resources,  themeUrl, protocol, prefix);
         }
       }
     } catch (Exception e) {
@@ -176,6 +136,50 @@
         LOG.error(msg, e);
       }
       throw new ServletException(msg, e);
+    }
+  }
+
+  private void addResources(ClassLoader classLoader, ResourceManagerImpl resources, URL themeUrl,
String protocol,
+      String prefix) throws IOException, ServletException {
+    LOG.info("themeUrl = '" + themeUrl + "'");
+    String fileName = themeUrl.toString().substring(
+        protocol.length() + 1, themeUrl.toString().indexOf("!"));
+    URL jarFile;
+    try {
+      jarFile = new URL(fileName);
+    } catch (MalformedURLException e) {
+      // workaround for weblogic on windows
+      jarFile = new URL("file:" + fileName);
+    }
+    InputStream stream = null;
+    try {
+      stream = jarFile.openStream();
+      ZipInputStream zip = new ZipInputStream(stream);
+      while (zip.available() > 0) {
+        ZipEntry nextEntry = zip.getNextEntry();
+        if (nextEntry == null || nextEntry.isDirectory()) {
+          continue;
+        }
+        String name = "/" + nextEntry.getName();
+        if (name.startsWith(prefix)) {
+          if (name.endsWith(".class")) {
+            // ignore the class files
+          } else if (name.endsWith(".properties")) {
+            LOG.info("** " + name.substring(1));
+            InputStream inputStream = classLoader.getResourceAsStream(name.substring(1));
+            addProperties(inputStream, resources, name, false);
+          } else if (name.endsWith(".properties.xml")) {
+            LOG.info("** " + name.substring(1));
+            InputStream inputStream = classLoader.getResourceAsStream(name.substring(1));
+            LOG.info(inputStream);
+            addProperties(inputStream, resources, name, true);
+          } else {
+            resources.add(name);
+          }
+        }
+      }
+    } finally {
+      IOUtils.closeQuietly(stream);
     }
   }
 

Modified: myfaces/tobago/trunk/example/security/src/main/java/org/apache/myfaces/tobago/example/security/CheckAuthorisationMethodBinding.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/security/src/main/java/org/apache/myfaces/tobago/example/security/CheckAuthorisationMethodBinding.java?rev=427513&r1=427512&r2=427513&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/security/src/main/java/org/apache/myfaces/tobago/example/security/CheckAuthorisationMethodBinding.java
(original)
+++ myfaces/tobago/trunk/example/security/src/main/java/org/apache/myfaces/tobago/example/security/CheckAuthorisationMethodBinding.java
Tue Aug  1 03:20:41 2006
@@ -70,8 +70,8 @@
     if (LOG.isDebugEnabled()) {
       LOG.debug("MethodBinding invoke " + getExpressionString());
     }
-    // TODO methodbinding with objects.length == 0 should only checked?
-    if (isAuthorized(facesContext)) {
+    // Methodbindings with a argument list would not be checked for authorisation
+    if (isAuthorized(facesContext) || objects.length > 0) {
       return methodBinding.invoke(facesContext, objects);
     } else {
       // TODO better message



Mime
View raw message