From 713460db4b63a038dba77541a757b6d40fb4dd74 Mon Sep 17 00:00:00 2001 From: Bharat saraswal Date: Thu, 21 Sep 2017 21:03:47 +0530 Subject: Removed below sonar issues: Redudant variables. reduced method complexity by introducting new inner methods. rename variable to follow guidelines. Issue-Id:AAI-215 Change-Id: I3174daf62e38934207b87797f633f1cbd44b7502 Signed-off-by: Bharat saraswal --- .../src/main/java/org/openecomp/auth/Auth.java | 47 +++++++++------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'aai-auth/src/main/java/org/openecomp/auth/Auth.java') diff --git a/aai-auth/src/main/java/org/openecomp/auth/Auth.java b/aai-auth/src/main/java/org/openecomp/auth/Auth.java index 4d112887..3c5c3bee 100644 --- a/aai-auth/src/main/java/org/openecomp/auth/Auth.java +++ b/aai-auth/src/main/java/org/openecomp/auth/Auth.java @@ -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); - } } -- cgit 1.2.3-korg