1 package org.openecomp.sdc.be.resources.data;
3 * ============LICENSE_START=======================================================
5 * ================================================================================
6 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 import org.apache.commons.lang3.tuple.ImmutablePair;
23 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
24 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
25 import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28 import java.util.HashMap;
31 public class ConsumerData extends GraphNode {
33 private ConsumerDataDefinition consumerDataDefinition;
35 public ConsumerData() {
36 super(NodeTypeEnum.ConsumerCredentials);
37 consumerDataDefinition = new ConsumerDataDefinition();
40 public ConsumerData(ConsumerDataDefinition consumerDataDefinition) {
41 super(NodeTypeEnum.ConsumerCredentials);
42 this.consumerDataDefinition = consumerDataDefinition;
46 public ConsumerData(Map<String, Object> properties) {
47 super(NodeTypeEnum.ConsumerCredentials);
48 consumerDataDefinition = new ConsumerDataDefinition();
49 consumerDataDefinition.setConsumerDetailsLastupdatedtime(
50 (Long) properties.get(GraphPropertiesDictionary.CONSUMER_DETAILS_LAST_UPDATED_TIME.getProperty()));
51 consumerDataDefinition.setConsumerLastAuthenticationTime(
52 (Long) properties.get(GraphPropertiesDictionary.CONSUMER_LAST_AUTHENTICATION_TIME.getProperty()));
53 consumerDataDefinition
54 .setConsumerName((String) properties.get(GraphPropertiesDictionary.CONSUMER_NAME.getProperty()));
55 consumerDataDefinition.setConsumerPassword(
56 (String) properties.get(GraphPropertiesDictionary.CONSUMER_PASSWORD.getProperty()));
57 consumerDataDefinition
58 .setConsumerSalt((String) properties.get(GraphPropertiesDictionary.CONSUMER_SALT.getProperty()));
59 consumerDataDefinition.setLastModfierAtuid(
60 (String) properties.get(GraphPropertiesDictionary.LAST_MODIFIER_USER_ID.getProperty()));
65 public String getUniqueIdKey() {
66 return GraphPropertiesDictionary.CONSUMER_NAME.getProperty();
70 public String getUniqueId() {
71 return consumerDataDefinition.getConsumerName();
74 public ConsumerDataDefinition getConsumerDataDefinition() {
75 return consumerDataDefinition;
79 public Map<String, Object> toGraphMap() {
80 Map<String, Object> map = new HashMap<>();
81 addIfExists(map, GraphPropertiesDictionary.CONSUMER_NAME, this.consumerDataDefinition.getConsumerName());
82 addIfExists(map, GraphPropertiesDictionary.CONSUMER_PASSWORD,
83 this.consumerDataDefinition.getConsumerPassword());
84 addIfExists(map, GraphPropertiesDictionary.CONSUMER_SALT, this.consumerDataDefinition.getConsumerSalt());
85 addIfExists(map, GraphPropertiesDictionary.CONSUMER_LAST_AUTHENTICATION_TIME,
86 this.consumerDataDefinition.getConsumerLastAuthenticationTime());
87 addIfExists(map, GraphPropertiesDictionary.CONSUMER_DETAILS_LAST_UPDATED_TIME,
88 this.consumerDataDefinition.getConsumerDetailsLastupdatedtime());
89 addIfExists(map, GraphPropertiesDictionary.LAST_MODIFIER_USER_ID,
90 this.consumerDataDefinition.getLastModfierAtuid());
95 //added to handle fortify security violation - t avoid printing consumer data to log
97 public ImmutablePair<String, Object> getKeyValueIdForLog() {
98 return new ImmutablePair<>(getUniqueIdKey(), "consumerName");
102 public String toString() {
103 return "ConsumerData [consumerDataDefinition=" + consumerDataDefinition + "]";