From a59bc3e85eaf33c0a38063e5c30fe890588a0eb1 Mon Sep 17 00:00:00 2001 From: "Kishore Reddy, Gujja (kg811t)" Date: Tue, 25 Sep 2018 13:59:56 -0400 Subject: login and Certman AAF Integration changes Issue-ID: PORTAL-386, PORTAL-389 failed to create user with special char in login_id Change-Id: I415adf615a7af97319d8d11a740e75d3dfa11583 Signed-off-by: Kishore Reddy, Gujja (kg811t) --- .../org/onap/portalapp/conf/ExternalAppConfig.java | 10 +- .../portalapp/portal/service/AppsCacheService.java | 58 ---------- .../portal/service/AppsCacheServiceImple.java | 124 --------------------- .../portal/service/SearchServiceImpl.java | 15 +-- .../portalapp/portal/service/UserServiceImpl.java | 7 +- 5 files changed, 17 insertions(+), 197 deletions(-) delete mode 100644 ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java delete mode 100644 ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java (limited to 'ecomp-portal-BE-os/src/main/java') diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java index ee53eba0..e9c48251 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java @@ -161,9 +161,10 @@ public class ExternalAppConfig extends AppConfig implements Configurable { MDC.put(MDC_SERVICE_INSTANCE_ID, ""); MDC.put(MDC_ALERT_SEVERITY, AlarmSeverityEnum.INFORMATIONAL.severity()); MDC.put(MDC_INSTANCE_UUID, SystemProperties.getProperty(SystemProperties.INSTANCE_UUID)); - if("true".equalsIgnoreCase(remotecentralizedsystemaccess)){ - importFromExternalAuth(); - } + + // if("true".equalsIgnoreCase(remotecentralizedsystemaccess)){ + // importFromExternalAuth(); + // } } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "init failed", e); } @@ -174,7 +175,10 @@ public class ExternalAppConfig extends AppConfig implements Configurable { * for all the centralized applications between AAF and ONAP, updates * fn_user and fn_user_role with user information from AAF. * + * This is being handled in AAF directly, so it has been deprecated + * */ + @Deprecated private void importFromExternalAuth() throws Exception { JSONArray aafAppRoles = new JSONArray(); JSONArray aafUserList = new JSONArray(); diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java deleted file mode 100644 index a3255480..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ - -package org.onap.portalapp.portal.service; - -import org.onap.portalapp.portal.domain.EPApp; - -public interface AppsCacheService { - - /** - * returns an app by id from the cache - * @param appId - * @return corresponding App - */ - EPApp getApp(Long appId); - - /** - * returns the corresponding application endpoint - * @param appId - * @return if appId exists in cache, then return corresponding application endpoint, null otherwise. - */ - String getAppEndpoint(Long appId); -} diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java deleted file mode 100644 index e6306c9c..00000000 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ -package org.onap.portalapp.portal.service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import org.onap.portalapp.portal.domain.EPApp; -import org.onap.portalapp.portal.logging.aop.EPMetricsLog; -import org.onap.portalapp.portal.service.AppsCacheService; -import org.onap.portalapp.portal.service.EPAppService; -import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Service; - -@Service("appsCacheService") -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -@EPMetricsLog -public class AppsCacheServiceImple implements AppsCacheService { - @Autowired - EPAppService appsService; - - EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsCacheServiceImple.class); - - private static long updateTime = 0; - private static final int cacheUpdateIntervalInSeconds = 10; - - private static volatile Map appsMap; - - @PostConstruct - public void init() { - this.refreshAppsMap(); - } - - private Map refreshAppsMap() { - long now = System.currentTimeMillis(); - - if(noNeedToUpdate(now)) - return null; - - synchronized (this) { - if(noNeedToUpdate(now)) - return null; - List allApps = appsService.getAppsFullList(); - Map newAppsMap = new HashMap(); - for (EPApp app : allApps) { - newAppsMap.put(app.getId(), app); - } - // Switch cache with the new one. - appsMap = newAppsMap; - updateTime = now; - } - - return appsMap; - } - - private boolean noNeedToUpdate(long now) { - long secondsPassed = (now - updateTime)/1000; - if(secondsPassed < cacheUpdateIntervalInSeconds){ - logger.debug(EELFLoggerDelegate.debugLogger, "no need to refresh yet, seconds since last refresh: " + secondsPassed + ", refresh interval (sec) = " + cacheUpdateIntervalInSeconds); - return true; // no need to update cache - } - return false; // its time to update - } - - @Override - public String getAppEndpoint(Long appId) { - refreshAppsMap(); - EPApp app = appsMap.get(appId); - if(app != null) - return app.getAppRestEndpoint(); - return null; - } - - @Override - public EPApp getApp(Long appId) { - refreshAppsMap(); - EPApp app = appsMap.get(appId); - if(app != null) - return app; - return null; - } - -} diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java index 48f6d298..e0934713 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/SearchServiceImpl.java +++ b/ecomp-portal-BE-os/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 @@ -79,18 +79,13 @@ public class SearchServiceImpl implements SearchService { public String searchUsersInFnTable(String searchString) { String orgUserId = null; List tokens = EcompPortalUtils.parsingByRegularExpression(searchString, " "); - for (int i = 0; i < tokens.size(); i++) { // find userid if possible and remove it from tokens - if (tokens.get(i).matches(".*\\d+.*")) { - orgUserId = tokens.get(i); - tokens.remove(i); - } - } while (tokens.size() > 2) { // we use no more then first 2 tokens (userId is removed, see above) tokens.remove(tokens.size() - 1); } EPUser attrUser = new EPUser(); attrUser.setOrgUserId(orgUserId); - List resultOfSearch = new ArrayList(), resultOfAdditionalSearch = null; + List resultOfSearch = new ArrayList(), resultOfAdditionalSearch = null, + resultOfSearchUserId = new ArrayList(); if (tokens.size() == 2) { attrUser.setFirstName(tokens.get(0)); attrUser.setLastName(tokens.get(1)); @@ -107,6 +102,7 @@ public class SearchServiceImpl implements SearchService { } else if (tokens.size() == 1) { attrUser.setFirstName(tokens.get(0)); resultOfSearch = this.searchUsersByName(attrUser); + resultOfSearchUserId = this.searchUsersByUserId(attrUser); resultOfSearch = this.removeWrongFirstNames(resultOfSearch, tokens.get(0)); if (resultOfSearch.size() < maxSizeOfSearchResult) { attrUser.setFirstName(null); @@ -114,12 +110,11 @@ public class SearchServiceImpl implements SearchService { resultOfAdditionalSearch = this.searchUsersByName(attrUser); resultOfAdditionalSearch = this.removeWrongLastNames(resultOfAdditionalSearch, tokens.get(0)); } - } else if (orgUserId != null) { - resultOfSearch = this.searchUsersByUserId(attrUser); } if (resultOfAdditionalSearch != null) { resultOfSearch.addAll(resultOfAdditionalSearch); } + resultOfSearch.addAll(resultOfSearchUserId); resultOfSearch = this.cutSearchResultToMaximumSize(resultOfSearch); ObjectMapper mapper = new ObjectMapper(); String result = "[]"; diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java index b5ccfc02..fccd4ff8 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/service/UserServiceImpl.java @@ -159,9 +159,12 @@ public class UserServiceImpl implements UserService { List list = null; StringBuffer criteria = new StringBuffer(); - if (firstName != null) + if (firstName != null && lastName != null) + criteria.append(" where first_name = '").append(firstName).append("' and last_name = '") + .append(lastName).append("'"); + else if (firstName != null) criteria.append(" where first_name = '").append(firstName).append("'"); - if (lastName != null) + else if (lastName != null) criteria.append(" where last_name = '").append(lastName).append("'"); list = getDataAccessService().getList(EPUser.class, criteria.toString(), null, null); return (list == null || list.size() == 0) ? null : list; -- cgit 1.2.3-korg