Java 8 PrivilegedActionException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PrivilegedActionException class.

This code example shows how to use the following methods:getException
        public T run() throws Exception { 
          return callable.call();
        } 
      }); 
    } catch (PrivilegedActionException ex) {
      throw ex.getException();
    } finally { 
      if (loginContext != null) {
        loginContext.logout();
      } 
    } 
  } 
 
  public static <T> T doAsClient(Callable<T> callable) throws Exception {
    return doAs(getClientPrincipal(), callable);
  } 
 
  public static <T> T doAsServer(Callable<T> callable) throws Exception {
    return doAs(getServerPrincipal(), callable);
  } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getException
            this.baseDir = (File) retval[0];
            this.canonicalPath = (String) retval[1]; 
        } 
        catch(PrivilegedActionException e)
        { 
            throw (IOException)e.getException();
        } 
    } 
     
    public Object findTemplateSource(final String name)
    throws 
    	IOException 
    { 
        try { 
            return AccessController.doPrivileged(new PrivilegedExceptionAction() {
                public Object run() throws IOException {
                    File source = new File(baseDir, SEP_IS_SLASH ? name : 
                        name.replace('/', File.separatorChar));
                    if(!source.isFile()) {
                        return null; 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getMessage, getException
                    } 
                } 
            ); 
        } catch (PrivilegedActionException e) {
            if (log.isDebugEnabled()) {
                log.debug("Exception thrown from AccessController: " + e.getMessage(), e);
            } 
            throw ExceptionFactory.makeWebServiceException(e.getException());
        } 
 
        return cl;
    } 
 
    /** 
     * Return the class for this name 
     * 
     * @return Class 
     */ 
    private static Class forName(final String className, final boolean initialize,
        final ClassLoader classloader) throws ClassNotFoundException {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCause
         }); 
      } 
      // Unwrap 
      catch (final PrivilegedActionException pae)
      { 
         final Throwable t = pae.getCause();
         // Rethrow 
         if (t instanceof NoSuchMethodException)
         { 
            throw (NoSuchMethodException) t;
         } 
         else 
         { 
            // No other checked Exception thrown by Class.getConstructor 
            try 
            { 
               throw (RuntimeException) t;
            } 
            // Just in case we've really messed up 
            catch (final ClassCastException cce)
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getException
                public Object run() throws Exception { 
                    return Class.forName(className, true, getClassLoader(this.getClass())); 
                } 
            }); 
        } catch (PrivilegedActionException pae) {
            throw BeanLogger.LOG.cannotLoadClass(className, pae.getException());
        } 
    } 
 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCause
            RuntimeException e;
            try { 
 
                e = AccessController.doPrivileged(NewInstanceAction.of(exceptionToThrow));
            } catch (PrivilegedActionException ex) {
                throw new WeldException(ex.getCause());
            } 
            e.initCause(t);
            throw e;
        } 
    } 
 
    private static void rethrowException(Throwable t) {
        rethrowException(t, CreationException.class);
    } 
 
    public static void rethrowException(IllegalArgumentException e) {
        rethrowException(e.getCause() != null ? e.getCause() : e);
    } 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
package groovy.xml; 
 
import junit.framework.TestCase;
 
import javax.xml.parsers.ParserConfigurationException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
 
public class FactorySupportTest extends TestCase {
    private static final PrivilegedActionException PRIVILEGED_ACTION_EXCEPTION = new PrivilegedActionException(new IllegalStateException());
    private static final ParserConfigurationException PARSER_CONFIGURATION_EXCEPTION = new ParserConfigurationException();
 
    public void testCreatesFactories() throws Exception {
        assertNotNull(FactorySupport.createDocumentBuilderFactory());
        assertNotNull(FactorySupport.createSaxParserFactory());
    } 
 
    public void testParserConfigurationExceptionNotWrapped() throws ParserConfigurationException {
        try { 
            FactorySupport.createFactory(new PrivilegedExceptionAction() {

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getException
        public T run() throws Exception { 
          return callable.call();
        } 
      }); 
    } catch (PrivilegedActionException ex) {
      throw ex.getException();
    } finally { 
      if (loginContext != null) {
        loginContext.logout();
      } 
    } 
  } 
 
  public static <T> T doAsClient(Callable<T> callable) throws Exception {
    return doAs(getClientPrincipal(), callable);
  } 
 
  public static <T> T doAsServer(Callable<T> callable) throws Exception {
    return doAs(getServerPrincipal(), callable);
  } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getException
                    defineClass2.setAccessible(true); 
                    return null; 
                } 
            }); 
        } catch (PrivilegedActionException pae) {
            throw new RuntimeException("cannot initialize ClassPool", pae.getException());
        } 
    } 
 
    /** 
     * Converts the class to a <code>java.lang.Class</code> object. Once this 
     * method is called, further modifications are not allowed any more. 
     * <p/> 
     * <p/> 
     * The class file represented by the given <code>CtClass</code> is loaded by 
     * the given class loader to construct a <code>java.lang.Class</code> object. 
     * Since a private method on the class loader is invoked through the 
     * reflection API, the caller must have permissions to do that. 
     * <p/> 
     * <p/> 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getException
                    public Object run() throws FileNotFoundException {
                        return new FileInputStream(file);
                    } 
                }); 
        } catch (PrivilegedActionException e) {
            throw (FileNotFoundException)e.getException();
        } 
    } 
 
    InputStream getResourceAsStream(final ClassLoader cl,
                                           final String name)
    { 
        return (InputStream)
            AccessController.doPrivileged(new PrivilegedAction() {
                public Object run() {
                    InputStream ris;
                    if (cl == null) {
                        ris = ClassLoader.getSystemResourceAsStream(name);
                    } else { 
                        ris = cl.getResourceAsStream(name);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 PrivilegedActionException Questions & Answers:

See Code Examples for Java 8 PrivilegedActionException Methods: