summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common
diff options
context:
space:
mode:
authorKishore Reddy, Gujja (kg811t) <kg811t@research.att.com>2018-09-11 11:59:20 -0400
committerKishore Reddy, Gujja (kg811t) <kg811t@research.att.com>2018-09-11 12:00:16 -0400
commite7b83375b7bb78fd1c25520fdb42ef162bdeb83b (patch)
treea6ccda48bce0628644b9460bbb5146f95870e320 /ecomp-portal-BE-common
parent7d4fa6ec66a6671c54d4588f7714b84ecbb6dbca (diff)
EcompPortalUtils and SearchServiceImpl changes
Issue-ID: PORTAL-386 failed to create user with special char in login_id Change-Id: Iab6ac96f9fa033e45cfbbc4434660139465c792e Signed-off-by: Kishore Reddy, Gujja (kg811t) <kg811t@research.att.com>
Diffstat (limited to 'ecomp-portal-BE-common')
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java10
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java3
2 files changed, 9 insertions, 4 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java
index ad6ed7b6..a192ad94 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
@@ -39,9 +39,9 @@ package org.onap.portalapp.portal.service;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
-import org.onap.portalapp.portal.service.SearchService;
-import org.onap.portalapp.portal.service.SearchServiceImpl;
import org.onap.portalapp.portal.domain.EPUser;
import org.onap.portalapp.portal.logging.aop.EPMetricsLog;
import org.onap.portalapp.portal.transport.UserWithNameSurnameTitle;
@@ -74,8 +74,10 @@ public class SearchServiceImpl implements SearchService {
public String searchUsersInPhoneBook(String searchString) {
String orgUserId = null;
List<String> tokens = EcompPortalUtils.parsingByRegularExpression(searchString, " ");
+ Pattern pattern = Pattern.compile(EcompPortalUtils.SEARCH_USERS_REGEX);
for (int i = 0; i < tokens.size(); i++) { // find orgUserId if possible and remove it from tokens
- if (tokens.get(i).matches(".*\\d+.*")) {
+ Matcher matcher = pattern.matcher(tokens.get(i));
+ if (matcher.matches()) {
orgUserId = tokens.get(i);
tokens.remove(i);
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java
index ab43149c..a4b6cc24 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java
@@ -80,6 +80,9 @@ public class EcompPortalUtils {
// It is a regular expression used for while creating a External Central Auth Role
public static final String EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS = "([^A-Z^a-z^0-9^\\.^%^(^)^=^:])";
+ // regex for alphanumeric , dashes and underscore
+ public static final String SEARCH_USERS_REGEX = "(^[a-zA-Z0-9_-]*$)";
+
/**
* @param orgUserId
* User ID to validate