当前位置: 首页>>代码示例>>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;未经允许,请勿转载。