Search in sources :

Example 1 with TaskPrincipal

use of org.apache.qpid.server.security.auth.TaskPrincipal in project qpid-broker-j by apache.

the class InternalBrokerHolder method shutdown.

@Override
public void shutdown() {
    if (_systemLauncher != null) {
        LOGGER.info("Shutting down Broker instance");
        Subject shutdownSubject = new Subject(true, new HashSet<>(Arrays.asList(_systemLauncher.getSystemPrincipal(), new TaskPrincipal("Shutdown"))), Collections.emptySet(), Collections.emptySet());
        Subject.doAs(shutdownSubject, new PrivilegedAction<Object>() {

            @Override
            public Object run() {
                if (_systemLauncher != null) {
                    _systemLauncher.shutdown();
                }
                return null;
            }
        });
        waitUntilPortsAreFreeIfRequired();
        LOGGER.info("Broker instance shutdown");
    } else {
        LOGGER.info("Nothing to shutdown. Broker instance either was already shut down or not started at all.");
    }
    if (UNCAUGHT_EXCEPTION_HANDLER.getAndResetCount() > 0) {
        throw new RuntimeException("One or more uncaught exceptions occurred prior to end of this test. Check test logs.");
    }
}
Also used : TaskPrincipal(org.apache.qpid.server.security.auth.TaskPrincipal) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Subject(javax.security.auth.Subject)

Example 2 with TaskPrincipal

use of org.apache.qpid.server.security.auth.TaskPrincipal in project qpid-broker-j by apache.

the class AbstractMessageLogger method getActor.

protected String getActor() {
    Subject subject = Subject.getSubject(AccessController.getContext());
    SessionPrincipal sessionPrincipal = getPrincipal(subject, SessionPrincipal.class);
    String message;
    if (sessionPrincipal != null) {
        message = generateSessionMessage(sessionPrincipal.getSession());
    } else {
        ConnectionPrincipal connPrincipal = getPrincipal(subject, ConnectionPrincipal.class);
        if (connPrincipal != null) {
            message = generateConnectionMessage(connPrincipal.getConnection());
        } else {
            TaskPrincipal taskPrincipal = getPrincipal(subject, TaskPrincipal.class);
            if (taskPrincipal != null) {
                message = generateTaskMessage(taskPrincipal);
            } else {
                ManagementConnectionPrincipal managementConnection = getPrincipal(subject, ManagementConnectionPrincipal.class);
                if (managementConnection != null) {
                    message = generateManagementConnectionMessage(managementConnection, getPrincipal(subject, AuthenticatedPrincipal.class));
                } else {
                    message = "<<UNKNOWN>> ";
                }
            }
        }
    }
    return message;
}
Also used : TaskPrincipal(org.apache.qpid.server.security.auth.TaskPrincipal) SessionPrincipal(org.apache.qpid.server.connection.SessionPrincipal) ConnectionPrincipal(org.apache.qpid.server.connection.ConnectionPrincipal) ManagementConnectionPrincipal(org.apache.qpid.server.security.auth.ManagementConnectionPrincipal) Subject(javax.security.auth.Subject) ManagementConnectionPrincipal(org.apache.qpid.server.security.auth.ManagementConnectionPrincipal)

Example 3 with TaskPrincipal

use of org.apache.qpid.server.security.auth.TaskPrincipal in project qpid-broker-j by apache.

the class EmbeddedBrokerPerClassAdminImpl method afterTestMethod.

@Override
public void afterTestMethod(final Class testClass, final Method method) {
    LOGGER.info("========================= stop executing test : " + testClass.getSimpleName() + "#" + method.getName());
    setClassQualifiedTestName(testClass.getName());
    LOGGER.info("========================= cleaning up test environment for test : " + testClass.getSimpleName() + "#" + method.getName());
    Subject deleteSubject = new Subject(true, new HashSet<>(Arrays.asList(_systemLauncher.getSystemPrincipal(), new TaskPrincipal("afterTestMethod"))), Collections.emptySet(), Collections.emptySet());
    Subject.doAs(deleteSubject, (PrivilegedAction<Object>) () -> {
        if (Boolean.getBoolean("broker.clean.between.tests")) {
            _currentVirtualHostNode.delete();
        } else {
            _currentVirtualHostNode.setAttributes(Collections.singletonMap(VirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE, false));
        }
        return null;
    });
    setClassQualifiedTestName(testClass.getName());
    LOGGER.info("========================= cleaning done for test : " + testClass.getSimpleName() + "#" + method.getName());
}
Also used : TaskPrincipal(org.apache.qpid.server.security.auth.TaskPrincipal) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Subject(javax.security.auth.Subject)

Aggregations

Subject (javax.security.auth.Subject)3 TaskPrincipal (org.apache.qpid.server.security.auth.TaskPrincipal)3 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)2 ConnectionPrincipal (org.apache.qpid.server.connection.ConnectionPrincipal)1 SessionPrincipal (org.apache.qpid.server.connection.SessionPrincipal)1 ManagementConnectionPrincipal (org.apache.qpid.server.security.auth.ManagementConnectionPrincipal)1