summaryrefslogtreecommitdiffstats
path: root/aai-auth/src/main/java/org/openecomp/auth/Auth.java
diff options
context:
space:
mode:
authorBharat saraswal <bharat.saraswal@huawei.com>2017-09-21 21:03:47 +0530
committerBharat saraswal <bharat.saraswal@huawei.com>2017-09-21 21:06:55 +0530
commit713460db4b63a038dba77541a757b6d40fb4dd74 (patch)
tree324b6f9799956c332e9c7e3d0a399444cfdb37e7 /aai-auth/src/main/java/org/openecomp/auth/Auth.java
parent2b3c5dd424520606c8ad3af4a97af92a4349e4aa (diff)
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 <bharat.saraswal@huawei.com>
Diffstat (limited to 'aai-auth/src/main/java/org/openecomp/auth/Auth.java')
-rw-r--r--aai-auth/src/main/java/org/openecomp/auth/Auth.java47
1 files changed, 20 insertions, 27 deletions
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);
- }
}