List of usage examples for java.security PrivilegedActionException getException
public Exception getException()
From source file:org.apache.axis2.jaxws.description.builder.DescriptionBuilderUtils.java
/** * Return the class for this name/* w w w .j a v a 2 s . c o m*/ * * @return Class */ private static Class forName(final String className) throws ClassNotFoundException { Class cl = null; try { cl = (Class) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws ClassNotFoundException { return Class.forName(className); } }); } catch (PrivilegedActionException e) { if (log.isDebugEnabled()) { log.debug("Exception thrown from AccessController: " + e.getMessage(), e); } throw (ClassNotFoundException) e.getException(); } return cl; }
From source file:org.apache.axis2.jaxws.description.builder.DescriptionBuilderUtils.java
/** * Return the class for this name/* w w w .ja v a 2s . c o m*/ * * @return Class */ private static Class forName(final String className, final boolean initialize, final ClassLoader classloader) throws ClassNotFoundException { Class cl = null; try { cl = (Class) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws ClassNotFoundException { return Class.forName(className, initialize, classloader); } }); } catch (PrivilegedActionException e) { if (log.isDebugEnabled()) { log.debug("Exception thrown from AccessController: " + e.getMessage(), e); } throw (ClassNotFoundException) e.getException(); } return cl; }
From source file:org.apache.axis2.jaxws.description.builder.DescriptionBuilderUtils.java
/** * @return ClassLoader/*from w w w . j a v a2s. c om*/ */ private static ClassLoader getContextClassLoader(final ClassLoader classLoader) { ClassLoader cl; try { cl = (ClassLoader) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws ClassNotFoundException { return classLoader != null ? classLoader : Thread.currentThread().getContextClassLoader(); } }); } catch (PrivilegedActionException e) { if (log.isDebugEnabled()) { log.debug("Exception thrown from AccessController: " + e.getMessage(), e); } throw ExceptionFactory.makeWebServiceException(e.getException()); } return cl; }
From source file:org.apache.axis2.jaxws.server.dispatcher.JavaDispatcher.java
/** * @return ClassLoader// www .ja v a 2 s . c o m */ private static ClassLoader getCurrentContextClassLoader() { // NOTE: This method must remain private because it uses AccessController ClassLoader cl = null; try { cl = (ClassLoader) org.apache.axis2.java.security.AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() throws ClassNotFoundException { return Thread.currentThread().getContextClassLoader(); } }); } catch (PrivilegedActionException e) { // The privileged method will throw a PriviledgedActionException which // contains the actual exception. if (log.isDebugEnabled()) { log.debug("Exception thrown from AccessController: " + e); } Exception wrappedE = e.getException(); if (wrappedE instanceof RuntimeException) { throw (RuntimeException) wrappedE; } else { throw new RuntimeException(wrappedE); } } return cl; }
From source file:org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher.java
/** * @return ClassLoader// ww w. j a v a2s.c o m */ private static ClassLoader getContextClassLoader() { // NOTE: This method must remain private because it uses AccessController ClassLoader cl = null; try { cl = (ClassLoader) org.apache.axis2.java.security.AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() throws ClassNotFoundException { return Thread.currentThread().getContextClassLoader(); } }); } catch (PrivilegedActionException e) { // The privileged method will throw a PriviledgedActionException which // contains the actual exception. if (log.isDebugEnabled()) { log.debug("Exception thrown from AccessController: " + e); } Exception wrappedE = e.getException(); if (wrappedE instanceof RuntimeException) { throw (RuntimeException) wrappedE; } else { throw new RuntimeException(wrappedE); } } return cl; }
From source file:org.apache.openjpa.lib.util.Options.java
/** * Matches a key to an object/setter pair. * * @param key the key given at the command line; may be of the form * 'foo.bar' to signify the 'bar' property of the 'foo' owned object * @param match an array of length 2, where the first index is set * to the object to retrieve the setter for * @return true if a match was made, false otherwise; additionally, * the first index of the match array will be set to * the matching object and the second index will be * set to the setter method or public field for the * property named by the key//from ww w . j av a 2 s . c o m */ private static boolean matchOptionToMember(String key, Object[] match) throws Exception { if (StringUtils.isEmpty(key)) return false; // unfortunately we can't use bean properties for setters; any // setter with more than 1 argument is ignored; calculate setter and getter // name to look for String[] find = Strings.split(key, ".", 2); String base = StringUtils.capitalize(find[0]); String set = "set" + base; String get = "get" + base; // look for a setter/getter matching the key; look for methods first Class<? extends Object> type = match[0].getClass(); Method[] meths = type.getMethods(); Method setMeth = null; Method getMeth = null; Class[] params; for (int i = 0; i < meths.length; i++) { if (meths[i].getName().equals(set)) { params = meths[i].getParameterTypes(); if (params.length == 0) continue; if (params[0].isArray()) continue; // use this method if we haven't found any other setter, if // it has less parameters than any other setter, or if it uses // string parameters if (setMeth == null) setMeth = meths[i]; else if (params.length < setMeth.getParameterTypes().length) setMeth = meths[i]; else if (params.length == setMeth.getParameterTypes().length && params[0] == String.class) setMeth = meths[i]; } else if (meths[i].getName().equals(get)) getMeth = meths[i]; } // if no methods found, check for public field Member setter = setMeth; Member getter = getMeth; if (setter == null) { Field[] fields = type.getFields(); String uncapBase = StringUtils.uncapitalize(find[0]); for (int i = 0; i < fields.length; i++) { if (fields[i].getName().equals(base) || fields[i].getName().equals(uncapBase)) { setter = fields[i]; getter = fields[i]; break; } } } // if no way to access property, give up if (setter == null && getter == null) return false; // recurse on inner object with remainder of key? if (find.length > 1) { Object inner = null; if (getter != null) inner = invoke(match[0], getter, null); // if no getter or current inner is null, try to create a new // inner instance and set it in object if (inner == null && setter != null) { Class<?> innerType = getType(setter)[0]; try { inner = AccessController.doPrivileged(J2DoPrivHelper.newInstanceAction(innerType)); } catch (PrivilegedActionException pae) { throw pae.getException(); } invoke(match[0], setter, new Object[] { inner }); } match[0] = inner; return matchOptionToMember(find[1], match); } // got match; find setter for property match[1] = setter; return match[1] != null; }
From source file:org.apache.axis2.builder.BuilderUtil.java
/** * Use the BOM Mark to identify the encoding to be used. Fall back to default encoding * specified/*from w ww .j a v a 2 s . c o m*/ * * @param is the InputStream of a message * @param charSetEncoding default character set encoding * @return a Reader with the correct encoding already set * @throws java.io.IOException */ public static Reader getReader(final InputStream is, final String charSetEncoding) throws IOException { final PushbackInputStream is2 = getPushbackInputStream(is); final String encoding = getCharSetEncoding(is2, charSetEncoding); InputStreamReader inputStreamReader; try { inputStreamReader = (InputStreamReader) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws UnsupportedEncodingException { return new InputStreamReader(is2, encoding); } }); } catch (PrivilegedActionException e) { throw (UnsupportedEncodingException) e.getException(); } return new BufferedReader(inputStreamReader); }
From source file:org.apache.axiom.om.util.StAXUtils.java
public static XMLStreamWriter createXMLStreamWriter(StAXWriterConfiguration configuration, final Writer out) throws XMLStreamException { final XMLOutputFactory outputFactory = getXMLOutputFactory(configuration); try {// w w w . j ava 2 s . co m XMLStreamWriter writer = (XMLStreamWriter) AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() throws XMLStreamException { return outputFactory.createXMLStreamWriter(out); } }); if (isDebugEnabled) { log.debug("XMLStreamWriter is " + writer.getClass().getName()); } return writer; } catch (PrivilegedActionException pae) { throw (XMLStreamException) pae.getException(); } }
From source file:org.apache.axiom.om.util.StAXUtils.java
public static XMLStreamReader createXMLStreamReader(StAXParserConfiguration configuration, final InputStream in, final String encoding) throws XMLStreamException { final XMLInputFactory inputFactory = getXMLInputFactory(configuration); try {// w ww.j av a 2 s . co m XMLStreamReader reader = (XMLStreamReader) AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() throws XMLStreamException { return inputFactory.createXMLStreamReader(in, encoding); } }); if (isDebugEnabled) { log.debug("XMLStreamReader is " + reader.getClass().getName()); } return reader; } catch (PrivilegedActionException pae) { throw (XMLStreamException) pae.getException(); } }
From source file:org.apache.axiom.om.util.StAXUtils.java
public static XMLStreamReader createXMLStreamReader(StAXParserConfiguration configuration, final Reader in) throws XMLStreamException { final XMLInputFactory inputFactory = getXMLInputFactory(configuration); try {/*from w w w . j av a2 s .co m*/ XMLStreamReader reader = (XMLStreamReader) AccessController .doPrivileged(new PrivilegedExceptionAction() { public Object run() throws XMLStreamException { return inputFactory.createXMLStreamReader(in); } }); if (isDebugEnabled) { log.debug("XMLStreamReader is " + reader.getClass().getName()); } return reader; } catch (PrivilegedActionException pae) { throw (XMLStreamException) pae.getException(); } }