public ManagedAuditLoggerImpl createNewConfiguration(boolean manualCommit) { if (childImpls == null) { throw ControllerMessages.MESSAGES.canOnlyCreateChildAuditLoggerForMainAuditLogger(); } ManagedAuditLoggerImpl child = new ManagedAuditLoggerImpl(this, manualCommit); childImpls.add(child); return child; }
@Override public void logJmxMethodAccess(boolean readOnly, String userId, String domainUUID, AccessMechanism accessMechanism, InetAddress remoteAddress, String methodName, String[] methodSignature, Object[] methodParams, Throwable error) { config.lock(); try { if (config.isBooting() && !isLogBoot()) { return; } if (readOnly && !isLogReadOnly()) { return; } storeLogItem( AuditLogItem.createMethodAccessItem(config.getAsVersion(), readOnly, config.isBooting(), userId, domainUUID, accessMechanism, remoteAddress, methodName, methodSignature, methodParams, error)); } catch (Exception e) { handleLoggingException(e); } finally { applyHandlerUpdates(); config.unlock(); } }
private boolean skipLogging(boolean readOnly) { if (config.isBooting() && !isLogBoot() || readOnly && !isLogReadOnly()) { if (getLoggerStatus() == Status.DISABLED) { // switch to the fast path for the next event runDisabledFastPath.set(true); } return true; } return false; }
/** protected by config's audit lock */ private void storeLogItem(AuditLogItem item) throws IOException { switch (getLoggerStatus()) { case QUEUEING: queuedItems.add(item); break; case LOGGING: writeLogItem(item); break; case DISABLE_NEXT: writeLogItem(item); config.setLoggerStatus(Status.DISABLED); case DISABLED: // ignore break; } }
@Override public void log(boolean readOnly, ResultAction resultAction, String userId, String domainUUID, AccessMechanism accessMechanism, InetAddress remoteAddress, Resource resultantModel, List<ModelNode> operations) { if (runDisabledFastPath.get()) return; config.lock(); try { if (skipLogging(readOnly)) { return; } storeLogItem( AuditLogItem.createModelControllerItem(config.getAsVersion(), readOnly, config.isBooting(), resultAction, userId, domainUUID, accessMechanism, remoteAddress, resultantModel, operations)); } catch (Exception e) { handleLoggingException(e); } finally { applyHandlerUpdates(); config.unlock(); } }
@Override public void setLoggerStatus(final Status newStatus) { config.lock(); try { if (newStatus == Status.DISABLE_NEXT && config.getLoggerStatus() == Status.DISABLED) { return; } config.setLoggerStatus(newStatus); if (newStatus == Status.LOGGING){ for (AuditLogItem record : queuedItems) { try { writeLogItem(record); } catch (Exception e) { handleLoggingException(e); } } queuedItems.clear(); } else if (newStatus == Status.DISABLED){ queuedItems.clear(); } runDisabledFastPath.set(false); } finally { config.unlock(); } }
/** protected by config's audit lock */ private void handleLoggingException(final Exception e) { ControllerLogger.MGMT_OP_LOGGER.failedToUpdateAuditLog(e); if (++failureCount == MAX_FAILURE_COUNT) { // Continuous failure likely indicates some configuration problem setLoggerStatus(Status.DISABLED); ControllerLogger.MGMT_OP_LOGGER.disablingLoggingDueToFailures(failureCount); } }
@Override public void applyChanges() { config.lock(); try { if (!config.isManualCommit()) { //i18n not needed, normal users will never end up here throw new IllegalStateException("Attempt was made to manually apply changes when manual commit was not configured"); } applyHandlerUpdates(); } finally { config.unlock(); } }
@Override public void logJmxMethodAccess(boolean readOnly, String userId, String domainUUID, AccessMechanism accessMechanism, InetAddress remoteAddress, String methodName, String[] methodSignature, Object[] methodParams, Throwable error) { if (runDisabledFastPath.get()) return; config.lock(); try { if (skipLogging(readOnly)) { return; } storeLogItem( AuditLogItem.createMethodAccessItem(config.getAsVersion(), readOnly, config.isBooting(), userId, domainUUID, accessMechanism, remoteAddress, methodName, methodSignature, methodParams, error)); } catch (Exception e) { handleLoggingException(e); } finally { applyHandlerUpdates(); config.unlock(); } }
/** protected by config's audit lock */ private void storeLogItem(AuditLogItem item) throws IOException { switch (getLoggerStatus()) { case QUEUEING: queuedItems.add(item); break; case LOGGING: writeLogItem(item); break; case DISABLE_NEXT: writeLogItem(item); config.setLoggerStatus(Status.DISABLED); case DISABLED: // switch to the fast path for the next event runDisabledFastPath.set(true); break; } }
@Override public void setLoggerStatus(final Status newStatus) { config.lock(); try { if (newStatus == Status.DISABLE_NEXT && config.getLoggerStatus() == Status.DISABLED) { return; } config.setLoggerStatus(newStatus); if (newStatus == Status.LOGGING){ for (AuditLogItem record : queuedItems) { try { writeLogItem(record); } catch (Exception e) { handleLoggingException(e); } } queuedItems.clear(); } else if (newStatus == Status.DISABLED){ queuedItems.clear(); } runDisabledFastPath.set(false); } finally { config.unlock(); } }
/** protected by config's audit lock */ private void handleLoggingException(final Exception e) { ControllerLogger.MGMT_OP_LOGGER.failedToUpdateAuditLog(e); if (++failureCount == MAX_FAILURE_COUNT) { // Continuous failure likely indicates some configuration problem setLoggerStatus(Status.DISABLED); ControllerLogger.MGMT_OP_LOGGER.disablingLoggingDueToFailures(failureCount); } }
@Override public void applyChanges() { config.lock(); try { if (!config.isManualCommit()) { //i18n not needed, normal users will never end up here throw new IllegalStateException("Attempt was made to manually apply changes when manual commit was not configured"); } applyHandlerUpdates(); } finally { config.unlock(); } }
public ManagedAuditLoggerImpl createNewConfiguration(boolean manualCommit) { if (childImpls == null) { throw ControllerLogger.ROOT_LOGGER.canOnlyCreateChildAuditLoggerForMainAuditLogger(); } ManagedAuditLoggerImpl child = new ManagedAuditLoggerImpl(this, manualCommit); childImpls.add(child); return child; }
@Override public void log(boolean readOnly, ResultAction resultAction, String userId, String domainUUID, AccessMechanism accessMechanism, InetAddress remoteAddress, Resource resultantModel, List<ModelNode> operations) { config.lock(); try { if (config.isBooting() && !isLogBoot()) { return; } if (readOnly && !isLogReadOnly()) { return; } storeLogItem( AuditLogItem.createModelControllerItem(config.getAsVersion(), readOnly, config.isBooting(), resultAction, userId, domainUUID, accessMechanism, remoteAddress, resultantModel, operations)); } catch (Exception e) { handleLoggingException(e); } finally { applyHandlerUpdates(); config.unlock(); } }
@Override public void log(boolean readOnly, ResultAction resultAction, String userId, String domainUUID, AccessMechanism accessMechanism, InetAddress remoteAddress, Resource resultantModel, List<ModelNode> operations) { if (runDisabledFastPath.get()) return; config.lock(); try { if (skipLogging(readOnly)) { return; } storeLogItem( AuditLogItem.createModelControllerItem(config.getAsVersion(), readOnly, config.isBooting(), resultAction, userId, domainUUID, accessMechanism, remoteAddress, resultantModel, operations)); } catch (Exception e) { handleLoggingException(e); } finally { applyHandlerUpdates(); config.unlock(); } }
private boolean skipLogging(boolean readOnly) { if (config.isBooting() && !isLogBoot() || readOnly && !isLogReadOnly()) { if (getLoggerStatus() == Status.DISABLED) { // switch to the fast path for the next event runDisabledFastPath.set(true); } return true; } return false; }
/** protected by config's audit lock */ private void storeLogItem(AuditLogItem item) throws IOException { switch (getLoggerStatus()) { case QUEUEING: queuedItems.add(item); break; case LOGGING: writeLogItem(item); break; case DISABLE_NEXT: writeLogItem(item); config.setLoggerStatus(Status.DISABLED); case DISABLED: // switch to the fast path for the next event runDisabledFastPath.set(true); break; } }
@Override public void setLoggerStatus(final Status newStatus) { config.lock(); try { if (newStatus == Status.DISABLE_NEXT && config.getLoggerStatus() == Status.DISABLED) { return; } config.setLoggerStatus(newStatus); if (newStatus == Status.LOGGING){ for (AuditLogItem record : queuedItems) { try { writeLogItem(record); } catch (Exception e) { handleLoggingException(e); } } } else if (newStatus == Status.DISABLED){ queuedItems.clear(); } } finally { config.unlock(); } }
/** protected by config's audit lock */ private void handleLoggingException(final Exception e) { ControllerLogger.MGMT_OP_LOGGER.failedToUpdateAuditLog(e); if (++failureCount == MAX_FAILURE_COUNT) { // Continuous failure likely indicates some configuration problem setLoggerStatus(Status.DISABLED); ControllerLogger.MGMT_OP_LOGGER.disablingLoggingDueToFailures(failureCount); } }