ARTEMIS-4293 add mngmnt ops to clear authn/z caches
This commit is contained in:
parent
ff4c697e25
commit
15aafe0b70
|
@ -2653,4 +2653,18 @@ public interface AuditLogger {
|
||||||
|
|
||||||
@LogMessage(id = 601768, value = "{} connection {} for user {} destroyed", level = LogMessage.Level.INFO)
|
@LogMessage(id = 601768, value = "{} connection {} for user {} destroyed", level = LogMessage.Level.INFO)
|
||||||
void destroyedConnection(String protocol, String connectionID, String user);
|
void destroyedConnection(String protocol, String connectionID, String user);
|
||||||
|
|
||||||
|
static void clearAuthenticationCache(Object source) {
|
||||||
|
BASE_LOGGER.clearAuthenticationCache(getCaller(), source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@LogMessage(id = 601769, value = "User {} is clearing authentication cache on target resource: {}", level = LogMessage.Level.INFO)
|
||||||
|
void clearAuthenticationCache(String user, Object source);
|
||||||
|
|
||||||
|
static void clearAuthorizationCache(Object source) {
|
||||||
|
BASE_LOGGER.clearAuthorizationCache(getCaller(), source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@LogMessage(id = 601770, value = "User {} is clearing authorization cache on target resource: {}", level = LogMessage.Level.INFO)
|
||||||
|
void clearAuthorizationCache(String user, Object source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2006,5 +2006,11 @@ public interface ActiveMQServerControl {
|
||||||
|
|
||||||
@Attribute(desc = "Scan all paged destinations to rebuild the page counters")
|
@Attribute(desc = "Scan all paged destinations to rebuild the page counters")
|
||||||
void rebuildPageCounters() throws Exception;
|
void rebuildPageCounters() throws Exception;
|
||||||
|
|
||||||
|
@Operation(desc = "Clear the authentication cache", impact = MBeanOperationInfo.ACTION)
|
||||||
|
void clearAuthenticationCache() throws Exception;
|
||||||
|
|
||||||
|
@Operation(desc = "Clear the authorization cache", impact = MBeanOperationInfo.ACTION)
|
||||||
|
void clearAuthorizationCache() throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4664,5 +4664,21 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
||||||
}
|
}
|
||||||
throw ActiveMQMessageBundle.BUNDLE.embeddedWebServerNotFound();
|
throw ActiveMQMessageBundle.BUNDLE.embeddedWebServerNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearAuthenticationCache() {
|
||||||
|
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||||
|
AuditLogger.clearAuthenticationCache(this.server);
|
||||||
|
}
|
||||||
|
((SecurityStoreImpl)server.getSecurityStore()).invalidateAuthenticationCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearAuthorizationCache() {
|
||||||
|
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||||
|
AuditLogger.clearAuthorizationCache(this.server);
|
||||||
|
}
|
||||||
|
((SecurityStoreImpl)server.getSecurityStore()).invalidateAuthorizationCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -424,12 +424,10 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC
|
||||||
logger.debug("Skipping authentication cache due to exception: {}", e.getMessage());
|
logger.debug("Skipping authentication cache due to exception: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// public for testing purposes
|
|
||||||
public void invalidateAuthorizationCache() {
|
public void invalidateAuthorizationCache() {
|
||||||
authorizationCache.invalidateAll();
|
authorizationCache.invalidateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public for testing purposes
|
|
||||||
public void invalidateAuthenticationCache() {
|
public void invalidateAuthenticationCache() {
|
||||||
authenticationCache.invalidateAll();
|
authenticationCache.invalidateAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,32 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
||||||
Wait.assertEquals(usingCore() ? 8 : 1, () -> serverControl.getAuthorizationCacheSize());
|
Wait.assertEquals(usingCore() ? 8 : 1, () -> serverControl.getAuthorizationCacheSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClearingSecurityCaches() throws Exception {
|
||||||
|
ActiveMQServerControl serverControl = createManagementControl();
|
||||||
|
|
||||||
|
ServerLocator loc = createInVMNonHALocator();
|
||||||
|
ClientSessionFactory csf = createSessionFactory(loc);
|
||||||
|
ClientSession session = csf.createSession("myUser", "myPass", false, true, false, false, 0);
|
||||||
|
session.start();
|
||||||
|
|
||||||
|
final String address = "ADDRESS";
|
||||||
|
serverControl.createAddress(address, "MULTICAST");
|
||||||
|
ClientProducer producer = session.createProducer(address);
|
||||||
|
ClientMessage m = session.createMessage(true);
|
||||||
|
m.putStringProperty("hello", "world");
|
||||||
|
producer.send(m);
|
||||||
|
|
||||||
|
Assert.assertTrue(serverControl.getAuthenticationCacheSize() > 0);
|
||||||
|
Wait.assertTrue(() -> serverControl.getAuthorizationCacheSize() > 0);
|
||||||
|
|
||||||
|
serverControl.clearAuthenticationCache();
|
||||||
|
serverControl.clearAuthorizationCache();
|
||||||
|
|
||||||
|
Assert.assertEquals(usingCore() ? 1 : 0, serverControl.getAuthenticationCacheSize());
|
||||||
|
Assert.assertEquals(usingCore() ? 7 : 0, serverControl.getAuthorizationCacheSize());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetConnectors() throws Exception {
|
public void testGetConnectors() throws Exception {
|
||||||
ActiveMQServerControl serverControl = createManagementControl();
|
ActiveMQServerControl serverControl = createManagementControl();
|
||||||
|
|
|
@ -1754,6 +1754,16 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
||||||
public void rebuildPageCounters() throws Exception {
|
public void rebuildPageCounters() throws Exception {
|
||||||
proxy.invokeOperation("rebuildPageCounters");
|
proxy.invokeOperation("rebuildPageCounters");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearAuthenticationCache() throws Exception {
|
||||||
|
proxy.invokeOperation("clearAuthenticationCache");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearAuthorizationCache() throws Exception {
|
||||||
|
proxy.invokeOperation("clearAuthorizationCache");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue