diff options
author | Christopher Lott (cl778h) <clott@research.att.com> | 2017-05-09 14:24:20 -0400 |
---|---|---|
committer | Christopher Lott (cl778h) <clott@research.att.com> | 2017-05-09 14:44:09 -0400 |
commit | e2aefda183de4f1c1256d97f7ce09f8bee5477db (patch) | |
tree | 4b0eaf3f153df90591711daf081e63a8b20ace74 /dcae_dmaapbc_webapp/dbca-common/src/main/java/org/openecomp/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java | |
parent | 472635713b7471b300a988db7e907bab0119eaee (diff) |
[ONAP-rebase] Rebase as 1.1.0-SNAPSHOT
Consolidate into a single maven project; no more separate model and client jars.
Change-Id: Ibbba982250b74c0dfd09ee1c65c0fb6c158dd632
Signed-off-by: Christopher Lott <cl778h@att.com>
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'dcae_dmaapbc_webapp/dbca-common/src/main/java/org/openecomp/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java')
-rw-r--r-- | dcae_dmaapbc_webapp/dbca-common/src/main/java/org/openecomp/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/dcae_dmaapbc_webapp/dbca-common/src/main/java/org/openecomp/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java b/dcae_dmaapbc_webapp/dbca-common/src/main/java/org/openecomp/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java new file mode 100644 index 0000000..3edd3ba --- /dev/null +++ b/dcae_dmaapbc_webapp/dbca-common/src/main/java/org/openecomp/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java @@ -0,0 +1,152 @@ +package org.openecomp.dcae.dmaapbc.dbcapp.domain; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; +import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; + +/** + * Hold an access profile for a DMaaP REST endpoint. Represents one row in the + * DBCA_DMAAP table. + */ +public class DmaapAccess extends DomainVo { + + private static final long serialVersionUID = 6443219375733216340L; + + // parent class defines these fields: + // ID, created, modified, created_id, modified_id + + /** Login ID for user who owns this row */ + private String userId; + /** Nickname for this row */ + private String name; + /** REST API endpoint */ + private String dmaapUrl; + /** Credentials */ + private String mechId; + /** Credentials */ + private String password; + /** User's preferred access profile */ + private boolean selected; + + /** + * Standard POJO no-arg constructor + */ + public DmaapAccess() { + } + + /** + * Copy constructor + * + * @param copy + * Instance to copy + */ + public DmaapAccess(final DmaapAccess copy) { + // Unfortunately DomainVo doesn't provide a copy constructor; + // only the ID field is needed. + this.id = copy.id; + // Our fields + this.userId = copy.userId; + this.name = copy.name; + this.dmaapUrl = copy.dmaapUrl; + this.mechId = copy.mechId; + this.password = copy.password; + this.selected = copy.selected; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDmaapUrl() { + return dmaapUrl; + } + + public void setDmaapUrl(String dmaapUrl) { + this.dmaapUrl = dmaapUrl; + } + + public String getMechId() { + return mechId; + } + + public void setMechId(String mechId) { + this.mechId = mechId; + } + + /** + * Gets the encrypted password. Applications should use + * {@link #decryptPassword()}! + * + * @return The encrypted password + */ + public String getPassword() { + return password; + } + + /** + * Sets the encrypted password. Applications should use + * {@link #encryptPassword(String)}! + * + * @param password + * The encrypted password + */ + public void setPassword(String password) { + this.password = password; + } + + public boolean getSelected() { + return selected; + } + + public void setSelected(boolean selected) { + this.selected = selected; + } + + /** + * A getter that decrypts the value read from the database and returns the + * clear text. Has no side effects. + * + * @return Clear-text password. + * @throws Exception + * If the password cannot be decrypted + */ + public String decryptPassword() throws Exception { + if (password == null) + return null; + return CipherUtil.decrypt(password); + } + + /** + * A setter that encrypts the clear-text in preparation for storing in the + * database. + * + * @param clearText + * The clear-text password to be encrypted + * @throws Exception + * If the password cannot be encrypted + */ + public void encryptPassword(String clearText) throws Exception { + if (clearText == null) { + password = null; + return; + } + password = CipherUtil.encrypt(clearText); + } + + @Override + public String toString() { + return "DmaapAccess[id=" + id + ", url=" + dmaapUrl + ", ...]"; + } + +} |