sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-664: Send user name as HTTP header in client to server communication
Date Fri, 01 Mar 2013 18:55:47 GMT
Updated Branches:
  refs/heads/sqoop2 b0ac2e4e4 -> 2642b66cf


SQOOP-664: Send user name as HTTP header in client to server communication

(Abraham Elmahrek 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/2642b66c
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/2642b66c
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/2642b66c

Branch: refs/heads/sqoop2
Commit: 2642b66cfe0a31c2283be0cc17e9af5195e162a7
Parents: b0ac2e4
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Fri Mar 1 10:54:59 2013 -0800
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Fri Mar 1 10:54:59 2013 -0800

----------------------------------------------------------------------
 .../org/apache/sqoop/client/request/Request.java   |    2 ++
 .../sqoop/common/SqoopProtocolConstants.java       |    1 +
 .../org/apache/sqoop/server/RequestContext.java    |   10 ++++++++++
 3 files changed, 13 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/2642b66c/client/src/main/java/org/apache/sqoop/client/request/Request.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/Request.java b/client/src/main/java/org/apache/sqoop/client/request/Request.java
index 1720507..befb793 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/Request.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/Request.java
@@ -50,6 +50,8 @@ public class Request
     resource.addFilter(serverExceptionFilter);
 
     return resource
+      // Provide name of user executing request.
+      .header(SqoopProtocolConstants.HEADER_SQOOP_USERNAME, System.getProperty("user.name"))
       // Sqoop is using JSON for data transfers
       .accept(MediaType.APPLICATION_JSON_TYPE)
       // Transfer client locale to return client specific data

http://git-wip-us.apache.org/repos/asf/sqoop/blob/2642b66c/common/src/main/java/org/apache/sqoop/common/SqoopProtocolConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/common/SqoopProtocolConstants.java b/common/src/main/java/org/apache/sqoop/common/SqoopProtocolConstants.java
index 93c786d..d08c855 100644
--- a/common/src/main/java/org/apache/sqoop/common/SqoopProtocolConstants.java
+++ b/common/src/main/java/org/apache/sqoop/common/SqoopProtocolConstants.java
@@ -18,6 +18,7 @@
 package org.apache.sqoop.common;
 
 public final class SqoopProtocolConstants {
+  public static final String HEADER_SQOOP_USERNAME = "sqoop-user-name";
 
   public static final String HEADER_SQOOP_ERROR_CODE = "sqoop-error-code";
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/2642b66c/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 c6b6569..4ed7f58 100644
--- a/server/src/main/java/org/apache/sqoop/server/RequestContext.java
+++ b/server/src/main/java/org/apache/sqoop/server/RequestContext.java
@@ -18,6 +18,7 @@
 package org.apache.sqoop.server;
 
 import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.common.SqoopProtocolConstants;
 import org.apache.sqoop.server.common.ServerError;
 
 import javax.servlet.http.HttpServletRequest;
@@ -99,4 +100,13 @@ public class RequestContext {
   public Locale getAcceptLanguageHeader() {
     return new Locale(request.getHeader("Accept-Language"));
   }
+
+  /**
+   * Get username specified by custom username HTTP header.
+   *
+   * @return Name of user sending the request
+   */
+  public String getUserName() {
+	return request.getHeader(SqoopProtocolConstants.HEADER_SQOOP_USERNAME);
+  }
 }


Mime
View raw message