Merge "Removed below sonar issues:"
[aai/aai-common.git] / aai-auth / src / main / java / org / openecomp / auth / Auth.java
index 4d11288..3c5c3be 100644 (file)
@@ -28,36 +28,29 @@ package org.openecomp.auth;
 import org.apache.http.cookie.Cookie;
 
 public class Auth {
-  private AuthCore authCore;
 
-  public Auth(String filename) throws Exception {
-    this.authCore = new AuthCore(filename);
-  }
+    private AuthCore authCore;
 
-  public boolean auth_basic(String username, String authFunction) throws Exception {
-    return authCore.authorize(username, authFunction);
-  }
+    public Auth(String filename) throws Exception {
+        this.authCore = new AuthCore(filename);
+    }
+
+    public boolean authBasic(String username, String authFunction) throws Exception {
+        return authCore.authorize(username, authFunction);
+    }
 
-  public boolean auth_cookie(Cookie cookie, String authFunction, StringBuilder username)
-    throws Exception {
-    if (cookie == null) {
-      return false;
+    public boolean authCookie(Cookie cookie, String authFunction, StringBuilder username) throws Exception {
+        return cookie != null && authCore.authorize(username.toString(), authFunction);
     }
-    return authCore.authorize(username.toString(), authFunction);
-  }
-
-  /**
-   *  Returns true if the user is allowed to access a function.
-   * @param authUser
-   *        - String value of the user.
-   * @param authAction
-   *        - String value of the function.
-   */
-  public boolean validateRequest(String authUser, String authAction) throws Exception {
-
-    if (authUser == null || authAction == null) {
-      return false;
+
+    /**
+     *  Returns true if the user is allowed to access a function.
+     * @param authUser
+     *        - String value of the user.
+     * @param authAction
+     *        - String value of the function.
+     */
+    public boolean validateRequest(String authUser, String authAction) throws Exception {
+        return authUser != null && authAction != null && authCore.authorize(authUser, authAction);
     }
-    return authCore.authorize(authUser, authAction);
-  }
 }