當前位置: 首頁>>代碼示例>>Java>>正文


Java PrivilegedActionException.getException方法代碼示例

本文整理匯總了Java中java.security.PrivilegedActionException.getException方法的典型用法代碼示例。如果您正苦於以下問題:Java PrivilegedActionException.getException方法的具體用法?Java PrivilegedActionException.getException怎麽用?Java PrivilegedActionException.getException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.PrivilegedActionException的用法示例。


在下文中一共展示了PrivilegedActionException.getException方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findResourcesInBundle

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
private Enumeration<URL> findResourcesInBundle(final String resName, final Bundle inBundle) throws IOException {
    Enumeration<URL> resources = null;
    try {
        // Bundle.getResources requires privileges that the client may not
        // have but we need
        // use a doPriv so that only this bundle needs the privileges
        resources = AccessController.doPrivileged(new PrivilegedExceptionAction<Enumeration<URL>>() {
            @Override
            public Enumeration<URL> run() throws IOException {
                return inBundle.getResources(resName);
            }
        });
    } catch (PrivilegedActionException pae) {
        // thrownException can never be a RuntimeException, as that would escape the doPriv normally
        Exception thrownException = pae.getException();
        if (thrownException instanceof IOException) {
            throw (IOException)thrownException;
        } else {
            LOG.warn("Exception during findResourcesInBundle", pae);
        }
    }
    return resources;
}
 
開發者ID:apache,項目名稱:aries-jpa,代碼行數:24,代碼來源:TempBundleDelegatingClassLoader.java

