sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2483: Sqoop2: Findbugs: Fix singleton class problem in AuthenticationManager and AuthorizationManager
Date Sat, 15 Aug 2015 16:05:58 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 bb7c350d5 -> 9ecd944dc


SQOOP-2483: Sqoop2: Findbugs: Fix singleton class problem in AuthenticationManager and AuthorizationManager

(Colin Ma via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/9ecd944d
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/9ecd944d
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/9ecd944d

Branch: refs/heads/sqoop2
Commit: 9ecd944dc5e210da0381661b82e1bfb65af176ff
Parents: bb7c350
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Sat Aug 15 09:05:27 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Sat Aug 15 09:05:27 2015 -0700

----------------------------------------------------------------------
 .../sqoop/security/AuthenticationManager.java      | 17 ++++++++---------
 .../sqoop/security/AuthorizationManager.java       | 17 ++++++++---------
 .../authorization/AuthorizationEngine.java         |  2 +-
 .../sqoop/handler/AuthorizationRequestHandler.java | 14 +++++++-------
 .../apache/sqoop/handler/JobRequestHandler.java    |  2 +-
 .../apache/sqoop/handler/LinkRequestHandler.java   |  2 +-
 .../org/apache/sqoop/server/RequestContext.java    |  2 +-
 7 files changed, 27 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/9ecd944d/core/src/main/java/org/apache/sqoop/security/AuthenticationManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/security/AuthenticationManager.java b/core/src/main/java/org/apache/sqoop/security/AuthenticationManager.java
index 603643f..6b12e9f 100644
--- a/core/src/main/java/org/apache/sqoop/security/AuthenticationManager.java
+++ b/core/src/main/java/org/apache/sqoop/security/AuthenticationManager.java
@@ -33,12 +33,6 @@ public class AuthenticationManager implements Reconfigurable {
    */
   public static final String DEFAULT_AUTHENTICATION_HANDLER = "org.apache.sqoop.security.authentication.SimpleAuthenticationHandler";
 
-
-  /**
-   * Default authentication auto upgrade option value
-   */
-  protected static boolean DEFAULT_AUTO_UPGRADE = false;
-
   /**
    * Private instance to singleton of this class.
    */
@@ -52,6 +46,11 @@ public class AuthenticationManager implements Reconfigurable {
   }
 
   /**
+   * The private constructor for the singleton class,
+   */
+  private AuthenticationManager(){}
+
+  /**
    * Return current instance.
    *
    * @return Current instance
@@ -73,16 +72,16 @@ public class AuthenticationManager implements Reconfigurable {
   }
 
   /**
-   * Private AuthenticiationHandler to singleton of this class.
+   * Private Authentication Handler to singleton of this class.
    */
-  private static AuthenticationHandler authenticationHandler;
+  private AuthenticationHandler authenticationHandler;
 
   /**
    * Return current authentication handler.
    *
    * @return Current authentication handler
    */
-  public static AuthenticationHandler getAuthenticationHandler() {
+  public AuthenticationHandler getAuthenticationHandler() {
     return authenticationHandler;
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/9ecd944d/core/src/main/java/org/apache/sqoop/security/AuthorizationManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/security/AuthorizationManager.java b/core/src/main/java/org/apache/sqoop/security/AuthorizationManager.java
index 7699862..4afdf02 100644
--- a/core/src/main/java/org/apache/sqoop/security/AuthorizationManager.java
+++ b/core/src/main/java/org/apache/sqoop/security/AuthorizationManager.java
@@ -18,7 +18,6 @@
 package org.apache.sqoop.security;
 
 import org.apache.log4j.Logger;
-import org.apache.sqoop.common.MapContext;
 import org.apache.sqoop.core.Reconfigurable;
 import org.apache.sqoop.core.SqoopConfiguration;
 
@@ -45,11 +44,6 @@ public class AuthorizationManager implements Reconfigurable {
   public static final String DEFAULT_SERVER_NAME = "SqoopServer1";
 
   /**
-   * Default authorization auto upgrade option value
-   */
-  protected static boolean DEFAULT_AUTO_UPGRADE = false;
-
-  /**
    * Private instance to singleton of this class.
    */
   private static AuthorizationManager instance;
@@ -62,6 +56,11 @@ public class AuthorizationManager implements Reconfigurable {
   }
 
   /**
+   * The private constructor for the singleton class,
+   */
+  private AuthorizationManager(){}
+
+  /**
    * Return current instance.
    *
    * @return Current instance
@@ -83,16 +82,16 @@ public class AuthorizationManager implements Reconfigurable {
   }
 
   /**
-   * Private AuthenticiationHandler to singleton of this class.
+   * Private Authorization Handler to singleton of this class.
    */
-  private static AuthorizationHandler authorizationHandler;
+  private AuthorizationHandler authorizationHandler;
 
   /**
    * Return current authorization handler.
    *
    * @return Current authorization handler
    */
-  public static AuthorizationHandler getAuthorizationHandler() {
+  public AuthorizationHandler getAuthorizationHandler() {
     return authorizationHandler;
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/9ecd944d/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
----------------------------------------------------------------------
diff --git a/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
b/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
index 57e0da5..358a8bd 100644
--- a/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
+++ b/security/src/main/java/org/apache/sqoop/security/authorization/AuthorizationEngine.java
@@ -164,7 +164,7 @@ public class AuthorizationEngine {
   }
 
   private static void checkPrivilege(String doUserName, MPrivilege... privileges) {
-    AuthorizationHandler handler = AuthorizationManager.getAuthorizationHandler();
+    AuthorizationHandler handler = AuthorizationManager.getInstance().getAuthorizationHandler();
 
     MPrincipal principal = new MPrincipal(doUserName, MPrincipal.TYPE.USER);
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/9ecd944d/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
b/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
index a730413..bdac1de 100644
--- a/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/AuthorizationRequestHandler.java
@@ -133,7 +133,7 @@ public class AuthorizationRequestHandler implements RequestHandler {
   }
 
   private JsonBean getRoles(RequestContext ctx) {
-    AuthorizationHandler handler = AuthorizationManager.getAuthorizationHandler();
+    AuthorizationHandler handler = AuthorizationManager.getInstance().getAuthorizationHandler();
     AuditLoggerManager manager = AuditLoggerManager.getInstance();
     String principal_name = ctx.getParameterValue(PRINCIPAL_NAME_QUERY_PARAM);
     String principal_type = ctx.getParameterValue(PRINCIPAL_TYPE_QUERY_PARAM);
@@ -153,7 +153,7 @@ public class AuthorizationRequestHandler implements RequestHandler {
   }
 
   private JsonBean getPrincipal(RequestContext ctx) {
-    AuthorizationHandler handler = AuthorizationManager.getAuthorizationHandler();
+    AuthorizationHandler handler = AuthorizationManager.getInstance().getAuthorizationHandler();
     AuditLoggerManager manager = AuditLoggerManager.getInstance();
     String role_name = ctx.getParameterValue(ROLE_NAME_QUERY_PARAM);
 
@@ -201,7 +201,7 @@ public class AuthorizationRequestHandler implements RequestHandler {
   }
 
   private JsonBean getPrivilege(RequestContext ctx) {
-    AuthorizationHandler handler = AuthorizationManager.getAuthorizationHandler();
+    AuthorizationHandler handler = AuthorizationManager.getInstance().getAuthorizationHandler();
     AuditLoggerManager manager = AuditLoggerManager.getInstance();
     String principal_name = ctx.getParameterValue(PRINCIPAL_NAME_QUERY_PARAM);
     String principal_type = ctx.getParameterValue(PRINCIPAL_TYPE_QUERY_PARAM);
@@ -225,7 +225,7 @@ public class AuthorizationRequestHandler implements RequestHandler {
   }
 
   private JsonBean createRole(RequestContext ctx) {
-    AuthorizationHandler handler = AuthorizationManager.getAuthorizationHandler();
+    AuthorizationHandler handler = AuthorizationManager.getInstance().getAuthorizationHandler();
     AuditLoggerManager manager = AuditLoggerManager.getInstance();
 
     RoleBean bean = new RoleBean();
@@ -253,7 +253,7 @@ public class AuthorizationRequestHandler implements RequestHandler {
   }
 
   private JsonBean grantRevokeRole(RequestContext ctx, boolean isGrant) {
-    AuthorizationHandler handler = AuthorizationManager.getAuthorizationHandler();
+    AuthorizationHandler handler = AuthorizationManager.getInstance().getAuthorizationHandler();
     AuditLoggerManager manager = AuditLoggerManager.getInstance();
 
     RolesBean rolesBean = new RolesBean();
@@ -285,7 +285,7 @@ public class AuthorizationRequestHandler implements RequestHandler {
   }
 
   private JsonBean grantRevokePrivilege(RequestContext ctx, boolean isGrant) {
-    AuthorizationHandler handler = AuthorizationManager.getAuthorizationHandler();
+    AuthorizationHandler handler = AuthorizationManager.getInstance().getAuthorizationHandler();
     AuditLoggerManager manager = AuditLoggerManager.getInstance();
 
     PrincipalsBean principalsBean = new PrincipalsBean();
@@ -330,7 +330,7 @@ public class AuthorizationRequestHandler implements RequestHandler {
   }
 
   private JsonBean dropRole(RequestContext ctx) {
-    AuthorizationHandler handler = AuthorizationManager.getAuthorizationHandler();
+    AuthorizationHandler handler = AuthorizationManager.getInstance().getAuthorizationHandler();
     AuditLoggerManager manager = AuditLoggerManager.getInstance();
 
     String[] urlElements = ctx.getUrlElements();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/9ecd944d/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
index 0d06085..7f8ddbd 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -147,7 +147,7 @@ public class JobRequestHandler implements RequestHandler {
         ctx.getRequest().getRemoteAddr(), "delete", "job", jobIdentifier);
     repository.deleteJob(jobId);
     MResource resource = new MResource(String.valueOf(jobId), MResource.TYPE.JOB);
-    AuthorizationManager.getAuthorizationHandler().removeResource(resource);
+    AuthorizationManager.getInstance().getAuthorizationHandler().removeResource(resource);
     return JsonBean.EMPTY_BEAN;
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/9ecd944d/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
index f056686..8a6beb8 100644
--- a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
@@ -102,7 +102,7 @@ public class LinkRequestHandler implements RequestHandler {
 
     repository.deleteLink(linkId);
     MResource resource = new MResource(String.valueOf(linkId), MResource.TYPE.LINK);
-    AuthorizationManager.getAuthorizationHandler().removeResource(resource);
+    AuthorizationManager.getInstance().getAuthorizationHandler().removeResource(resource);
     return JsonBean.EMPTY_BEAN;
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/9ecd944d/server/src/main/java/org/apache/sqoop/server/RequestContext.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/server/RequestContext.java b/server/src/main/java/org/apache/sqoop/server/RequestContext.java
index 01aed41..492440f 100644
--- a/server/src/main/java/org/apache/sqoop/server/RequestContext.java
+++ b/server/src/main/java/org/apache/sqoop/server/RequestContext.java
@@ -121,7 +121,7 @@ public class RequestContext {
    * @return Name of user sending the request
    */
   public String getUserName() {
-    if (AuthenticationManager.getAuthenticationHandler().isSecurityEnabled()) {
+    if (AuthenticationManager.getInstance().getAuthenticationHandler().isSecurityEnabled())
{
       return HttpUserGroupInformation.get().getShortUserName();
     } else {
       return request.getParameter(PseudoAuthenticator.USER_NAME);


Mime
View raw message