2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.resources.data.auditing;
23 import com.datastax.driver.core.utils.UUIDs;
24 import com.datastax.driver.mapping.annotations.ClusteringColumn;
25 import com.datastax.driver.mapping.annotations.Column;
26 import com.datastax.driver.mapping.annotations.PartitionKey;
27 import com.datastax.driver.mapping.annotations.Table;
28 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
29 import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
31 import java.text.SimpleDateFormat;
32 import java.util.Date;
33 import java.util.TimeZone;
34 import java.util.UUID;
36 @Table(keyspace = "sdcaudit", name = AuditingTypesConstants.AUTH_EVENT_TYPE)
37 public class AuthEvent extends AuditingGenericEvent {
40 protected UUID timebaseduuid;
43 protected Date timestamp1;
50 @Column(name = "auth_status")
51 private String authStatus;
56 protected String action;
58 protected String status;
60 @Column(name = "description")
61 protected String desc;
63 @Column(name = "request_id")
64 protected String requestId;
66 public AuthEvent(String action, CommonAuditData commonAuditData, String user, String authUrl, String realm, String authStatus) {
69 this.requestId = commonAuditData.getRequestId();
70 this.desc = commonAuditData.getDescription();
71 this.status = commonAuditData.getStatus();
72 this.authStatus = authStatus;
78 //Required to be public as it is used by Cassandra driver on get operation
80 timestamp1 = new Date();
81 timebaseduuid = UUIDs.timeBased();
84 public String getUrl() {
88 public void setUrl(String url) {
92 public String getUser() {
96 public void setUser(String user) {
100 public String getAuthStatus() {
104 public void setAuthStatus(String authStatus) {
105 this.authStatus = authStatus;
108 public String getRealm() {
112 public void setRealm(String realm) {
116 public UUID getTimebaseduuid() {
117 return timebaseduuid;
120 public void setTimebaseduuid(UUID timebaseduuid) {
121 this.timebaseduuid = timebaseduuid;
124 public Date getTimestamp1() {
128 public void setTimestamp1(Date timestamp1) {
129 this.timestamp1 = timestamp1;
132 public String getAction() {
136 public void setAction(String action) {
137 this.action = action;
140 public String getStatus() {
144 public void setStatus(String status) {
145 this.status = status;
148 public String getDesc() {
152 public void setDesc(String desc) {
156 public String getRequestId() {
160 public void setRequestId(String requestId) {
161 this.requestId = requestId;
164 public void setTimestamp1(String timestamp) {
165 this.timestamp1 = parseDateFromString(timestamp);
169 public void fillFields() {
170 fields.put(AuditingFieldsKey.AUDIT_AUTH_URL.getDisplayName(), getUrl());
172 fields.put(AuditingFieldsKey.AUDIT_AUTH_USER.getDisplayName(), getUser());
173 fields.put(AuditingFieldsKey.AUDIT_AUTH_STATUS.getDisplayName(), getAuthStatus());
174 fields.put(AuditingFieldsKey.AUDIT_AUTH_REALM.getDisplayName(), getRealm());
175 fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
176 fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
177 fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
178 fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
179 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
180 simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
181 fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));