Containerization feature of SO
[so.git] / adapters / mso-adapter-utils / src / main / java / org / onap / so / cloud / CloudIdentity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.onap.so.cloud;
22
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import com.openpojo.business.annotation.BusinessKey;
25 import org.apache.commons.lang3.builder.HashCodeBuilder;
26
27 import java.util.Comparator;
28
29 import org.apache.commons.lang3.builder.EqualsBuilder;
30 import org.apache.commons.lang3.builder.ToStringBuilder;
31 import org.apache.commons.lang3.builder.ToStringStyle;
32
33 /**
34  * JavaBean JSON class for a CloudIdentity. This bean represents a cloud identity
35  * service instance (i.e. a DCP node) in the NVP/AIC cloud. It will be loaded via
36  * CloudConfig object, of which it is a component (a CloudConfig JSON configuration
37  * file may contain multiple CloudIdentity definitions).
38  *
39  * Note that this is only used to access Cloud Configurations loaded from a
40  * JSON config file, so there are no explicit setters.
41  *
42  */
43 public class CloudIdentity {
44         
45     @JsonProperty
46     @BusinessKey
47     private String id;
48     @JsonProperty("identity_url")
49     @BusinessKey
50     private String identityUrl;
51     @JsonProperty("mso_id")
52     @BusinessKey
53     private String msoId;
54     @JsonProperty("mso_pass")
55     @BusinessKey
56     private String msoPass;
57     @JsonProperty("admin_tenant")
58     @BusinessKey
59     private String adminTenant;
60     @JsonProperty("member_role")
61     @BusinessKey
62     private String memberRole;
63     @JsonProperty("tenant_metadata")
64     @BusinessKey
65     private Boolean tenantMetadata;
66     @JsonProperty("identity_server_type")
67     @BusinessKey
68     private ServerType identityServerType;
69     @JsonProperty("identity_authentication_type")
70     @BusinessKey
71     private AuthenticationType identityAuthenticationType;
72     
73     public CloudIdentity() {}
74
75     public String getId () {
76         return id;
77     }
78
79     public void setId (String id) {
80         this.id = id;
81     }
82
83     public String getIdentityUrl() {
84         return this.identityUrl;
85     }
86     public void setIdentityUrl(String url) {
87         this.identityUrl = url;
88     }
89
90     public String getMsoId () {
91         return msoId;
92     }
93
94     public void setMsoId (String id) {
95         this.msoId = id;
96     }
97
98     public String getMsoPass () {
99         return msoPass;
100     }
101
102     public void setMsoPass (String pwd) {
103         this.msoPass = pwd;
104     }
105
106     public String getAdminTenant () {
107         return adminTenant;
108     }
109
110     public void setAdminTenant (String tenant) {
111         this.adminTenant = tenant;
112     }
113
114     public String getMemberRole () {
115         return memberRole;
116     }
117
118     public void setMemberRole (String role) {
119         this.memberRole = role;
120     }
121
122     public Boolean hasTenantMetadata () {
123         return tenantMetadata;
124     }
125
126     public void setTenantMetadata (Boolean meta) {
127         this.tenantMetadata = meta;
128     }
129     
130     public ServerType getIdentityServerType() {
131         return this.identityServerType;
132     }
133     public void setIdentityServerType(ServerType ist) {
134         this.identityServerType = ist;
135     }
136     public String getIdentityServerTypeAsString() {
137         return this.identityServerType.toString();
138     }
139     /**
140          * @return the identityAuthenticationType
141          */
142         public AuthenticationType getIdentityAuthenticationType() {
143                 return identityAuthenticationType;
144         }
145
146         /**
147          * @param identityAuthenticationType the identityAuthenticationType to set
148          */
149         public void setIdentityAuthenticationType(AuthenticationType identityAuthenticationType) {
150                 this.identityAuthenticationType = identityAuthenticationType;
151         }
152
153         @Override
154         public CloudIdentity clone() {
155                 CloudIdentity cloudIdentityCopy = new CloudIdentity();
156
157                 cloudIdentityCopy.id = this.id;
158                 cloudIdentityCopy.identityUrl = this.identityUrl;
159                 cloudIdentityCopy.msoId = this.msoId;
160                 cloudIdentityCopy.msoPass = this.msoPass;
161                 cloudIdentityCopy.adminTenant = this.adminTenant;
162                 cloudIdentityCopy.memberRole = this.memberRole;
163                 cloudIdentityCopy.tenantMetadata = this.tenantMetadata;
164                 cloudIdentityCopy.identityServerType = this.identityServerType;
165                 cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;
166
167                 return cloudIdentityCopy;
168         }
169
170         @Override
171         public String toString() {
172                 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
173                                 .append("identityUrl", getIdentityUrl()).append("msoId", getMsoId())
174                                 .append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
175                                 .append("tenantMetadata", hasTenantMetadata()).append("identityServerType", getIdentityServerType())
176                                 .append("identityAuthenticationType", getIdentityAuthenticationType()).toString();
177         }
178
179         @Override
180         public boolean equals(final Object other) {
181                 if (other == null) {
182                         return false;
183                 }
184                 if (!getClass().equals(other.getClass())) {
185                         return false;
186                 }
187                 CloudIdentity castOther = (CloudIdentity) other;
188                 return new EqualsBuilder().append(getId(), castOther.getId())
189                                 .append(getIdentityUrl(), castOther.getIdentityUrl()).append(getMsoId(), castOther.getMsoId())
190                                 .append(getMsoPass(), castOther.getMsoPass()).append(getAdminTenant(), castOther.getAdminTenant())
191                                 .append(getMemberRole(), castOther.getMemberRole())
192                                 .append(hasTenantMetadata(), castOther.hasTenantMetadata())
193                                 .append(getIdentityServerType(), castOther.getIdentityServerType())
194                                 .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType()).isEquals();
195         }
196
197         @Override
198         public int hashCode() {
199                 return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
200                                 .append(getMsoPass()).append(getAdminTenant()).append(getMemberRole()).append(hasTenantMetadata())
201                                 .append(getIdentityServerType()).append(getIdentityAuthenticationType()).toHashCode();
202         }
203 }