Merge "Drop Nokia from file header copyright line, part 2"
[portal/ric-dashboard.git] / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / portalapi / PortalAuthManager.java
index e471447..8eb7362 100644 (file)
@@ -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,6 +20,7 @@
 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;
 
@@ -44,7 +45,8 @@ public class PortalAuthManager {
 
        public PortalAuthManager(final String appName, final String username, final String password,
                        final String decryptorClassName, final String userCookie)
-                       throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+                       throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException,
+                       InvocationTargetException, NoSuchMethodException, SecurityException {
                credentialsMap = new HashMap<>();
                // The map keys are hardcoded in EPSDK-FW, no constants are defined :(
                credentialsMap.put("appName", appName);
@@ -54,7 +56,7 @@ public class PortalAuthManager {
                // 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();
        }
 
        /**
@@ -92,17 +94,17 @@ 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) {
                // 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 +112,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;
        }