Fix formatting in the dashboard
[nonrtric.git] / dashboard / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / portalapi / PortalAuthManager.java
index dc70f7e..f4daa5c 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,83 +38,83 @@ import org.slf4j.LoggerFactory;
  */
 public class PortalAuthManager {
 
-       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+    private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-       final Map<String, String> credentialsMap;
-       private final IPortalSdkDecryptor portalSdkDecryptor;
-       private final String userIdCookieName;
+    final Map<String, String> credentialsMap;
+    private final IPortalSdkDecryptor portalSdkDecryptor;
+    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, IllegalArgumentException,
-                       InvocationTargetException, NoSuchMethodException, SecurityException {
-               credentialsMap = new HashMap<>();
-               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.getDeclaredConstructor().newInstance();
-       }
+    public PortalAuthManager(final String appName, final String username, final String password,
+        final String decryptorClassName, final String userCookie)
+        throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException,
+        InvocationTargetException, NoSuchMethodException, SecurityException {
+        credentialsMap = new HashMap<>();
+        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.getDeclaredConstructor().newInstance();
+    }
 
-       /**
-        * @return A map of key-value pairs with application name, user name and
-        *         password.
-        */
-       public Map<String, String> getAppCredentials() {
-               return credentialsMap;
-       }
+    /**
+     * @return A map of key-value pairs with application name, user name and
+     *         password.
+     */
+    public Map<String, String> getAppCredentials() {
+        return credentialsMap;
+    }
 
-       /**
-        * Searches the request for a cookie with the specified name.
-        *
-        * @param request
-        *                       HttpServletRequest
-        * @param cookieName
-        *                       Cookie name
-        * @return Cookie, or null if not found.
-        */
-       private 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;
-       }
+    /**
+     * Searches the request for a cookie with the specified name.
+     *
+     * @param request
+     *        HttpServletRequest
+     * @param cookieName
+     *        Cookie name
+     * @return Cookie, or null if not found.
+     */
+    private 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;
+    }
 
-       /**
-        * Validates whether the ECOMP Portal sign-on process has completed. Checks for
-        * the ECOMP cookie first, then the user cookie.
-        * 
-        * @param request
-        *                    HttpServletRequest
-        * @return User ID if the ECOMP cookie is present and the sign-on process
-        *         established a user ID; else null.
-        */
-       public String validateEcompSso(HttpServletRequest request) {
-               // Check ECOMP Portal cookie
-               Cookie ep = getCookie(request, PortalApiConstants.EP_SERVICE);
-               if (ep == null) {
-                       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("validateEcompSso: cookie not found: {}", userIdCookieName);
-                       return null;
-               }
-               logger.trace("validateEcompSso: user cookie {}", userIdCookieName);
-               String userid = null;
-               try {
-                       userid = portalSdkDecryptor.decrypt(user.getValue());
-               } catch (CipherUtilException e) {
-                       throw new IllegalArgumentException("validateEcompSso failed", e);
-               }
-               return userid;
-       }
+    /**
+     * Validates whether the ECOMP Portal sign-on process has completed. Checks for
+     * the ECOMP cookie first, then the user cookie.
+     *
+     * @param request
+     *        HttpServletRequest
+     * @return User ID if the ECOMP cookie is present and the sign-on process
+     *         established a user ID; else null.
+     */
+    public String validateEcompSso(HttpServletRequest request) {
+        // Check ECOMP Portal cookie
+        Cookie ep = getCookie(request, PortalApiConstants.EP_SERVICE);
+        if (ep == null) {
+            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("validateEcompSso: cookie not found: {}", userIdCookieName);
+            return null;
+        }
+        logger.trace("validateEcompSso: user cookie {}", userIdCookieName);
+        String userid = null;
+        try {
+            userid = portalSdkDecryptor.decrypt(user.getValue());
+        } catch (CipherUtilException e) {
+            throw new IllegalArgumentException("validateEcompSso failed", e);
+        }
+        return userid;
+    }
 
 }