1 package org.openecomp.dcae.dmaapbc.dbcapp.domain;
3 import org.openecomp.portalsdk.core.domain.support.DomainVo;
4 import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
7 * Hold an access profile for a DMaaP REST endpoint. Represents one row in the
10 public class DmaapAccess extends DomainVo {
12 private static final long serialVersionUID = 6443219375733216340L;
14 // parent class defines these fields:
15 // ID, created, modified, created_id, modified_id
17 /** Login ID for user who owns this row */
18 private String userId;
19 /** Nickname for this row */
21 /** REST API endpoint */
22 private String dmaapUrl;
24 private String mechId;
26 private String password;
27 /** User's preferred access profile */
28 private boolean selected;
31 * Standard POJO no-arg constructor
33 public DmaapAccess() {
42 public DmaapAccess(final DmaapAccess copy) {
43 // Unfortunately DomainVo doesn't provide a copy constructor;
44 // only the ID field is needed.
47 this.userId = copy.userId;
48 this.name = copy.name;
49 this.dmaapUrl = copy.dmaapUrl;
50 this.mechId = copy.mechId;
51 this.password = copy.password;
52 this.selected = copy.selected;
55 public String getUserId() {
59 public void setUserId(String userId) {
63 public String getName() {
67 public void setName(String name) {
71 public String getDmaapUrl() {
75 public void setDmaapUrl(String dmaapUrl) {
76 this.dmaapUrl = dmaapUrl;
79 public String getMechId() {
83 public void setMechId(String mechId) {
88 * Gets the encrypted password. Applications should use
89 * {@link #decryptPassword()}!
91 * @return The encrypted password
93 public String getPassword() {
98 * Sets the encrypted password. Applications should use
99 * {@link #encryptPassword(String)}!
102 * The encrypted password
104 public void setPassword(String password) {
105 this.password = password;
108 public boolean getSelected() {
112 public void setSelected(boolean selected) {
113 this.selected = selected;
117 * A getter that decrypts the value read from the database and returns the
118 * clear text. Has no side effects.
120 * @return Clear-text password.
122 * If the password cannot be decrypted
124 public String decryptPassword() throws Exception {
125 if (password == null)
127 return CipherUtil.decrypt(password);
131 * A setter that encrypts the clear-text in preparation for storing in the
135 * The clear-text password to be encrypted
137 * If the password cannot be encrypted
139 public void encryptPassword(String clearText) throws Exception {
140 if (clearText == null) {
144 password = CipherUtil.encrypt(clearText);
148 public String toString() {
149 return "DmaapAccess[id=" + id + ", url=" + dmaapUrl + ", ...]";