summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java
index 62232beaf5..89b0fe65bc 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java
@@ -30,6 +30,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -84,7 +85,7 @@ public class UserBusinessLogic {
}
private String decryptUserId(final String userId) {
- if (StringUtils.isNotEmpty(userId)) {
+ if (StringUtils.isNotEmpty(userId) && isUserBase64Encoded(userId)) {
try {
return CipherUtil.decryptPKC(userId);
} catch (final Exception e) {
@@ -94,6 +95,16 @@ public class UserBusinessLogic {
return userId;
}
+ boolean isUserBase64Encoded(String userId){
+ try {
+ byte[] decodedUserId = Base64.decodeBase64(userId.getBytes());
+ byte[] reEncodedUserId = Base64.encodeBase64(decodedUserId);
+ return userId.equals(new String(reEncodedUserId));
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
public User getUser(String userId) {
userId = decryptUserId(userId);
UserContext userContext = ThreadLocalsHolder.getUserContext();