summaryrefslogtreecommitdiffstats
path: root/ONAP-SDK-APP/src/main
diff options
context:
space:
mode:
authorTej, Tarun <tt3868@att.com>2017-08-21 20:00:50 -0400
committerTarun Tej Velaga <tt3868@att.com>2017-08-23 17:29:35 +0000
commit80f072f60509ef3a35369a60857fe05f6c2a993a (patch)
tree7dca6266b225be3f192623fdc859ca80f4d1d493 /ONAP-SDK-APP/src/main
parentc53fa990ea27ec074859eb94bcb7ec6deaa2157b (diff)
Fixes for sonar critical issues
Fixes for critical and blocker issues reported in sonar. Issue-Id: POLICY-113 Change-Id: I50969fe93a94b0497f3fb30864a6c45e63208fe6 Signed-off-by: Tej, Tarun <tt3868@att.com>
Diffstat (limited to 'ONAP-SDK-APP/src/main')
-rw-r--r--ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/conf/ExternalAppConfig.java9
-rw-r--r--ONAP-SDK-APP/src/main/java/org/openecomp/portalapp/login/LoginStrategyImpl.java107
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;
+ }
-
}