aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java
blob: e6d02c68366754347ad2e039af872be306a81463 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/*-
 * ============LICENSE_START=======================================================
 * ONAP - SO
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.so.db.catalog.beans;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.openpojo.business.annotation.BusinessKey;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.Date;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * EntityBean class for a CloudIdentity. This bean represents a cloud identity
 * service instance (i.e. a DCP node) in the NVP/AIC cloud. It will be loaded via
 * CloudConfig object, of which it is a component.
 *
 */
@Entity
@Table(name = "identity_services")
public class CloudIdentity {

    @JsonProperty
    @BusinessKey
    @Id
    @Column(name = "ID")
    private String id;
    
    @JsonProperty("identity_url")
    @BusinessKey
    @Column(name = "IDENTITY_URL")
    private String identityUrl;
    
    @JsonProperty("mso_id")
    @BusinessKey
    @Column(name = "MSO_ID")
    private String msoId;
    
    @JsonProperty("mso_pass")
    @BusinessKey
    @Column(name = "MSO_PASS")
    private String msoPass;
    
    @JsonProperty("admin_tenant")
    @BusinessKey
    @Column(name = "ADMIN_TENANT")
    private String adminTenant;
    
    @JsonProperty("member_role")
    @BusinessKey
    @Column(name = "MEMBER_ROLE")
    private String memberRole;
    
    @JsonProperty("tenant_metadata")
    @BusinessKey
    @Column(name = "TENANT_METADATA")
    private Boolean tenantMetadata;
    
    @JsonProperty("identity_server_type")
    @BusinessKey
    @Enumerated(EnumType.STRING)
    @Column(name = "IDENTITY_SERVER_TYPE")
    private ServerType identityServerType;
    
    @JsonProperty("identity_authentication_type")
    @BusinessKey
    @Enumerated(EnumType.STRING)
    @Column(name = "IDENTITY_AUTHENTICATION_TYPE")
    private AuthenticationType identityAuthenticationType;

    @JsonProperty("last_updated_by")
    @BusinessKey
    @Column(name = "LAST_UPDATED_BY")
    private String lastUpdatedBy ;

    @JsonProperty("creation_timestamp")
    @BusinessKey
    @Column(name = "CREATION_TIMESTAMP", updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date created;

    @JsonProperty("update_timestamp")
    @BusinessKey
    @Column(name = "UPDATE_TIMESTAMP")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updated;
    
    public CloudIdentity() {}

    @PrePersist
    protected void onCreate() {
        this.created = new Date();
        this.updated = new Date();
    }

    public String getId () {
        return id;
    }

    public void setId (String id) {
        this.id = id;
    }

    public String getIdentityUrl() {
    	return this.identityUrl;
    }
    public void setIdentityUrl(String url) {
    	this.identityUrl = url;
    }

    public String getMsoId () {
        return msoId;
    }

    public void setMsoId (String id) {
        this.msoId = id;
    }

    public String getMsoPass () {
        return msoPass;
    }

    public void setMsoPass (String pwd) {
        this.msoPass = pwd;
    }

    public String getAdminTenant () {
        return adminTenant;
    }

    public String getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public Date getCreated() {
        return created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setLastUpdatedBy(String lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public void setAdminTenant (String tenant) {
        this.adminTenant = tenant;
    }

    public String getMemberRole () {
        return memberRole;
    }

    public void setMemberRole (String role) {
        this.memberRole = role;
    }

    public Boolean getTenantMetadata() {
        return tenantMetadata;
    }

    public void setTenantMetadata (Boolean meta) {
        this.tenantMetadata = meta;
    }
    
    public ServerType getIdentityServerType() {
    	return this.identityServerType;
    }
    public void setIdentityServerType(ServerType ist) {
    	this.identityServerType = ist;
    }
    public String getIdentityServerTypeAsString() {
    	return this.identityServerType.toString();
    }
    /**
	 * @return the identityAuthenticationType
	 */
	public AuthenticationType getIdentityAuthenticationType() {
		return identityAuthenticationType;
	}

	/**
	 * @param identityAuthenticationType the identityAuthenticationType to set
	 */
	public void setIdentityAuthenticationType(AuthenticationType identityAuthenticationType) {
		this.identityAuthenticationType = identityAuthenticationType;
	}

	@Override
	public CloudIdentity clone() {
		CloudIdentity cloudIdentityCopy = new CloudIdentity();

		cloudIdentityCopy.id = this.id;
		cloudIdentityCopy.identityUrl = this.identityUrl;
		cloudIdentityCopy.msoId = this.msoId;
		cloudIdentityCopy.msoPass = this.msoPass;
		cloudIdentityCopy.adminTenant = this.adminTenant;
		cloudIdentityCopy.memberRole = this.memberRole;
		cloudIdentityCopy.tenantMetadata = this.tenantMetadata;
		cloudIdentityCopy.identityServerType = this.identityServerType;
		cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;

		return cloudIdentityCopy;
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
				.append("identityUrl", getIdentityUrl()).append("msoId", getMsoId())
				.append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
				.append("tenantMetadata", getTenantMetadata()).append("identityServerType", getIdentityServerType())
				.append("identityAuthenticationType", getIdentityAuthenticationType()).toString();
	}

	@Override
	public boolean equals(final Object other) {
		if (other == null) {
			return false;
		}
		if (!getClass().equals(other.getClass())) {
			return false;
		}
		CloudIdentity castOther = (CloudIdentity) other;
		return new EqualsBuilder().append(getId(), castOther.getId())
				.append(getIdentityUrl(), castOther.getIdentityUrl()).append(getMsoId(), castOther.getMsoId())
				.append(getMsoPass(), castOther.getMsoPass()).append(getAdminTenant(), castOther.getAdminTenant())
				.append(getMemberRole(), castOther.getMemberRole())
				.append(getTenantMetadata(), castOther.getTenantMetadata())
				.append(getIdentityServerType(), castOther.getIdentityServerType())
				.append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType()).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
				.append(getMsoPass()).append(getAdminTenant()).append(getMemberRole()).append(getTenantMetadata())
				.append(getIdentityServerType()).append(getIdentityAuthenticationType()).toHashCode();
	}
}