List of usage examples for java.security PrivilegedActionException getCause
public synchronized Throwable getCause()
From source file:org.apache.axis2.jaxws.message.databinding.JAXBUtils.java
private static Unmarshaller internalCreateUnmarshaller(final JAXBContext context) throws JAXBException { Unmarshaller unm;//from w ww. j a va 2s . c o m try { unm = (Unmarshaller) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws JAXBException { return context.createUnmarshaller(); } }); } catch (PrivilegedActionException e) { throw (JAXBException) e.getCause(); } return unm; }
From source file:org.apache.axis2.jaxws.message.databinding.JAXBUtils.java
private static Marshaller internalCreateMarshaller(final JAXBContext context) throws JAXBException { Marshaller marshaller;/*from www . j ava2 s . c o m*/ try { marshaller = (Marshaller) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws JAXBException { return context.createMarshaller(); } }); } catch (PrivilegedActionException e) { throw (JAXBException) e.getCause(); } return marshaller; }
From source file:org.elasticsearch.xpack.core.ssl.SSLServiceTests.java
private CloseableHttpAsyncClient getAsyncHttpClient(SSLIOSessionStrategy sslStrategy) throws Exception { try {/* w w w. j a v a 2 s . co m*/ return AccessController .doPrivileged((PrivilegedExceptionAction<CloseableHttpAsyncClient>) () -> HttpAsyncClientBuilder .create().setSSLStrategy(sslStrategy).build()); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } }
From source file:org.codice.ddf.security.crl.generator.CrlGenerator.java
/** * Removes the org.apache.ws.security.crypto.merlin.x509crl.file property in the * signature.properties and encryption.properties files. *///ww w. ja va 2 s . c om @VisibleForTesting void removeCrlFileLocationInPropertiesFile() { try { AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> { removeProperty(issuerSignaturePropertiesLocation); removeProperty(issuerEncryptionPropertiesLocation); removeProperty(serverSignaturePropertiesLocation); removeProperty(serverEncryptionPropertiesLocation); SecurityLogger.audit("Removing the {} property from signature and encryption properties.", CRL_PROPERTY_KEY); return null; }); } catch (PrivilegedActionException e) { LOGGER.warn( "Unable to remove the CRL property from the signature.properties and encryption.properties files."); LOGGER.debug( "Unable to remove the CRL property from the signature.properties and encryption.properties files. {}", e.getCause()); postErrorEvent( "Unable to remove the CRL property from the signature.properties and encryption.properties files."); } }
From source file:org.apache.hadoop.security.UserGroupInformation.java
/** * Run the given action as the user, potentially throwing an exception. * @param <T> the return type of the run method * @param action the method to execute// ww w. j a v a 2 s .c o m * @return the value from the run method * @throws IOException if the action throws an IOException * @throws Error if the action throws an Error * @throws RuntimeException if the action throws a RuntimeException * @throws InterruptedException if the action throws an InterruptedException * @throws UndeclaredThrowableException if the action throws something else */ public <T> T doAs(PrivilegedExceptionAction<T> action) throws IOException, InterruptedException { try { logPriviledgedAction(subject, action); return Subject.doAs(subject, action); } catch (PrivilegedActionException pae) { Throwable cause = pae.getCause(); LOG.error("PriviledgedActionException as:" + this + " cause:" + cause); if (cause instanceof IOException) { throw (IOException) cause; } else if (cause instanceof Error) { throw (Error) cause; } else if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else if (cause instanceof InterruptedException) { throw (InterruptedException) cause; } else { throw new UndeclaredThrowableException(pae, "Unknown exception in doAs"); } } }
From source file:org.openconcerto.sql.model.graph.DatabaseGraph.java
private final void refresh(final ToRefreshSpec toRefresh) throws SQLException { synchronized (this.base.getTreeMutex()) { synchronized (this) { final GraphLoadingEvent evt = new GraphLoadingEvent(this.base).fireEvent(); try { // TODO limit to file permission this.mappedFromFile = Collections.unmodifiableMap(AccessController .doPrivileged(new PrivilegedExceptionAction<Map<String, Set<String>>>() { @Override public Map<String, Set<String>> run() throws SQLException { return mapTables(toRefresh); }//from ww w . jav a 2s. co m })); } catch (PrivilegedActionException e) { throw (SQLException) e.getCause(); } finally { evt.fireFinishingEvent(); } } } }
From source file:org.exoplatform.services.jcr.ext.script.groovy.GroovyScript2RestLoader.java
/** * Write parameters to RegistryService.//from ww w. j a v a 2s . com * * @param sessionProvider the SessionProvider * @throws ParserConfigurationException * @throws SAXException * @throws IOException * @throws RepositoryException */ protected void writeParamsToRegistryService(SessionProvider sessionProvider) throws IOException, SAXException, ParserConfigurationException, RepositoryException { if (LOG.isDebugEnabled()) { LOG.debug(">>> Save init parametrs in registry service."); } Document doc; try { doc = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Document>() { public Document run() throws ParserConfigurationException { return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } }); } catch (PrivilegedActionException e) { throw (ParserConfigurationException) e.getCause(); } Element root = doc.createElement(SERVICE_NAME); doc.appendChild(root); Element element = doc.createElement("nodeType"); setAttributeSmart(element, "value", getNodeType()); root.appendChild(element); StringBuffer sb = new StringBuffer(); for (String workspace : observationListenerConfiguration.getWorkspaces()) { if (sb.length() > 0) { sb.append(';'); } sb.append(workspace); } element = doc.createElement("workspaces"); setAttributeSmart(element, "value", sb.toString()); root.appendChild(element); element = doc.createElement("repository"); setAttributeSmart(element, "value", observationListenerConfiguration.getRepository()); root.appendChild(element); RegistryEntry serviceEntry = new RegistryEntry(doc); registryService.createEntry(sessionProvider, RegistryService.EXO_SERVICES, serviceEntry); }
From source file:com.buaa.cfs.security.UserGroupInformation.java
/** * Run the given action as the user, potentially throwing an exception. * * @param <T> the return type of the run method * @param action the method to execute//from w ww . j av a 2 s . c o m * * @return the value from the run method * * @throws IOException if the action throws an IOException * @throws Error if the action throws an Error * @throws RuntimeException if the action throws a RuntimeException * @throws InterruptedException if the action throws an InterruptedException * @throws UndeclaredThrowableException if the action throws something else */ public <T> T doAs(PrivilegedExceptionAction<T> action) throws IOException, InterruptedException { try { logPrivilegedAction(subject, action); return Subject.doAs(subject, action); } catch (PrivilegedActionException pae) { Throwable cause = pae.getCause(); if (LOG.isDebugEnabled()) { LOG.debug("PrivilegedActionException as:" + this + " cause:" + cause); } if (cause instanceof IOException) { throw (IOException) cause; } else if (cause instanceof Error) { throw (Error) cause; } else if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else if (cause instanceof InterruptedException) { throw (InterruptedException) cause; } else { throw new UndeclaredThrowableException(cause); } } }
From source file:com.frameworkset.commons.dbcp2.BasicDataSource.java
/** * Create (if necessary) and return a connection to the database. * * @throws SQLException if a database access error occurs * @return a database connection/*from www . j a v a2 s. c om*/ */ @Override public Connection getConnection() throws SQLException { if (Utils.IS_SECURITY_ENABLED) { PrivilegedExceptionAction<Connection> action = new PaGetConnection(); try { return AccessController.doPrivileged(action); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof SQLException) { throw (SQLException) cause; } throw new SQLException(e); } } return createDataSource().getConnection(); }