sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject sqoop git commit: SQOOP-2184: Sqoop2: Add ServerName for authorization handler
Date Mon, 09 Mar 2015 07:27:01 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 9b96277b4 -> 1a4293df7


SQOOP-2184: Sqoop2: Add ServerName for authorization handler

(Richard Zhou via Abraham Elmahrek)


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

Branch: refs/heads/sqoop2
Commit: 1a4293df790368e48448a36ad15f9aa8b31acf81
Parents: 9b96277
Author: Abraham Elmahrek <abe@apache.org>
Authored: Mon Mar 9 00:26:23 2015 -0700
Committer: Abraham Elmahrek <abe@apache.org>
Committed: Mon Mar 9 00:26:23 2015 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/security/AuthorizationHandler.java  |  2 +-
 .../org/apache/sqoop/security/AuthorizationManager.java  | 11 ++++++++++-
 .../org/apache/sqoop/security/SecurityConstants.java     |  8 ++++++++
 dist/src/main/server/conf/sqoop.properties               |  1 +
 .../Authorization/DefaultAuthorizationHandler.java       |  5 ++++-
 5 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a4293df/core/src/main/java/org/apache/sqoop/security/AuthorizationHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/security/AuthorizationHandler.java b/core/src/main/java/org/apache/sqoop/security/AuthorizationHandler.java
index 7d60a01..a97c801 100644
--- a/core/src/main/java/org/apache/sqoop/security/AuthorizationHandler.java
+++ b/core/src/main/java/org/apache/sqoop/security/AuthorizationHandler.java
@@ -30,7 +30,7 @@ import java.util.List;
  */
 public abstract class AuthorizationHandler {
 
-  public abstract void doInitialize(AuthenticationProvider provider) throws ClassNotFoundException,
IllegalAccessException, InstantiationException;
+  public abstract void doInitialize(AuthenticationProvider provider, String serverName) throws
ClassNotFoundException, IllegalAccessException, InstantiationException;
 
   /**
    * Role related function

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a4293df/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 7f0fe27..76a13ff 100644
--- a/core/src/main/java/org/apache/sqoop/security/AuthorizationManager.java
+++ b/core/src/main/java/org/apache/sqoop/security/AuthorizationManager.java
@@ -40,6 +40,11 @@ public class AuthorizationManager implements Reconfigurable {
   public static final String DEFAULT_AUTHENTICATION_PROVIDER = "org.apache.sqoop.security.Authorization.DefaultAuthenticationProvider";
 
   /**
+   * Default authentication provider
+   */
+  public static final String DEFAULT_SERVER_NAME = "SqoopServer1";
+
+  /**
    * Default authorization auto upgrade option value
    */
   protected static boolean DEFAULT_AUTO_UPGRADE = false;
@@ -103,7 +108,11 @@ public class AuthorizationManager implements Reconfigurable {
             SecurityConstants.AUTHENTICATION_PROVIDER,
             DEFAULT_AUTHENTICATION_PROVIDER).trim();
 
-    authorizationHandler.doInitialize(SecurityFactory.getAuthenticationProvider(provider));
+    String serverName = SqoopConfiguration.getInstance().getContext().getString(
+            SecurityConstants.SERVER_NAME,
+            DEFAULT_SERVER_NAME).trim();
+
+    authorizationHandler.doInitialize(SecurityFactory.getAuthenticationProvider(provider),
serverName);
 
     LOG.info("Authorization loaded.");
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a4293df/core/src/main/java/org/apache/sqoop/security/SecurityConstants.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/security/SecurityConstants.java b/core/src/main/java/org/apache/sqoop/security/SecurityConstants.java
index fde6b60..eef818b 100644
--- a/core/src/main/java/org/apache/sqoop/security/SecurityConstants.java
+++ b/core/src/main/java/org/apache/sqoop/security/SecurityConstants.java
@@ -141,6 +141,14 @@ public final class SecurityConstants {
           PREFIX_AUTHORIZATION_CONFIG + "authentication_provider";
 
   /**
+   * The config specifies the sqoop server name for authorization.
+   * The default server name is "SqoopServer1"
+   * <tt>org.apache.sqoop.security.authorization.server_name</tt>.
+   */
+  public static final String SERVER_NAME =
+          PREFIX_AUTHORIZATION_CONFIG + "server_name";
+
+  /**
    * The config specifies the token kind in delegation token.
    */
   public static final String TOKEN_KIND = "sqoop_token_kind";

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a4293df/dist/src/main/server/conf/sqoop.properties
----------------------------------------------------------------------
diff --git a/dist/src/main/server/conf/sqoop.properties b/dist/src/main/server/conf/sqoop.properties
index f116e17..e7de613 100755
--- a/dist/src/main/server/conf/sqoop.properties
+++ b/dist/src/main/server/conf/sqoop.properties
@@ -165,6 +165,7 @@ org.apache.sqoop.execution.engine=org.apache.sqoop.execution.mapreduce.Mapreduce
 #org.apache.sqoop.security.authorization.access_controller=org.apache.sqoop.security.Authorization.DefaultAuthorizationAccessController
 #org.apache.sqoop.security.authorization.validator=org.apache.sqoop.security.Authorization.DefaultAuthorizationValidator
 #org.apache.sqoop.security.authorization.authentication_provider=org.apache.sqoop.security.Authorization.DefaultAuthenticationProvider
+#org.apache.sqoop.security.authorization.server_name=SqoopServer1
 
 # External connectors load path
 # "/path/to/external/connectors/": Add all the connector JARs in the specified folder

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1a4293df/security/src/main/java/org/apache/sqoop/security/Authorization/DefaultAuthorizationHandler.java
----------------------------------------------------------------------
diff --git a/security/src/main/java/org/apache/sqoop/security/Authorization/DefaultAuthorizationHandler.java
b/security/src/main/java/org/apache/sqoop/security/Authorization/DefaultAuthorizationHandler.java
index c60b8a5..f68ca54 100644
--- a/security/src/main/java/org/apache/sqoop/security/Authorization/DefaultAuthorizationHandler.java
+++ b/security/src/main/java/org/apache/sqoop/security/Authorization/DefaultAuthorizationHandler.java
@@ -49,6 +49,8 @@ public class DefaultAuthorizationHandler extends AuthorizationHandler {
 
   protected AuthenticationProvider authenticationProvider;
 
+  protected String serverName;
+
   public AuthorizationValidator getAuthorizationValidator() {
     return authorizationValidator;
   }
@@ -74,7 +76,7 @@ public class DefaultAuthorizationHandler extends AuthorizationHandler {
   }
 
   @Override
-  public void doInitialize(AuthenticationProvider provider) throws ClassNotFoundException,
IllegalAccessException, InstantiationException {
+  public void doInitialize(AuthenticationProvider provider, String serverName) throws ClassNotFoundException,
IllegalAccessException, InstantiationException {
     MapContext mapContext = SqoopConfiguration.getInstance().getContext();
     String accessController = mapContext.getString(
             SecurityConstants.AUTHORIZATION_ACCESS_CONTROLLER,
@@ -87,6 +89,7 @@ public class DefaultAuthorizationHandler extends AuthorizationHandler {
     this.authorizationValidator = SecurityFactory.getAuthorizationValidator(validator);
 
     this.authenticationProvider = provider;
+    this.serverName = serverName;
   }
 
   /**


Mime
View raw message