only bind the index audit trail if auditing is enabled

If auditing is not enabled, we should not bind the index audit trail as a lifecycle component
since we do not bind all of its dependent classes when auditing is disabled.

Original commit: elastic/x-pack-elasticsearch@39f736ca6a
This commit is contained in:
jaymode 2015-06-12 17:08:31 -04:00
parent 95ad77a778
commit f4ed6282fd
1 changed files with 11 additions and 5 deletions

View File

@ -30,7 +30,7 @@ public class AuditTrailModule extends AbstractShieldModule.Node implements PrePr
public AuditTrailModule(Settings settings) {
super(settings);
enabled = settings.getAsBoolean("shield.audit.enabled", false);
enabled = auditingEnabled(settings);
}
@Override
@ -75,11 +75,17 @@ public class AuditTrailModule extends AbstractShieldModule.Node implements PrePr
}
}
static boolean auditingEnabled(Settings settings) {
return settings.getAsBoolean("shield.audit.enabled", false);
}
public static boolean indexAuditLoggingEnabled(Settings settings) {
String[] outputs = settings.getAsArray("shield.audit.outputs");
for (String output : outputs) {
if (output.equals(IndexAuditTrail.NAME)) {
return true;
if (auditingEnabled(settings)) {
String[] outputs = settings.getAsArray("shield.audit.outputs");
for (String output : outputs) {
if (output.equals(IndexAuditTrail.NAME)) {
return true;
}
}
}
return false;