diff options
Diffstat (limited to 'ONAP-SDK-APP/src/main/java')
-rw-r--r-- | ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java | 9 | ||||
-rw-r--r-- | ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java | 107 |
2 files changed, 62 insertions, 54 deletions
diff --git a/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java b/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java index 91ed598cf..1b6397c05 100644 --- a/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java +++ b/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java @@ -28,6 +28,7 @@ import org.openecomp.portalsdk.core.auth.LoginStrategy; import org.openecomp.portalsdk.core.conf.AppConfig; import org.openecomp.portalsdk.core.conf.Configurable; import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager; +import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException; import org.openecomp.portalsdk.core.service.DataAccessService; import org.openecomp.portalsdk.core.util.CacheManager; import org.openecomp.portalsdk.core.util.SystemProperties; @@ -135,11 +136,15 @@ public class ExternalAppConfig extends AppConfig implements Configurable { */ // @Bean // ANNOTATION COMMENTED OUT // APPLICATIONS REQUIRING QUARTZ SHOULD RESTORE ANNOTATION - public SchedulerFactoryBean schedulerFactoryBean() throws Exception { + public SchedulerFactoryBean schedulerFactoryBean() throws PortalAPIException { SchedulerFactoryBean scheduler = new SchedulerFactoryBean(); scheduler.setTriggers(schedulerRegistryAdapter.getTriggers()); scheduler.setConfigLocation(appApplicationContext.getResource("WEB-INF/conf/quartz.properties")); - scheduler.setDataSource(dataSource()); + try{ + scheduler.setDataSource(dataSource()); + }catch(Exception e){ + throw new PortalAPIException(e); + } return scheduler; } diff --git a/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java b/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java index a4b684719..13d8836ea 100644 --- a/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java +++ b/ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java @@ -14,60 +14,63 @@ import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; import org.springframework.web.servlet.ModelAndView; public class LoginStrategyImpl extends LoginStrategy { - - private static final Logger LOGGER = FlexLogger.getLogger(LoginStrategyImpl.class); - - @Override - public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { - //'login' for opensource is same as 'external' login. - return doExternalLogin(request, response); - } - - @Override - public String getUserId(HttpServletRequest request) throws PortalAPIException { - // Check ONAP Portal cookie - if (!isLoginCookieExist(request)) - return null; - String userid = null; - try { - userid = getUserIdFromCookie(request); - } catch (Exception e) { - LOGGER.error("Exception Occured"+e); - } - return userid; - } + private static final Logger LOGGER = FlexLogger.getLogger(LoginStrategyImpl.class); - private static String getUserIdFromCookie(HttpServletRequest request) throws Exception { - String userId = ""; - Cookie[] cookies = request.getCookies(); - Cookie userIdcookie = null; - if (cookies != null) - for (Cookie cookie : cookies) - if (cookie.getName().equals(USER_ID)) - userIdcookie = cookie; - if(userIdcookie!=null){ - userId = CipherUtil.decrypt(userIdcookie.getValue(), - PortalApiProperties.getProperty(PortalApiConstants.Decryption_Key)); - } - return userId; - - } - - private static boolean isLoginCookieExist(HttpServletRequest request) { - Cookie ep = getCookie(request, EP_SERVICE); - return (ep != null); - } - - private static Cookie getCookie(HttpServletRequest request, String cookieName) { - Cookie[] cookies = request.getCookies(); - if (cookies != null) - for (Cookie cookie : cookies) - if (cookie.getName().equals(cookieName)) - return cookie; + @Override + public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception { + // 'login' for opensource is same as 'external' login. + return doExternalLogin(request, response); + } - return null; - } + @Override + public String getUserId(HttpServletRequest request) throws PortalAPIException { + // Check ONAP Portal cookie + if (!isLoginCookieExist(request)) + return null; + + String userid = null; + try { + userid = getUserIdFromCookie(request); + } catch (Exception e) { + LOGGER.error("Exception Occured" + e); + } + return userid; + } + + private static String getUserIdFromCookie(HttpServletRequest request) throws PortalAPIException { + String userId = ""; + Cookie[] cookies = request.getCookies(); + Cookie userIdcookie = null; + if (cookies != null) + for (Cookie cookie : cookies) + if (cookie.getName().equals(USER_ID)) + userIdcookie = cookie; + if (userIdcookie != null) { + try { + userId = CipherUtil.decrypt(userIdcookie.getValue(), + PortalApiProperties.getProperty(PortalApiConstants.Decryption_Key)); + } catch (Exception e) { + throw new PortalAPIException(e); + } + } + return userId; + + } + + private static boolean isLoginCookieExist(HttpServletRequest request) { + Cookie ep = getCookie(request, EP_SERVICE); + return (ep != null); + } + + private static Cookie getCookie(HttpServletRequest request, String cookieName) { + Cookie[] cookies = request.getCookies(); + if (cookies != null) + for (Cookie cookie : cookies) + if (cookie.getName().equals(cookieName)) + return cookie; + + return null; + } - } |