Example usage for java.security AccessControlException getCause

List of usage examples for java.security AccessControlException getCause

Introduction

In this page you can find the example usage for java.security AccessControlException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.apache.qpid.server.management.plugin.servlet.rest.AbstractServlet.java

private void doWithSubjectAndActor(PrivilegedExceptionAction<Void> privilegedExceptionAction,
        final HttpServletRequest request, final HttpServletResponse resp) {
    Subject subject;//from www.j  a va 2s.  com
    try {
        subject = getAndCacheAuthorizedSubject(request);
    } catch (AccessControlException e) {
        sendError(resp, HttpServletResponse.SC_FORBIDDEN);
        return;
    }

    SecurityManager.setThreadSubject(subject);
    try {
        HttpManagementActor logActor = getLogActorAndCacheInSession(request);
        CurrentActor.set(logActor);
        try {
            Subject.doAs(subject, privilegedExceptionAction);
        } catch (RuntimeException e) {
            LOGGER.error("Unable to perform action", e);
            throw e;
        } catch (PrivilegedActionException e) {
            LOGGER.error("Unable to perform action", e);
            throw new RuntimeException(e.getCause());
        } finally {
            CurrentActor.remove();
        }
    } finally {
        try {
            SecurityManager.setThreadSubject(null);
        } finally {
            AMQShortString.clearLocalCache();
        }
    }
}