X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-os%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fconf%2FExternalAppConfig.java;h=2bf10e430eafc026b5eddb27a8067fbf2e69762e;hb=6d6508031238b16d153d76b0f68ad7f27d90012c;hp=c059a01c05fbb05ba7724a8728e021614c599899;hpb=4ee8967d2429a8ff633693dd35f39eb26c022816;p=portal.git 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 c059a01c..2bf10e43 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 @@ -3,6 +3,8 @@ * ONAP Portal * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Modifications Copyright © 2018 IBM. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed @@ -33,7 +35,7 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalapp.conf; @@ -74,7 +76,6 @@ import org.onap.portalapp.portal.service.ExternalAccessRolesService; import org.onap.portalapp.portal.service.UserRolesService; import org.onap.portalapp.portal.transport.ExternalAuthUserRole; import org.onap.portalapp.portal.transport.ExternalRoleDescription; -import org.onap.portalapp.portal.ueb.EPUebHelper; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EPSystemProperties; import org.onap.portalapp.scheduler.RegistryAdapter; @@ -128,17 +129,17 @@ public class ExternalAppConfig extends AppConfig implements Configurable { @Autowired private DataAccessService dataAccessService; - + @Autowired private UserRolesService userRolesService; - + @Autowired private ExternalAccessRolesService externalAccessRolesService; private RegistryAdapter schedulerRegistryAdapter; - String UEB_APP_KEY = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY); - + String uebAppKey = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY); + public ViewResolver viewResolver() { return super.viewResolver(); } @@ -162,27 +163,23 @@ 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(remotecentralizedsystemaccess.equalsIgnoreCase("true")){ - importFromExternalAuth(); - } + + if("true".equalsIgnoreCase(remotecentralizedsystemaccess)){ + importFromExternalAuth(); + } } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "init failed", e); } } - - /** - * Does a sync on functions, roles and role functions based on namespace - * for all the centralized applications between AAF and ONAP, updates - * fn_user and fn_user_role with user information from AAF. - * - */ + + private void importFromExternalAuth() throws Exception { JSONArray aafAppRoles = new JSONArray(); JSONArray aafUserList = new JSONArray(); List appList; //to get all centralized apps List centralizedAppList = dataAccessService.executeNamedQuery("getCentralizedApps", null, null); - if(centralizedAppList != null && centralizedAppList.size() > 0){ + if(centralizedAppList != null && !centralizedAppList.isEmpty()){ for(int i = 0; i < centralizedAppList.size(); i++){ //syncRoles(does a sync on functions, roles and role functions) externalAccessRolesService.syncApplicationRolesWithEcompDB(centralizedAppList.get(i)); @@ -192,14 +189,14 @@ public class ExternalAppConfig extends AppConfig implements Configurable { for(int j = 0; j < aafAppRoles.length(); j++){ ObjectMapper mapper = new ObjectMapper(); String name = aafAppRoles.getJSONObject(j).getString("name"); - String desc = aafAppRoles.getJSONObject(j).getString("description"); - ExternalRoleDescription externalRoleDescription = mapper.readValue(desc, ExternalRoleDescription.class); +// String desc = aafAppRoles.getJSONObject(j).getString("description"); +// ExternalRoleDescription externalRoleDescription = mapper.readValue(desc, ExternalRoleDescription.class); aafUserList = externalAccessRolesService.getAllUsersByRole(name); if(aafUserList != null && aafUserList.length() > 0){ for(int k = 0; k < aafUserList.length(); k++){ EPUser user = null; List usersList = null; - List userRolesList = new ArrayList(); + List userRolesList = new ArrayList<>(); JSONObject userRole = (JSONObject) aafUserList.get(k); Gson gson = new Gson(); ExternalAuthUserRole userRoleObj = gson.fromJson(userRole.toString(), ExternalAuthUserRole.class); @@ -210,36 +207,32 @@ public class ExternalAppConfig extends AppConfig implements Configurable { Map orgUserId = new HashMap<>(); orgUserId.put("orgUserIdValue", userRoleObj.getUser()); usersList = dataAccessService.executeNamedQuery("epUserAppId", orgUserId, null); - if(usersList != null && usersList.size() > 0){ + if(usersList != null && !usersList.isEmpty()){ user = usersList.get(0); } if(user == null){ // add user to fn_user(needs to be revisited after getting user info from AAF PORTAL-172) } - //for each role and user in that role, check if user exists in fn_user_role. If not, add - /*userRolesList = userRolesService.getUserRolesList(centralizedAppList.get(0).getId(), user.getId(), Long.valueOf(externalRoleDescription.getId())); - if(userRolesList == null || userRolesList.isEmpty()){ - // add userRole to fn_user_role(needs to be revisited after getting user info from AAF PORTAL-172) - }*/ } } - + } } } } } - + public DataAccessService dataAccessService() { return super.dataAccessService(); } + @Override public String[] tileDefinitions() { return super.tileDefinitions(); } public List addTileDefinitions() { - List definitions = new ArrayList(); + List definitions = new ArrayList<>(); definitions.add("/WEB-INF/defs/definitions.xml"); return definitions; } @@ -266,7 +259,7 @@ public class ExternalAppConfig extends AppConfig implements Configurable { @Bean public org.onap.portalsdk.core.auth.LoginStrategy coreLoginStrategy() { - if (SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) + if ("OIDC".equalsIgnoreCase(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim())) return new OpenIdConnectLoginStrategy(); else return new SimpleLoginStrategy(); @@ -275,7 +268,7 @@ public class ExternalAppConfig extends AppConfig implements Configurable { @Bean public LoginStrategy loginStrategy() { - if (SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) + if ("OIDC".equalsIgnoreCase(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim())) return new OpenIdConnectLoginStrategy(); else return new SimpleLoginStrategy(); @@ -287,17 +280,10 @@ public class ExternalAppConfig extends AppConfig implements Configurable { @Override public void addInterceptors(InterceptorRegistry registry) { - // registry.addInterceptor(new - // StaticResourcesInterceptor()).addPathPatterns("/index.htm", - // "/applicationsHome", "/widgetsHome", "/admins", "/users", - // "/applications", "/widgets"); - // Excludes login/logout pages and REST endpoints used by other - // application servers. - registry.addInterceptor(sessionTimeoutInterceptor()).excludePathPatterns("/oid-login", "/portalApi/healthCheck", "/portalApi/healthCheck/", "/portalApi/healthCheckSuspend", "/portalApi/healthCheckSuspend/", "/portalApi/healthCheckResume", "/portalApi/healthCheckResume/", "/login_external", - "/login_external.htm*", "login", "/login.htm*", "/auxapi/*", "/context/*", "/api*", + "/login_external.htm*", "login", "/login.htm*", "/auxapi/**/*", "/context/*", "/api*", "/single_signon.htm", "/single_signon", "/dashboard", "/OpenSourceLogin.htm"); registry.addInterceptor(portalResourceInterceptor()); @@ -311,7 +297,8 @@ public class ExternalAppConfig extends AppConfig implements Configurable { * @return New instance of {@link SchedulerFactoryBean} */ - @Bean + /* + @Bean public EPUebHelper epUebHelper() { return new EPUebHelper(); } @@ -320,6 +307,8 @@ public class ExternalAppConfig extends AppConfig implements Configurable { public HealthMonitor healthMonitor() { return new HealthMonitor(); } + */ + /** * Creates and returns a new instance of a {@link MainUebHandler}.