summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2018-10-10 14:52:54 +0300
committerMichael Lando <michael.lando@intl.att.com>2018-10-12 08:07:35 +0000
commit7d05e16f0ab24ba8918bd4466d50a9fb77571552 (patch)
treed1da92387eaa9d29780d56650e51dc5ccd439107 /catalog-be/src/main/java
parent502b7b7839374680a494c1606798a8b4588daa2b (diff)
update sdc portal integration
Change-Id: I6e17434f753c2eaa562da80c1eade8688601f510 Issue-ID: SDC-1749 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java39
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverter.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java5
3 files changed, 34 insertions, 12 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java
index 757c3a48d4..50d48d4ca7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java
@@ -21,10 +21,16 @@
package org.openecomp.sdc.be.ecomp;
import fj.data.Either;
-import org.openecomp.portalsdk.core.onboarding.crossapi.IPortalRestAPIService;
-import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
-import org.openecomp.portalsdk.core.restful.domain.EcompRole;
-import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestAPIService;
+import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
+import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.KeyConstants;
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
+import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
+import org.onap.portalsdk.core.restful.domain.EcompRole;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -40,8 +46,10 @@ import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoader;
import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
public class EcompIntImpl implements IPortalRestAPIService {
@@ -265,7 +273,7 @@ public class EcompIntImpl implements IPortalRestAPIService {
}
@Override
- public List<EcompRole> getAvailableRoles() throws PortalAPIException {
+ public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException {
log.debug("Start handle request of ECOMP getAvailableRoles");
try {
List<EcompRole> ecompRolesList = new LinkedList<>();
@@ -372,14 +380,21 @@ public class EcompIntImpl implements IPortalRestAPIService {
@Override
public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException {
- // TODO Validation should be changed completely
+ final String portal_key = PortalApiProperties.getProperty("portal_pass");
+ final String portal_user = PortalApiProperties.getProperty("portal_user");
final String USERNAME = request.getHeader("username");
final String PASSWORD = request.getHeader("password");
if (USERNAME != null && PASSWORD != null) {
- if (!USERNAME.equals("") && !PASSWORD.equals("")) {
- log.debug("User authenticated - Username: ,Password: {}", USERNAME, PASSWORD);
- return true;
+ try {
+ if (CipherUtil.decryptPKC(USERNAME).equals(CipherUtil.decryptPKC(portal_user)) &&
+ CipherUtil.decryptPKC(PASSWORD).equals(CipherUtil.decryptPKC(portal_key))) {
+ log.debug("User authenticated - Username: {}", USERNAME);
+ return true;
+ }
+ } catch (CipherUtilException e) {
+ log.debug("User authentication failed - Decryption failed", e);
+ return false;
}
}
@@ -415,4 +430,10 @@ public class EcompIntImpl implements IPortalRestAPIService {
public String getUserId(HttpServletRequest request) throws PortalAPIException {
return request.getHeader(Constants.USER_ID_HEADER);
}
+
+ //TODO for what the following method stands for
+ @Override
+ public Map<String, String> getCredentials() throws PortalAPIException {
+ return null;
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverter.java
index aebc9170f1..df20351fd8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompRoleConverter.java
@@ -20,7 +20,7 @@
package org.openecomp.sdc.be.ecomp.converters;
-import org.openecomp.portalsdk.core.restful.domain.EcompRole;
+import org.onap.portalsdk.core.restful.domain.EcompRole;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.common.log.wrappers.Logger;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java
index 0297abeacb..61b29a3986 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/EcompUserConverter.java
@@ -21,8 +21,9 @@
package org.openecomp.sdc.be.ecomp.converters;
import fj.data.Either;
-import org.openecomp.portalsdk.core.restful.domain.EcompRole;
-import org.openecomp.portalsdk.core.restful.domain.EcompUser;
+
+import org.onap.portalsdk.core.restful.domain.EcompRole;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.user.Role;