ARTEMIS-3955 consolidate Subject on RemotingConnection
This commit is contained in:
parent
f88381430c
commit
729fdc4aab
|
@ -245,18 +245,13 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAuditSubject(Subject subject) {
|
||||
public void setSubject(Subject subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subject getAuditSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subject getSubject() {
|
||||
return null;
|
||||
return subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -227,15 +227,14 @@ public interface RemotingConnection extends BufferHandler {
|
|||
*/
|
||||
boolean isSupportsFlowControl();
|
||||
|
||||
/*
|
||||
* sets the currently associated subject for this connection
|
||||
* */
|
||||
void setAuditSubject(Subject subject);
|
||||
|
||||
Subject getAuditSubject();
|
||||
/**
|
||||
* sets the currently associated subject for this connection
|
||||
* @param subject
|
||||
*/
|
||||
void setSubject(Subject subject);
|
||||
|
||||
/**
|
||||
* the possibly null identity associated with this connection
|
||||
* the possibly null subject associated with this connection
|
||||
* @return
|
||||
*/
|
||||
Subject getSubject();
|
||||
|
|
|
@ -500,15 +500,10 @@ public class ChannelImplTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAuditSubject(Subject subject) {
|
||||
public void setSubject(Subject subject) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subject getAuditSubject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subject getSubject() {
|
||||
return null;
|
||||
|
|
|
@ -163,10 +163,10 @@ public class ActiveMQProtonRemotingConnection extends AbstractRemotingConnection
|
|||
@Override
|
||||
public Subject getSubject() {
|
||||
SASLResult saslResult = amqpConnection.getSASLResult();
|
||||
if (saslResult != null) {
|
||||
if (saslResult != null && saslResult.getSubject() != null) {
|
||||
return saslResult.getSubject();
|
||||
}
|
||||
return null;
|
||||
return super.getSubject();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -858,18 +858,13 @@ public final class StompConnection implements RemotingConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAuditSubject(Subject subject) {
|
||||
public void setSubject(Subject subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subject getAuditSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subject getSubject() {
|
||||
return null;
|
||||
return subject;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -182,15 +182,10 @@ public class ManagementRemotingConnection implements RemotingConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setAuditSubject(Subject subject) {
|
||||
public void setSubject(Subject subject) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subject getAuditSubject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subject getSubject() {
|
||||
return null;
|
||||
|
|
|
@ -273,7 +273,7 @@ public class ServerSessionPacketHandler implements ChannelHandler {
|
|||
}
|
||||
if (AuditLogger.isAnyLoggingEnabled()) {
|
||||
AuditLogger.setRemoteAddress(remotingConnection.getRemoteAddress());
|
||||
AuditLogger.setCurrentCaller(remotingConnection.getAuditSubject());
|
||||
AuditLogger.setCurrentCaller(remotingConnection.getSubject());
|
||||
}
|
||||
final byte type = packet.getType();
|
||||
switch (type) {
|
||||
|
|
|
@ -86,7 +86,7 @@ public class ActiveMQPacketHandler implements ChannelHandler {
|
|||
|
||||
if (AuditLogger.isAnyLoggingEnabled()) {
|
||||
AuditLogger.setRemoteAddress(connection.getRemoteAddress());
|
||||
AuditLogger.setCurrentCaller(connection.getAuditSubject());
|
||||
AuditLogger.setCurrentCaller(connection.getSubject());
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
|
|
|
@ -190,7 +190,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC
|
|||
}
|
||||
|
||||
if (connection != null) {
|
||||
connection.setAuditSubject(subject);
|
||||
connection.setSubject(subject);
|
||||
}
|
||||
if (AuditLogger.isResourceLoggingEnabled()) {
|
||||
AuditLogger.userSuccesfullyAuthenticatedInAudit(subject, connection.getRemoteAddress());
|
||||
|
|
|
@ -1721,7 +1721,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
checkSessionLimit(validatedUser);
|
||||
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.createCoreSession(this, connection.getAuditSubject(), connection.getRemoteAddress(), name, username, "****", minLargeMessageSize, connection, autoCommitSends,
|
||||
AuditLogger.createCoreSession(this, connection.getSubject(), connection.getRemoteAddress(), name, username, "****", minLargeMessageSize, connection, autoCommitSends,
|
||||
autoCommitAcks, preAcknowledge, xa, defaultAddress, callback, autoCreateQueues, context, prefixes);
|
||||
}
|
||||
|
||||
|
|
|
@ -1884,7 +1884,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue {
|
|||
if (AuditLogger.isMessageLoggingEnabled()) {
|
||||
// it's possible for the consumer to be null (e.g. acking the message administratively)
|
||||
final ServerSession session = consumer != null ? server.getSessionByID(consumer.getSessionID()) : null;
|
||||
final Subject subject = session == null ? null : session.getRemotingConnection().getAuditSubject();
|
||||
final Subject subject = session == null ? null : session.getRemotingConnection().getSubject();
|
||||
final String remoteAddress = session == null ? null : session.getRemotingConnection().getRemoteAddress();
|
||||
|
||||
if (transactional) {
|
||||
|
|
|
@ -490,7 +490,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
|
|||
Message message = reference.getMessage();
|
||||
|
||||
if (AuditLogger.isMessageLoggingEnabled()) {
|
||||
AuditLogger.coreConsumeMessage(session.getRemotingConnection().getAuditSubject(), session.getRemotingConnection().getRemoteAddress(), getQueueName().toString(), reference.toString());
|
||||
AuditLogger.coreConsumeMessage(session.getRemotingConnection().getSubject(), session.getRemotingConnection().getRemoteAddress(), getQueueName().toString(), reference.toString());
|
||||
}
|
||||
if (server.hasBrokerMessagePlugins()) {
|
||||
server.callBrokerMessagePlugins(plugin -> plugin.beforeDeliver(this, reference));
|
||||
|
|
|
@ -530,7 +530,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
final boolean supportLargeMessage,
|
||||
final Integer credits) throws Exception {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.createCoreConsumer(this, remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), consumerID, queueName, filterString, priority, browseOnly, supportLargeMessage, credits);
|
||||
AuditLogger.createCoreConsumer(this, remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), consumerID, queueName, filterString, priority, browseOnly, supportLargeMessage, credits);
|
||||
}
|
||||
final SimpleString unPrefixedQueueName = removePrefix(queueName);
|
||||
|
||||
|
@ -720,7 +720,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
@Override
|
||||
public Queue createQueue(QueueConfiguration queueConfiguration) throws Exception {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.createQueue(this, remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), queueConfiguration);
|
||||
AuditLogger.createQueue(this, remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), queueConfiguration);
|
||||
}
|
||||
|
||||
queueConfiguration
|
||||
|
@ -930,7 +930,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
EnumSet<RoutingType> routingTypes,
|
||||
final boolean autoCreated) throws Exception {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.serverSessionCreateAddress(this.getName(), remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), address, routingTypes, autoCreated);
|
||||
AuditLogger.serverSessionCreateAddress(this.getName(), remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), address, routingTypes, autoCreated);
|
||||
}
|
||||
|
||||
SimpleString realAddress = CompositeAddress.extractAddressName(address);
|
||||
|
@ -950,7 +950,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
@Override
|
||||
public AddressInfo createAddress(AddressInfo addressInfo, boolean autoCreated) throws Exception {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.serverSessionCreateAddress(this.getName(), remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), addressInfo, autoCreated);
|
||||
AuditLogger.serverSessionCreateAddress(this.getName(), remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), addressInfo, autoCreated);
|
||||
}
|
||||
|
||||
AddressInfo art = getAddressAndRoutingType(addressInfo);
|
||||
|
@ -1040,7 +1040,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
@Override
|
||||
public void createSharedQueue(QueueConfiguration queueConfiguration) throws Exception {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.createSharedQueue(this, remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), queueConfiguration);
|
||||
AuditLogger.createSharedQueue(this, remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), queueConfiguration);
|
||||
}
|
||||
queueConfiguration.setAddress(removePrefix(queueConfiguration.getAddress()));
|
||||
|
||||
|
@ -1167,7 +1167,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
@Override
|
||||
public void deleteQueue(final SimpleString queueToDelete) throws Exception {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.destroyQueue(this, remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), queueToDelete);
|
||||
AuditLogger.destroyQueue(this, remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), queueToDelete);
|
||||
}
|
||||
final SimpleString unPrefixedQueueName = removePrefix(queueToDelete);
|
||||
|
||||
|
@ -1842,7 +1842,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
|
||||
if (AuditLogger.isMessageLoggingEnabled()) {
|
||||
if (tx != null && !autoCommitSends) {
|
||||
AuditLogger.addSendToTransaction(remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), message.toString(), tx.toString());
|
||||
AuditLogger.addSendToTransaction(remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), message.toString(), tx.toString());
|
||||
tx.addOperation(new TransactionOperationAbstract() {
|
||||
@Override
|
||||
public void afterCommit(Transaction tx) {
|
||||
|
@ -1851,7 +1851,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
|
||||
@Override
|
||||
public void afterRollback(Transaction tx) {
|
||||
AuditLogger.rolledBackTransaction(remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), tx.toString(), message.toString());
|
||||
AuditLogger.rolledBackTransaction(remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), tx.toString(), message.toString());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -1872,7 +1872,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
}
|
||||
|
||||
private void auditLogSend(Message message, Transaction tx) {
|
||||
AuditLogger.coreSendMessage(remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), message.toString(), routingContext, tx == null ? null : tx.toString());
|
||||
AuditLogger.coreSendMessage(remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), message.toString(), routingContext, tx == null ? null : tx.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2088,7 +2088,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
final Message message,
|
||||
final boolean direct) throws Exception {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.handleManagementMessage(this.getName(), remotingConnection.getAuditSubject(), remotingConnection.getRemoteAddress(), tx, message, direct);
|
||||
AuditLogger.handleManagementMessage(this.getName(), remotingConnection.getSubject(), remotingConnection.getRemoteAddress(), tx, message, direct);
|
||||
}
|
||||
try {
|
||||
securityCheck(removePrefix(message.getAddressSimpleString()), CheckType.MANAGE, this);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class KeyResolver {
|
|||
break;
|
||||
case ROLE_NAME:
|
||||
if (connection != null && connection.getProtocolConnection() != null) {
|
||||
Subject subject = connection.getProtocolConnection().getAuditSubject();
|
||||
Subject subject = connection.getProtocolConnection().getSubject();
|
||||
if (subject != null) {
|
||||
for (RolePrincipal candidateRole : subject.getPrincipals(RolePrincipal.class)) {
|
||||
String roleName = candidateRole.getName();
|
||||
|
|
|
@ -147,7 +147,7 @@ public class KeyResolverTest {
|
|||
RemotingConnection protocolConnection = Mockito.mock(RemotingConnection.class);
|
||||
Mockito.when(connection.getProtocolConnection()).thenReturn(protocolConnection);
|
||||
Subject subject = Mockito.mock(Subject.class);
|
||||
Mockito.when(protocolConnection.getAuditSubject()).thenReturn(subject);
|
||||
Mockito.when(protocolConnection.getSubject()).thenReturn(subject);
|
||||
|
||||
Assert.assertEquals(KeyResolver.NULL_KEY_VALUE, keyResolver.resolve(connection, null, null));
|
||||
|
||||
|
@ -175,7 +175,7 @@ public class KeyResolverTest {
|
|||
RemotingConnection protocolConnection = Mockito.mock(RemotingConnection.class);
|
||||
Mockito.when(connection.getProtocolConnection()).thenReturn(protocolConnection);
|
||||
Subject subject = Mockito.mock(Subject.class);
|
||||
Mockito.when(protocolConnection.getAuditSubject()).thenReturn(subject);
|
||||
Mockito.when(protocolConnection.getSubject()).thenReturn(subject);
|
||||
|
||||
Assert.assertEquals(KeyResolver.NULL_KEY_VALUE, keyResolver.resolve(connection, null, null));
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ public class MQTTSecurityManagerTest extends MQTTTestSupport {
|
|||
RemotingConnection remotingConnection,
|
||||
String securityDomain) {
|
||||
remotingConnection.setClientID(clientID);
|
||||
System.out.println("Setting: " + clientID);
|
||||
return new Subject();
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ public class AdvisoryOpenWireTest extends BasicOpenWireTest {
|
|||
|
||||
final CountDownLatch numConnectionsCreatedViaAdvisoryNotificationsLatch = new CountDownLatch(19);
|
||||
connections[0].createSession(false, Session.AUTO_ACKNOWLEDGE)
|
||||
.createConsumer(AdvisorySupport.getConnectionAdvisoryTopic()).setMessageListener(message -> numConnectionsCreatedViaAdvisoryNotificationsLatch.countDown());
|
||||
.createConsumer(AdvisorySupport.getConnectionAdvisoryTopic()).setMessageListener(message -> numConnectionsCreatedViaAdvisoryNotificationsLatch.countDown());
|
||||
|
||||
try {
|
||||
for (int i = 1; i < connections.length; i++) {
|
||||
|
@ -202,5 +202,4 @@ public class AdvisoryOpenWireTest extends BasicOpenWireTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue