List of usage examples for java.security PrivilegedActionException getException
public Exception getException()
From source file:org.apache.struts2.jasper.runtime.PageContextImpl.java
public void forward(final String relativeUrlPath) throws ServletException, IOException { if (SecurityUtil.isPackageProtectionEnabled()) { try {//from w w w.ja v a 2s . c o m AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { doForward(relativeUrlPath); return null; } }); } catch (PrivilegedActionException e) { Exception ex = e.getException(); if (ex instanceof IOException) { throw (IOException) ex; } else { throw (ServletException) ex; } } } else { doForward(relativeUrlPath); } }
From source file:org.apache.struts2.jasper.runtime.PageContextImpl.java
public void handlePageException(final Throwable t) throws IOException, ServletException { if (t == null) throw new NullPointerException("null Throwable"); if (SecurityUtil.isPackageProtectionEnabled()) { try {/* ww w . j a v a2 s . c o m*/ AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { doHandlePageException(t); return null; } }); } catch (PrivilegedActionException e) { Exception ex = e.getException(); if (ex instanceof IOException) { throw (IOException) ex; } else { throw (ServletException) ex; } } } else { doHandlePageException(t); } }
From source file:org.apache.axis2.deployment.AxisConfigBuilder.java
/** * Processes AxisObservers./*from w ww . ja v a2s. co m*/ * * @param oservers */ private void processObservers(Iterator oservers) { while (oservers.hasNext()) { try { OMElement observerelement = (OMElement) oservers.next(); AxisObserver observer; OMAttribute trsClas = observerelement.getAttribute(new QName(TAG_CLASS_NAME)); if (trsClas == null) { log.info(Messages.getMessage(DeploymentErrorMsgs.OBSERVER_ERROR)); return; } final String clasName = trsClas.getAttributeValue(); Class observerclass; try { observerclass = (Class) org.apache.axis2.java.security.AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() throws ClassNotFoundException { return Loader.loadClass(clasName); } }); } catch (PrivilegedActionException e) { throw (ClassNotFoundException) e.getException(); } observer = (AxisObserver) observerclass.newInstance(); // processing Parameters // Processing service level parameters Iterator itr = observerelement.getChildrenWithName(new QName(TAG_PARAMETER)); processParameters(itr, observer, axisConfig); // initialization try { observer.init(axisConfig); } catch (Throwable e) { //Observer init may throw runtime exception , but we can stil // start Axis2 log.info(e.getMessage()); } axisConfig.addObservers(observer); } catch (Exception e) { log.info(e.getMessage()); } } }
From source file:org.apache.bsf.BSFManager.java
/** * Execute the given script of the given language. * * @param lang language identifier//from w w w . j av a2 s .com * @param source (context info) the source of this expression (e.g., filename) * @param lineNo (context info) the line number in source for expr * @param columnNo (context info) the column number in source for expr * @param script the script to execute * * @exception BSFException if anything goes wrong while running the script */ public void exec(String lang, String source, int lineNo, int columnNo, Object script) throws BSFException { logger.debug("BSFManager:exec"); final BSFEngine e = loadScriptingEngine(lang); final String sourcef = source; final int lineNof = lineNo, columnNof = columnNo; final Object scriptf = script; try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { e.exec(sourcef, lineNof, columnNof, scriptf); return null; } }); } catch (PrivilegedActionException prive) { logger.error("Exception :", prive); throw (BSFException) prive.getException(); } }
From source file:org.apache.bsf.BSFManager.java
/** * Execute the given script of the given language, attempting to * emulate an interactive session w/ the language. * * @param lang language identifier/*from w ww . jav a 2 s.co m*/ * @param source (context info) the source of this expression * (e.g., filename) * @param lineNo (context info) the line number in source for expr * @param columnNo (context info) the column number in source for expr * @param script the script to execute * * @exception BSFException if anything goes wrong while running the script */ public void iexec(String lang, String source, int lineNo, int columnNo, Object script) throws BSFException { logger.debug("BSFManager:iexec"); final BSFEngine e = loadScriptingEngine(lang); final String sourcef = source; final int lineNof = lineNo, columnNof = columnNo; final Object scriptf = script; try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { e.iexec(sourcef, lineNof, columnNof, scriptf); return null; } }); } catch (PrivilegedActionException prive) { logger.error("Exception :", prive); throw (BSFException) prive.getException(); } }
From source file:org.apache.axis2.deployment.util.Utils.java
public static File createTempFile(final String suffix, InputStream in, final File tmpDir) throws IOException { byte data[] = new byte[2048]; int count;/*from w w w .j a v a2 s . co m*/ File f = TempFileManager.createTempFile("axis2", suffix); // if (tmpDir == null) { // String directory = (String)org.apache.axis2.java.security.AccessController // .doPrivileged(new PrivilegedAction() { // public Object run() { // return System.getProperty("java.io.tmpdir"); // } // }); // final File tempFile = new File(directory, "_axis2"); // Boolean exists = (Boolean)org.apache.axis2.java.security.AccessController // .doPrivileged(new PrivilegedAction() { // public Object run() { // return tempFile.exists(); // } // }); // if (!exists) { // Boolean mkdirs = (Boolean)org.apache.axis2.java.security.AccessController // .doPrivileged(new PrivilegedAction() { // public Object run() { // return tempFile.mkdirs(); // } // }); // if (!mkdirs) { // throw new IOException("Unable to create the directory"); // } // } // try { // f = (File)org.apache.axis2.java.security.AccessController // .doPrivileged(new PrivilegedExceptionAction() { // public Object run() throws IOException { // return File.createTempFile("axis2", suffix, // tempFile); // } // }); // f.deleteOnExit(); // } catch (PrivilegedActionException e) { // throw (IOException)e.getException(); // } // } else { // try { // f = (File)org.apache.axis2.java.security.AccessController // .doPrivileged(new PrivilegedExceptionAction() { // public Object run() throws IOException { // return File.createTempFile("axis2", suffix, // tmpDir); // } // }); // f.deleteOnExit(); // } catch (PrivilegedActionException e) { // throw (IOException)e.getException(); // } // } // if (log.isDebugEnabled()) { // log.debug("Created temporary file : " + f.getAbsolutePath());// $NON-SEC-4 // } // final File f2 = f; // org.apache.axis2.java.security.AccessController // .doPrivileged(new PrivilegedAction() { // public Object run() { // f2.deleteOnExit(); // return null; // } // }); FileOutputStream out; final File f2 = f; try { out = (FileOutputStream) org.apache.axis2.java.security.AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileOutputStream(f2); } }); } catch (PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); } while ((count = in.read(data, 0, 2048)) != -1) { out.write(data, 0, count); } out.close(); return f; }
From source file:org.apache.bsf.BSFManager.java
/** * Compile the given expression of the given language into the given * <tt>CodeBuffer</tt>.//from w w w. j av a 2s . c o m * * @param lang language identifier * @param source (context info) the source of this expression (e.g., filename) * @param lineNo (context info) the line number in source for expr * @param columnNo (context info) the column number in source for expr * @param expr the expression to compile * @param cb code buffer to compile into * * @exception BSFException if any error while compiling the expression */ public void compileExpr(String lang, String source, int lineNo, int columnNo, Object expr, CodeBuffer cb) throws BSFException { logger.debug("BSFManager:compileExpr"); final BSFEngine e = loadScriptingEngine(lang); final String sourcef = source; final int lineNof = lineNo, columnNof = columnNo; final Object exprf = expr; final CodeBuffer cbf = cb; try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { e.compileExpr(sourcef, lineNof, columnNof, exprf, cbf); return null; } }); } catch (PrivilegedActionException prive) { logger.error("Exception :", prive); throw (BSFException) prive.getException(); } }
From source file:org.apache.bsf.BSFManager.java
/** * Compile the given script of the given language into the given * <tt>CodeBuffer</tt>./* ww w.j av a 2 s . c o m*/ * * @param lang language identifier * @param source (context info) the source of this script (e.g., filename) * @param lineNo (context info) the line number in source for script * @param columnNo (context info) the column number in source for script * @param script the script to compile * @param cb code buffer to compile into * * @exception BSFException if any error while compiling the script */ public void compileScript(String lang, String source, int lineNo, int columnNo, Object script, CodeBuffer cb) throws BSFException { logger.debug("BSFManager:compileScript"); final BSFEngine e = loadScriptingEngine(lang); final String sourcef = source; final int lineNof = lineNo, columnNof = columnNo; final Object scriptf = script; final CodeBuffer cbf = cb; try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { e.compileScript(sourcef, lineNof, columnNof, scriptf, cbf); return null; } }); } catch (PrivilegedActionException prive) { logger.error("Exception :", prive); throw (BSFException) prive.getException(); } }
From source file:org.apache.bsf.BSFManager.java
/** * Evaluate the given expression of the given language and return the * resulting value.//from w w w . j a v a 2 s. c o m * * @param lang language identifier * @param source (context info) the source of this expression (e.g., filename) * @param lineNo (context info) the line number in source for expr * @param columnNo (context info) the column number in source for expr * @param expr the expression to evaluate * * @exception BSFException if anything goes wrong while running the script */ public Object eval(String lang, String source, int lineNo, int columnNo, Object expr) throws BSFException { logger.debug("BSFManager:eval"); final BSFEngine e = loadScriptingEngine(lang); final String sourcef = source; final int lineNof = lineNo, columnNof = columnNo; final Object exprf = expr; Object result = null; try { final Object resultf = AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { return e.eval(sourcef, lineNof, columnNof, exprf); } }); result = resultf; } catch (PrivilegedActionException prive) { logger.error("Exception: ", prive); throw (BSFException) prive.getException(); } return result; }
From source file:org.apache.bsf.BSFManager.java
/** * Compile the application of the given anonymous function of the given * language to the given parameters into the given <tt>CodeBuffer</tt>. * * @param lang language identifier//from w ww . j a v a 2 s . com * @param source (context info) the source of this expression (e.g., filename) * @param lineNo (context info) the line number in source for expr * @param columnNo (context info) the column number in source for expr * @param funcBody the multi-line, value returning script to evaluate * @param paramNames the names of the parameters above assumes * @param arguments values of the above parameters * @param cb code buffer to compile into * * @exception BSFException if anything goes wrong while running the script */ public void compileApply(String lang, String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments, CodeBuffer cb) throws BSFException { logger.debug("BSFManager:compileApply"); final BSFEngine e = loadScriptingEngine(lang); final String sourcef = source; final int lineNof = lineNo, columnNof = columnNo; final Object funcBodyf = funcBody; final Vector paramNamesf = paramNames; final Vector argumentsf = arguments; final CodeBuffer cbf = cb; try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { e.compileApply(sourcef, lineNof, columnNof, funcBodyf, paramNamesf, argumentsf, cbf); return null; } }); } catch (PrivilegedActionException prive) { logger.error("Exception :", prive); throw (BSFException) prive.getException(); } }