Skip to content
This repository was archived by the owner on Dec 23, 2017. It is now read-only.

Commit dad9d09

Browse files
edmundoajoschi
authored andcommitted
Integrate audit log (#18)
1 parent 44689a7 commit dad9d09

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/main/java/org/graylog/plugins/usagestatistics/UsageStatsModule.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.fasterxml.jackson.databind.ObjectMapper;
1919
import okhttp3.OkHttpClient;
20+
import org.graylog.plugins.usagestatistics.audit.UsageStatsAuditEventTypes;
2021
import org.graylog.plugins.usagestatistics.collectors.ClusterCollector;
2122
import org.graylog.plugins.usagestatistics.collectors.CollectorCollector;
2223
import org.graylog.plugins.usagestatistics.collectors.ElasticsearchCollector;
@@ -58,5 +59,7 @@ protected void configure() {
5859
addRestResource(UsageStatsOptOutResource.class);
5960

6061
addConfigBeans();
62+
63+
addAuditEventTypes(UsageStatsAuditEventTypes.class);
6164
}
6265
}

src/main/java/org/graylog/plugins/usagestatistics/UsageStatsOptOutResource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import io.swagger.annotations.ApiResponse;
2222
import io.swagger.annotations.ApiResponses;
2323
import org.apache.shiro.authz.annotation.RequiresAuthentication;
24+
import org.graylog.plugins.usagestatistics.audit.UsageStatsAuditEventTypes;
25+
import org.graylog2.audit.jersey.AuditEvent;
2426
import org.graylog2.plugin.rest.PluginRestResource;
2527
import org.graylog2.shared.rest.resources.RestResource;
2628

@@ -80,6 +82,7 @@ public UsageStatsOptOutState getOptOutState() {
8082
@ApiResponse(code = 400, message = "Missing or invalid opt-out state"),
8183
@ApiResponse(code = 500, message = "Internal Server Error")
8284
})
85+
@AuditEvent(type = UsageStatsAuditEventTypes.OPT_OUT_UPDATE)
8386
public void setOptOutState(@Valid @NotNull UsageStatsOptOutState optOutState) {
8487
checkPermission(CLUSTER_CONFIG_ENTRY_CREATE, CLUSTER_CONFIG_INSTANCE);
8588

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright (C) 2015 Graylog, Inc. ([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.graylog.plugins.usagestatistics.audit;
17+
18+
import com.google.common.collect.ImmutableSet;
19+
import org.graylog2.audit.PluginAuditEventTypes;
20+
21+
import java.util.Set;
22+
23+
public class UsageStatsAuditEventTypes implements PluginAuditEventTypes {
24+
private static final String NAMESPACE = "usage_statistics:";
25+
26+
public static final String OPT_OUT_UPDATE = NAMESPACE + "opt_out:update";
27+
28+
private static final Set<String> EVENT_TYPES = ImmutableSet.<String>builder()
29+
.add(OPT_OUT_UPDATE)
30+
.build();
31+
32+
@Override
33+
public Set<String> auditEventTypes() {
34+
return EVENT_TYPES;
35+
}
36+
}

0 commit comments

Comments
 (0)