示例2: load

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
@Override
public void load() throws ClassNotFoundException, IOException {
    if (SecurityUtil.isPackageProtectionEnabled()){
        try{
            AccessController.doPrivileged( new PrivilegedDoLoad() );
        } catch (PrivilegedActionException ex){
            Exception exception = ex.getException();
            if (exception instanceof ClassNotFoundException) {
                throw (ClassNotFoundException)exception;
            } else if (exception instanceof IOException) {
                throw (IOException)exception;
            }
            if (log.isDebugEnabled()) {
                log.debug("Unreported exception in load() ", exception);
            }
        }
    } else {
        doLoad();
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:21,代碼來源:StandardManager.java

示例3: doCallbacks

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
/**
 * Invokes all registered callbacks and clears the callback list.
 * Callbacks with higher priorities are called first; those with equal
 * priorities may be called in any order.  If any of the callbacks
 * throws an InvalidObjectException, the callback process is terminated
 * and the exception propagated upwards.
 */
void doCallbacks() throws InvalidObjectException {
    try {
        while (list != null) {
            AccessController.doPrivileged(
                new PrivilegedExceptionAction<Void>()
            {
                public Void run() throws InvalidObjectException {
                    list.obj.validateObject();
                    return null;
                }
            }, list.acc);
            list = list.next;
        }
    } catch (PrivilegedActionException ex) {
        list = null;
        throw (InvalidObjectException) ex.getException();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:ObjectInputStream.java

示例4: plainConnect

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
protected void plainConnect()  throws IOException {
    synchronized (this) {
        if (connected) {
            return;
        }
    }
    SocketPermission p = URLtoSocketPermission(this.url);
    if (p != null) {
        try {
            AccessController.doPrivileged(
                new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        plainConnect0();
                        return null;
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
                throw (IOException) e.getException();
        }
    } else {
        // run without additional permission
        plainConnect0();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:HttpURLConnection.java

示例5: include

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
@Override
public void include(final String relativeUrlPath, final boolean flush)
        throws ServletException, IOException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            AccessController.doPrivileged(
                    new PrivilegedExceptionAction<Void>() {
                @Override
                public Void run() throws Exception {
                    doInclude(relativeUrlPath, flush);
                    return null;
                }
            });
        } catch (PrivilegedActionException e) {
            Exception ex = e.getException();
            if (ex instanceof IOException) {
                throw (IOException) ex;
            } else {
                throw (ServletException) ex;
            }
        }
    } else {
        doInclude(relativeUrlPath, flush);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:26,代碼來源:PageContextImpl.java

示例6: plainConnect

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
protected void plainConnect()  throws IOException {
    synchronized (this) {
        if (connected) {
            return;
        }
    }
    SocketPermission p = URLtoSocketPermission(this.url);
    if (p != null) {
        try {
            AccessController.doPrivilegedWithCombiner(
                new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        plainConnect0();
                        return null;
                    }
                }, null, p
            );
        } catch (PrivilegedActionException e) {
                throw (IOException) e.getException();
        }
    } else {
        // run without additional permission
        plainConnect0();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:HttpURLConnection.java

示例7: check

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
private static void check(PrivilegedCheck action) {
    try {
        AccessController.doPrivileged(action);
    } catch (PrivilegedActionException e) {
        Exception orig = e.getException();
        if (orig instanceof RuntimeException) {
            throw ((RuntimeException) orig);
        }
        orig.printStackTrace();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:TopSecurityManager.java

示例8: Spi

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
public Spi(final Configuration.Parameters params) throws IOException {

            // call in a doPrivileged
            //
            // we have already passed the Configuration.getInstance
            // security check.  also this class is not freely accessible
            // (it is in the "sun" package).

            try {
                AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
                    public Void run() throws IOException {
                        if (params == null) {
                            init();
                        } else {
                            if (!(params instanceof URIParameter)) {
                                throw new IllegalArgumentException
                                        ("Unrecognized parameter: " + params);
                            }
                            URIParameter uriParam = (URIParameter)params;
                            url = uriParam.getURI().toURL();
                            init();
                        }
                        return null;
                    }
                });
            } catch (PrivilegedActionException pae) {
                throw (IOException)pae.getException();
            }

            // if init() throws some other RuntimeException,
            // let it percolate up naturally.
        }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:33,代碼來源:ConfigFile.java

示例9: doAs

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
/**
 * Does something using the Subject inside
 * @param action the action
 * @param in the input byte
 * @return the output byte
 * @throws java.lang.Exception
 */
public byte[] doAs(final Action action, final byte[] in) throws Exception {
    try {
        return Subject.doAs(s, new PrivilegedExceptionAction<byte[]>() {

            @Override
            public byte[] run() throws Exception {
                return action.run(Context.this, in);
            }
        });
    } catch (PrivilegedActionException pae) {
        throw pae.getException();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:Context.java

示例10: writeSession

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
/**
 * Write the provided session to the Store without modifying
 * the copy in memory or triggering passivation events. Does
 * nothing if the session is invalid or past its expiration.
 */
protected void writeSession(Session session) throws IOException {

    if (store == null || !session.isValid()) {
        return;
    }

    try {
        if (SecurityUtil.isPackageProtectionEnabled()){
            try{
                AccessController.doPrivileged(new PrivilegedStoreSave(session));
            }catch(PrivilegedActionException ex){
                Exception exception = ex.getException();
                log.error("Exception in the Store during writeSession: "
                          + exception);
                exception.printStackTrace();                        
            }
        } else {
             store.save(session);
        }   
    } catch (IOException e) {
        log.error(sm.getString
            ("persistentManager.serializeError", session.getIdInternal(), e));
        throw e;
    }

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:PersistentManagerBase.java

示例11: pushIdentity

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
@Override
public ContextStateCache pushIdentity(final Principal principal, final Object credential) throws Exception {
    try {
        return AccessController.doPrivileged(new PrivilegedExceptionAction<ContextStateCache>() {

            @Override
            public ContextStateCache run() throws Exception {
                return NON_PRIVILEGED.pushIdentity(principal, credential);
            }
        });
    } catch (PrivilegedActionException e) {
        throw e.getException();
    }
}
 
開發者ID:mposolda,項目名稱:keycloak-remote-ejb,代碼行數:15,代碼來源:SecurityActions.java

示例12: syncSpi

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
protected void syncSpi() throws BackingStoreException {
    try {
        AccessController.doPrivileged(
            new PrivilegedExceptionAction<Void>() {
            public Void run() throws BackingStoreException {
                syncSpiPrivileged();
                return null;
            }
        });
    } catch (PrivilegedActionException e) {
        throw (BackingStoreException) e.getException();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:FileSystemPreferences.java

示例13: removeNodeSpi

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
/**
 * Called with file lock held (in addition to node locks).
 */
protected void removeNodeSpi() throws BackingStoreException {
    try {
        AccessController.doPrivileged(
            new PrivilegedExceptionAction<Void>() {
            public Void run() throws BackingStoreException {
                if (changeLog.contains(nodeCreate)) {
                    changeLog.remove(nodeCreate);
                    nodeCreate = null;
                    return null;
                }
                if (!dir.exists())
                    return null;
                prefsFile.delete();
                tmpFile.delete();
                // dir should be empty now.  If it's not, empty it
                File[] junk = dir.listFiles();
                if (junk.length != 0) {
                    getLogger().warning(
                       "Found extraneous files when removing node: "
                        + Arrays.asList(junk));
                    for (int i=0; i<junk.length; i++)
                        junk[i].delete();
                }
                if (!dir.delete())
                    throw new BackingStoreException("Couldn't delete dir: "
                                                                     + dir);
                return null;
            }
        });
    } catch (PrivilegedActionException e) {
        throw (BackingStoreException) e.getException();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:37,代碼來源:FileSystemPreferences.java

示例14: call

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
public T call() throws Exception {
    try {
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<T>() {
                public T run() throws Exception {
                    return task.call();
                }
            }, acc);
    } catch (PrivilegedActionException e) {
        throw e.getException();
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:Executors.java

示例15: read

import java.security.PrivilegedActionException; //導入方法依賴的package包/類
@Override
public int read(final byte[] b, final int off, final int len)
    throws IOException {

    if (SecurityUtil.isPackageProtectionEnabled()){
        try{
            Integer result =
                AccessController.doPrivileged(
                    new PrivilegedExceptionAction<Integer>(){

                        @Override
                        public Integer run() throws IOException{
                            Integer integer =
                                Integer.valueOf(ib.read(b, off, len));
                            return integer;
                        }

            });
            return result.intValue();
        } catch(PrivilegedActionException pae){
            Exception e = pae.getException();
            if (e instanceof IOException){
                throw (IOException)e;
            } else {
                throw new RuntimeException(e.getMessage(), e);
            }
        }
    } else {
        return ib.read(b, off, len);
    }
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:32,代碼來源:CoyoteInputStream.java


注:本文中的java.security.PrivilegedActionException.getException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。