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.");
}
}
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;
}
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());
}
Aggregations