X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fportalapi%2FPortalAuthManager.java;h=977daf442246d35ab8213c69896a0696054983b5;hb=a0180adc6a1e1ec09472549596428b70d48db3fc;hp=e47144737e93f0c9dc58be9c6af646b480d80924;hpb=3f812ea25d352ec33d07f5ffa4c2aa2a77e8e793;p=portal%2Fric-dashboard.git diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java index e4714473..977daf44 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * O-RAN-SC * %% - * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * Copyright (C) 2019 AT&T Intellectual Property * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,14 @@ package org.oransc.ric.portal.dashboard.portalapi; import java.lang.invoke.MethodHandles; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; +import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService; import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.slf4j.Logger; @@ -43,18 +45,17 @@ public class PortalAuthManager { private final String userIdCookieName; public PortalAuthManager(final String appName, final String username, final String password, - final String decryptorClassName, final String userCookie) - throws ClassNotFoundException, InstantiationException, IllegalAccessException { + final String decryptorClassName, final String userCookie) throws ClassNotFoundException, + InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { credentialsMap = new HashMap<>(); - // The map keys are hardcoded in EPSDK-FW, no constants are defined :( - credentialsMap.put("appName", appName); - credentialsMap.put("username", username); - credentialsMap.put("password", password); + credentialsMap.put(IPortalRestCentralService.CREDENTIALS_APP, appName); + credentialsMap.put(IPortalRestCentralService.CREDENTIALS_USER, username); + credentialsMap.put(IPortalRestCentralService.CREDENTIALS_PASS, password); this.userIdCookieName = userCookie; // Instantiate here so configuration errors are detected at app-start time logger.debug("ctor: using decryptor class {}", decryptorClassName); Class decryptorClass = Class.forName(decryptorClassName); - portalSdkDecryptor = (IPortalSdkDecryptor) decryptorClass.newInstance(); + portalSdkDecryptor = (IPortalSdkDecryptor) decryptorClass.getDeclaredConstructor().newInstance(); } /** @@ -62,6 +63,7 @@ public class PortalAuthManager { * password. */ public Map getAppCredentials() { + logger.debug("getAppCredentials"); return credentialsMap; } @@ -92,17 +94,18 @@ public class PortalAuthManager { * @return User ID if the ECOMP cookie is present and the sign-on process * established a user ID; else null. */ - public String valdiateEcompSso(HttpServletRequest request) { + public String validateEcompSso(HttpServletRequest request) { + logger.debug("validateEcompSso URI {}", request.getRequestURI()); // Check ECOMP Portal cookie Cookie ep = getCookie(request, PortalApiConstants.EP_SERVICE); if (ep == null) { - logger.debug("valdiateEcompSso: cookie not found: {}", PortalApiConstants.EP_SERVICE); + logger.debug("validateEcompSso: cookie not found: {}", PortalApiConstants.EP_SERVICE); return null; } logger.trace("validateEcompSso: found cookie {}", PortalApiConstants.EP_SERVICE); Cookie user = getCookie(request, userIdCookieName); if (user == null) { - logger.debug("valdiateEcompSso: cookie not found: {}", userIdCookieName); + logger.debug("validateEcompSso: cookie not found: {}", userIdCookieName); return null; } logger.trace("validateEcompSso: user cookie {}", userIdCookieName); @@ -110,7 +113,7 @@ public class PortalAuthManager { try { userid = portalSdkDecryptor.decrypt(user.getValue()); } catch (CipherUtilException e) { - throw new IllegalArgumentException("valdiateEcompSso failed", e); + throw new IllegalArgumentException("validateEcompSso failed", e); } return userid; }