From b9a6ae1246c02031deb7f5e0d016f242e7d99452 Mon Sep 17 00:00:00 2001 From: Dominic Lunanuova Date: Wed, 7 Feb 2018 22:10:00 +0000 Subject: Refactor to use org.onap local packages This is stage 1 of refactoring to use org.onap instead of org.openecomp in java packages and class names. Leaving the update from openecomp portalsdk to onap epsdk for a future exercise since I'm trying to get a standalone GUI working (i.e. non-portal). Issue-ID: DMAAP-159 Change-Id: I6a9368c66fa3603b1d9984f600802326ff2f0592 Signed-off-by: Dominic Lunanuova --- .../dcae/dmaapbc/dbcapp/domain/DmaapAccess.java | 152 +++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 dcae_dmaapbc_webapp/dbca-common/src/main/java/org/onap/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java (limited to 'dcae_dmaapbc_webapp/dbca-common/src/main/java/org/onap/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java') diff --git a/dcae_dmaapbc_webapp/dbca-common/src/main/java/org/onap/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java b/dcae_dmaapbc_webapp/dbca-common/src/main/java/org/onap/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java new file mode 100644 index 0000000..31b0fdd --- /dev/null +++ b/dcae_dmaapbc_webapp/dbca-common/src/main/java/org/onap/dcae/dmaapbc/dbcapp/domain/DmaapAccess.java @@ -0,0 +1,152 @@ +package org.onap.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 + ", ...]"; + } + +} -- cgit 1.2.3-korg