myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1336648 - /myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
Date Thu, 10 May 2012 12:52:55 GMT
Author: lu4242
Date: Thu May 10 12:52:54 2012
New Revision: 1336648

URL: http://svn.apache.org/viewvc?rev=1336648&view=rev
Log:
MYFACES-3536 AccessControlException occurs when using a CustomExceptionHandler to navigate
to a page using the NavigationHandler (thanks to Paul Nicolucci for provide this patch)

Modified:
    myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java

Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java?rev=1336648&r1=1336647&r2=1336648&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
(original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
Thu May 10 12:52:54 2012
@@ -24,6 +24,9 @@ import java.io.InputStream;
 import java.net.URL;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedActionException;
 
 import javax.el.ELException;
 import javax.faces.FacesException;
@@ -707,9 +710,40 @@ public final class SAXCompiler extends C
             is = new BufferedInputStream(src.openStream(), 1024);
             mngr = new CompilationManager(alias, this);
             encoding = getXmlDecl(is, mngr);
-            ViewMetadataHandler handler = new ViewMetadataHandler(mngr, alias);
-            SAXParser parser = this.createSAXParser(handler);
-            parser.parse(is, handler);
+            final ViewMetadataHandler handler = new ViewMetadataHandler(mngr, alias);
+            final SAXParser parser = this.createSAXParser(handler);
+            
+            if (System.getSecurityManager() != null)
+            {
+                try
+                {
+                    final InputStream finalInputStream = is;
+                    AccessController.doPrivileged(new PrivilegedExceptionAction() 
+                    {
+                        public Object run() throws SAXException, IOException 
+                        {
+                            parser.parse(finalInputStream, handler);
+                            return null; 
+                        }
+                    });
+                }
+                catch (PrivilegedActionException pae)
+                {
+                    Exception e = pae.getException();
+                    if(e instanceof SAXException)
+                    {
+                        throw new FaceletException("Error Parsing " + alias + ": " + e.getMessage(),
e.getCause());
+                    } 
+                    else if(e instanceof IOException)
+                    {
+                        throw (IOException)e;
+                    }
+                }
+            }
+            else
+            {
+                parser.parse(is, handler);
+            }
         }
         catch (SAXException e)
         {



Mime
View raw message