2b3b5fbbbf9155a82515a0c65ad3a9778b2f0343
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / elements / ConsumerDataDefinition.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.datatypes.elements;
22
23 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
24
25 public class ConsumerDataDefinition extends ToscaDataDefinition {
26
27     // ECOMP Consumer Name - UTF-8 string up to 255 characters containing the
28     // following characters : ( maybe to limit 4-64 chars ? )
29     // Lowercase characters {a-z}
30     // Uppercase characters {A-Z}
31     // Numbers {0-9}
32     // Dash {-}; this character is not supported as the first character in the
33     // user name
34     // Period {.}; this character is not supported as the first character in the
35     // user name
36     // Underscore {_}
37     // * ECOMP Consumer Password - expected to be SHA-2 256 encrypted value (
38     // SALT + "real" password ) => maximal length 256 bytes = 32 characters
39     // Before storing/comparing please convert upper case letter to lower.
40     // The "normalized" encrypted password should match the following format :
41     // [a-z0-9]{32} = alphanumeric string
42     //
43     // * ECOMP Consumer Salt - alphanumeric string [a-z0-9] , length = 32 chars.
44     // * ECOMP Consumer Last Authentication Time ( for future use) -
45     // time when ECOMP Consumer was authenticated for the last time in
46     // milliseconds from 1970 (GMT) - should be set to "0" on creation .
47     // * ECOMP Consumer Details Last updated time - time of the last update in
48     // milliseconds from 1970 (GMT)
49     // * USER_ID - USER_ID of the last user that created/updated credentials (
50     // should be retrieved from USER_ID header)
51     private String consumerName;
52     private String consumerPassword;
53     private String consumerSalt;
54     private Long consumerLastAuthenticationTime;
55     private Long consumerDetailsLastupdatedtime;
56     private String lastModfierAtuid;
57
58     public ConsumerDataDefinition() {
59
60     }
61
62     public ConsumerDataDefinition(ConsumerDataDefinition a) {
63         this.consumerName = a.consumerName;
64         this.consumerPassword = a.consumerPassword;
65         this.consumerSalt = a.consumerSalt;
66         this.consumerLastAuthenticationTime = a.consumerLastAuthenticationTime;
67         this.consumerDetailsLastupdatedtime = a.consumerDetailsLastupdatedtime;
68         this.lastModfierAtuid = a.lastModfierAtuid;
69
70     }
71
72     public String getConsumerName() {
73         return consumerName;
74     }
75
76     public void setConsumerName(String consumerName) {
77         this.consumerName = consumerName;
78     }
79
80     public String getConsumerPassword() {
81         return consumerPassword;
82     }
83
84     public void setConsumerPassword(String consumerPassword) {
85         this.consumerPassword = consumerPassword;
86     }
87
88     public String getConsumerSalt() {
89         return consumerSalt;
90     }
91
92     public void setConsumerSalt(String consumerSalt) {
93         this.consumerSalt = consumerSalt;
94     }
95
96     public Long getConsumerLastAuthenticationTime() {
97         return consumerLastAuthenticationTime;
98     }
99
100     public void setConsumerLastAuthenticationTime(Long consumerLastAuthenticationTime) {
101         this.consumerLastAuthenticationTime = consumerLastAuthenticationTime;
102     }
103
104     public Long getConsumerDetailsLastupdatedtime() {
105         return consumerDetailsLastupdatedtime;
106     }
107
108     public void setConsumerDetailsLastupdatedtime(Long consumerDetailsLastupdatedtime) {
109         this.consumerDetailsLastupdatedtime = consumerDetailsLastupdatedtime;
110     }
111
112     public String getLastModfierAtuid() {
113         return lastModfierAtuid;
114     }
115
116     public void setLastModfierAtuid(String lastModfierAtuid) {
117         this.lastModfierAtuid = lastModfierAtuid;
118     }
119
120     @Override
121     public String toString() {
122         StringBuilder sb = new StringBuilder();
123         sb.append("ConsumerDataDefinition [").append("consumerName=").append(consumerName).append(",")
124                 .append("consumerPassword=").append(consumerPassword).append(",").append("consumerSalt=")
125                 .append(consumerSalt).append(",").append("consumerLastAuthenticationTime=")
126                 .append(consumerLastAuthenticationTime).append(",").append("consumerDetailsLastupdatedtime=")
127                 .append(consumerDetailsLastupdatedtime).append(",").append("lastModfierAtuid=").append(lastModfierAtuid)
128                 .append("]");
129         return sb.toString();
130     }
131
132     @Override
133     public int hashCode() {
134         final int prime = 31;
135         int result = 1;
136         result = prime * result + ((consumerName == null) ? 0 : consumerName.hashCode());
137         result = prime * result + ((consumerPassword == null) ? 0 : consumerPassword.hashCode());
138         result = prime * result + ((consumerSalt == null) ? 0 : consumerSalt.hashCode());
139         result = prime * result
140                 + ((consumerLastAuthenticationTime == null) ? 0 : consumerLastAuthenticationTime.hashCode());
141         result = prime * result
142                 + ((consumerDetailsLastupdatedtime == null) ? 0 : consumerDetailsLastupdatedtime.hashCode());
143         result = prime * result + ((lastModfierAtuid == null) ? 0 : lastModfierAtuid.hashCode());
144         return result;
145     }
146
147     @Override
148     public boolean equals(Object obj) {
149         if (this == obj) {
150             return true;
151         }
152         if (obj == null) {
153             return false;
154         }
155         if (getClass() != obj.getClass()) {
156             return false;
157         }
158         ConsumerDataDefinition other = (ConsumerDataDefinition) obj;
159         if (consumerName == null) {
160             if (other.consumerName != null) {
161                 return false;
162             }
163         } else if (!consumerName.equals(other.consumerName)) {
164             return false;
165         }
166         if (consumerPassword == null) {
167             if (other.consumerPassword != null) {
168                 return false;
169             }
170         } else if (!consumerPassword.equals(other.consumerPassword)) {
171             return false;
172         }
173
174         if (consumerSalt == null) {
175             if (other.consumerSalt != null) {
176                 return false;
177             }
178         } else if (!consumerSalt.equals(other.consumerSalt)) {
179             return false;
180         }
181
182         if (consumerLastAuthenticationTime == null) {
183             if (other.consumerLastAuthenticationTime != null) {
184                 return false;
185             }
186         } else if (!consumerLastAuthenticationTime.equals(other.consumerLastAuthenticationTime)) {
187             return false;
188         }
189
190         if (consumerDetailsLastupdatedtime == null) {
191             if (other.consumerDetailsLastupdatedtime != null) {
192                 return false;
193             }
194         } else if (!consumerDetailsLastupdatedtime.equals(other.consumerDetailsLastupdatedtime)) {
195             return false;
196         }
197
198         if (lastModfierAtuid == null) {
199             return other.lastModfierAtuid == null;
200         } else {
201             return lastModfierAtuid.equals(other.lastModfierAtuid);
202         }
203
204     }
205
206 }