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.onap.so.db.catalog.beans;
23 import java.util.Date;
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.EnumType;
27 import javax.persistence.Enumerated;
28 import javax.persistence.Id;
29 import javax.persistence.PrePersist;
30 import javax.persistence.PreUpdate;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import org.apache.commons.lang3.builder.EqualsBuilder;
35 import org.apache.commons.lang3.builder.HashCodeBuilder;
36 import org.apache.commons.lang3.builder.ToStringBuilder;
37 import org.apache.commons.lang3.builder.ToStringStyle;
38 import com.fasterxml.jackson.annotation.JsonProperty;
39 import com.openpojo.business.annotation.BusinessKey;
40 import uk.co.blackpepper.bowman.annotation.RemoteResource;
43 * EntityBean class for a CloudIdentity. This bean represents a cloud identity service instance (i.e. a DCP node) in the
44 * NVP/AIC cloud. It will be loaded via CloudConfig object, of which it is a component.
48 @RemoteResource("/cloudIdentity")
49 @Table(name = "identity_services")
50 public class CloudIdentity {
58 @JsonProperty("identity_url")
60 @Column(name = "IDENTITY_URL")
61 private String identityUrl;
63 @JsonProperty("mso_id")
65 @Column(name = "MSO_ID")
68 @JsonProperty("mso_pass")
70 @Column(name = "MSO_PASS")
71 private String msoPass;
73 @JsonProperty("project_domain_name")
75 @Column(name = "PROJECT_DOMAIN_NAME")
76 private String projectDomainName;
78 @JsonProperty("admin_project_domain_name")
80 @Column(name = "ADMIN_PROJECT_DOMAIN_NAME", nullable = false)
81 private String adminProjectDomainName = "Default";
83 @JsonProperty("user_domain_name")
85 @Column(name = "USER_DOMAIN_NAME")
86 private String userDomainName;
88 @JsonProperty("admin_tenant")
90 @Column(name = "ADMIN_TENANT")
91 private String adminTenant;
93 @JsonProperty("member_role")
95 @Column(name = "MEMBER_ROLE")
96 private String memberRole;
98 @JsonProperty("tenant_metadata")
100 @Column(name = "TENANT_METADATA")
101 private Boolean tenantMetadata;
103 @JsonProperty("identity_server_type")
105 @Enumerated(EnumType.STRING)
106 @Column(name = "IDENTITY_SERVER_TYPE")
107 private ServerType identityServerType;
109 @JsonProperty("identity_authentication_type")
111 @Enumerated(EnumType.STRING)
112 @Column(name = "IDENTITY_AUTHENTICATION_TYPE")
113 private AuthenticationType identityAuthenticationType;
115 @JsonProperty("last_updated_by")
117 @Column(name = "LAST_UPDATED_BY")
118 private String lastUpdatedBy;
120 @JsonProperty("creation_timestamp")
122 @Column(name = "CREATION_TIMESTAMP", updatable = false)
123 @Temporal(TemporalType.TIMESTAMP)
124 private Date created;
126 @JsonProperty("update_timestamp")
128 @Column(name = "UPDATE_TIMESTAMP")
129 @Temporal(TemporalType.TIMESTAMP)
130 private Date updated;
132 public CloudIdentity() {}
135 protected void onCreate() {
136 this.created = new Date();
137 this.updated = new Date();
141 protected void onUpdate() {
142 this.updated = new Date();
145 public String getId() {
149 public void setId(String id) {
153 public String getIdentityUrl() {
154 return this.identityUrl;
157 public void setIdentityUrl(String url) {
158 this.identityUrl = url;
161 public String getMsoId() {
165 public void setMsoId(String id) {
169 public String getMsoPass() {
173 public void setMsoPass(String pwd) {
177 public String getAdminTenant() {
181 public String getLastUpdatedBy() {
182 return lastUpdatedBy;
185 public Date getCreated() {
189 public Date getUpdated() {
193 public void setLastUpdatedBy(String lastUpdatedBy) {
194 this.lastUpdatedBy = lastUpdatedBy;
197 public void setCreated(Date created) {
198 this.created = created;
201 public void setUpdated(Date updated) {
202 this.updated = updated;
205 public void setAdminTenant(String tenant) {
206 this.adminTenant = tenant;
209 public String getMemberRole() {
213 public void setMemberRole(String role) {
214 this.memberRole = role;
217 public Boolean getTenantMetadata() {
218 return tenantMetadata;
221 public void setTenantMetadata(Boolean meta) {
222 this.tenantMetadata = meta;
225 public ServerType getIdentityServerType() {
226 return this.identityServerType;
229 public void setIdentityServerType(ServerType ist) {
230 this.identityServerType = ist;
233 public String getIdentityServerTypeAsString() {
234 return this.identityServerType.toString();
238 * @return the identityAuthenticationType
240 public AuthenticationType getIdentityAuthenticationType() {
241 return identityAuthenticationType;
245 * @param identityAuthenticationType the identityAuthenticationType to set
247 public void setIdentityAuthenticationType(AuthenticationType identityAuthenticationType) {
248 this.identityAuthenticationType = identityAuthenticationType;
251 public String getProjectDomainName() {
252 return projectDomainName;
255 public void setProjectDomainName(String projectDomainName) {
256 this.projectDomainName = projectDomainName;
259 public String getAdminProjectDomainName() {
260 return adminProjectDomainName;
263 public void setAdminProjectDomainName(String adminProjectDomainName) {
264 this.adminProjectDomainName = adminProjectDomainName;
267 public String getUserDomainName() {
268 return userDomainName;
271 public void setUserDomainName(String userDomainName) {
272 this.userDomainName = userDomainName;
276 public CloudIdentity clone() {
277 CloudIdentity cloudIdentityCopy = new CloudIdentity();
279 cloudIdentityCopy.id = this.id;
280 cloudIdentityCopy.identityUrl = this.identityUrl;
281 cloudIdentityCopy.msoId = this.msoId;
282 cloudIdentityCopy.msoPass = this.msoPass;
283 cloudIdentityCopy.adminTenant = this.adminTenant;
284 cloudIdentityCopy.memberRole = this.memberRole;
285 cloudIdentityCopy.tenantMetadata = this.tenantMetadata;
286 cloudIdentityCopy.identityServerType = this.identityServerType;
287 cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;
288 cloudIdentityCopy.projectDomainName = this.projectDomainName;
289 cloudIdentityCopy.adminProjectDomainName = this.adminProjectDomainName;
290 cloudIdentityCopy.userDomainName = this.userDomainName;
292 return cloudIdentityCopy;
296 public String toString() {
297 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
298 .append("identityUrl", getIdentityUrl()).append("msoId", getMsoId())
299 .append("projectDomain", getProjectDomainName()).append("userDomain", getUserDomainName())
300 .append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
301 .append("tenantMetadata", getTenantMetadata()).append("identityServerType", getIdentityServerType())
302 .append("identityAuthenticationType", getIdentityAuthenticationType())
303 .append("adminProjectDomainName", getAdminProjectDomainName()).toString();
307 public boolean equals(final Object other) {
311 if (!getClass().equals(other.getClass())) {
314 CloudIdentity castOther = (CloudIdentity) other;
315 return new EqualsBuilder().append(getId(), castOther.getId())
316 .append(getIdentityUrl(), castOther.getIdentityUrl()).append(getMsoId(), castOther.getMsoId())
317 .append(getMsoPass(), castOther.getMsoPass()).append(getAdminTenant(), castOther.getAdminTenant())
318 .append(getProjectDomainName(), castOther.getProjectDomainName())
319 .append(getUserDomainName(), castOther.getUserDomainName())
320 .append(getMemberRole(), castOther.getMemberRole())
321 .append(getTenantMetadata(), castOther.getTenantMetadata())
322 .append(getIdentityServerType(), castOther.getIdentityServerType())
323 .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType())
324 .append(getAdminProjectDomainName(), castOther.getAdminProjectDomainName()).isEquals();
328 public int hashCode() {
329 return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
330 .append(getMsoPass()).append(getProjectDomainName()).append(getUserDomainName())
331 .append(getAdminTenant()).append(getMemberRole()).append(getTenantMetadata())
332 .append(getIdentityServerType()).append(getIdentityAuthenticationType())
333 .append(getAdminProjectDomainName()).toHashCode();