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.openecomp.mso.cloud;
23 import java.security.GeneralSecurityException;
25 import com.fasterxml.jackson.annotation.JsonProperty;
27 import org.openecomp.mso.utils.CryptoUtils;
28 import org.openecomp.mso.logger.MessageEnum;
29 import org.openecomp.mso.logger.MsoLogger;
32 * JavaBean JSON class for a Cloudify Manager. This bean represents a Cloudify
33 * node through which TOSCA-based VNFs may be deployed. Each CloudSite in the
34 * CloudConfig may have a Cloudify Manager for deployments using TOSCA blueprints.
35 * Cloudify Managers may support multiple Cloud Sites, but each site will have
36 * at most one Cloudify Manager.
38 * This does not replace the ability to use the CloudSite directly via Openstack.
40 * Note that this is only used to access Cloud Configurations loaded from a
41 * JSON config file, so there are no explicit setters.
45 public class CloudifyManager {
47 private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
51 @JsonProperty ("cloudify_url")
52 private String cloudifyUrl;
53 @JsonProperty("username")
54 private String username;
55 @JsonProperty("password")
56 private String password;
57 @JsonProperty("version")
58 private String version;
60 private static String cloudKey = "aa3871669d893c7fb8abbcda31b88b4f";
62 public CloudifyManager() {}
64 public String getId() {
67 public void setId(String id) {
71 public String getCloudifyUrl() {
75 public void setCloudifyUrl(String cloudifyUrl) {
76 this.cloudifyUrl = cloudifyUrl;
79 public String getUsername() {
83 public void setUsername(String username) {
84 this.username = username;
87 public String getPassword() {
89 return CryptoUtils.decrypt (password, cloudKey);
90 } catch (GeneralSecurityException e) {
91 LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in getMsoPass", e);
96 public void setPassword(String password) {
97 this.password = password;
100 public String getVersion() {
104 public void setVersion(String version) {
105 this.version = version;
110 public String toString() {
111 return "CloudifyManager: id=" + id +
112 ", cloudifyUrl=" + cloudifyUrl +
113 ", username=" + username +
114 ", password=" + password +
115 ", version=" + version;
119 public CloudifyManager clone() {
120 CloudifyManager cloudifyManagerCopy = new CloudifyManager();
121 cloudifyManagerCopy.id = this.id;
122 cloudifyManagerCopy.cloudifyUrl = this.cloudifyUrl;
123 cloudifyManagerCopy.username = this.username;
124 cloudifyManagerCopy.password = this.password;
125 cloudifyManagerCopy.version = this.version;
126 return cloudifyManagerCopy;
130 public int hashCode() {
131 final int prime = 31;
133 result = prime * result + ((id == null) ? 0 : id.hashCode());
134 result = prime * result + ((cloudifyUrl == null) ? 0 : cloudifyUrl.hashCode());
135 result = prime * result + ((username == null) ? 0 : username.hashCode());
136 result = prime * result + ((password == null) ? 0 : password.hashCode());
137 result = prime * result + ((version == null) ? 0 : version.hashCode());
142 public boolean equals(Object obj) {
147 if (getClass() != obj.getClass())
149 CloudifyManager other = (CloudifyManager) obj;
150 if (!cmp(id, other.id))
152 if (!cmp(cloudifyUrl, other.cloudifyUrl))
154 if (!cmp(username, other.username))
156 if (!cmp(version, other.version))
158 if (!cmp(password, other.password))
162 private boolean cmp(Object a, Object b) {