当前位置: 首页>>代码示例>>Java>>正文


Java SecureShuffleUtils.verifyReply方法代码示例

本文整理汇总了Java中org.apache.hadoop.mapreduce.security.SecureShuffleUtils.verifyReply方法的典型用法代码示例。如果您正苦于以下问题:Java SecureShuffleUtils.verifyReply方法的具体用法?Java SecureShuffleUtils.verifyReply怎么用?Java SecureShuffleUtils.verifyReply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.mapreduce.security.SecureShuffleUtils的用法示例。


在下文中一共展示了SecureShuffleUtils.verifyReply方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyConnection

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
private void verifyConnection(URL url, String msgToEncode, String encHash)
    throws IOException {
  // Validate response code
  int rc = connection.getResponseCode();
  if (rc != HttpURLConnection.HTTP_OK) {
    throw new IOException(
        "Got invalid response code " + rc + " from " + url +
        ": " + connection.getResponseMessage());
  }
  // get the shuffle version
  if (!ShuffleHeader.DEFAULT_HTTP_HEADER_NAME.equals(
      connection.getHeaderField(ShuffleHeader.HTTP_HEADER_NAME))
      || !ShuffleHeader.DEFAULT_HTTP_HEADER_VERSION.equals(
          connection.getHeaderField(ShuffleHeader.HTTP_HEADER_VERSION))) {
    throw new IOException("Incompatible shuffle response version");
  }
  // get the replyHash which is HMac of the encHash we sent to the server
  String replyHash = connection.getHeaderField(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);
  if(replyHash==null) {
    throw new IOException("security validation of TT Map output failed");
  }
  LOG.debug("url="+msgToEncode+";encHash="+encHash+";replyHash="+replyHash);
  // verify that replyHash is HMac of encHash
  SecureShuffleUtils.verifyReply(replyHash, encHash, shuffleSecretKey);
  LOG.info("for url="+msgToEncode+" sent hash and received reply");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:Fetcher.java

示例2: verifyConnection

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
private void verifyConnection(URL url, String msgToEncode, String encHash)
    throws IOException {
  // Validate response code
  int rc = connection.getResponseCode();
  if (rc != HttpURLConnection.HTTP_OK) {
    throw new IOException(
        "Got invalid response code " + rc + " from " + url +
        ": " + connection.getResponseMessage());
  }
  // get the shuffle version
  if (!ShuffleHeader.DEFAULT_HTTP_HEADER_NAME.equals(
      connection.getHeaderField(ShuffleHeader.HTTP_HEADER_NAME))
      || !ShuffleHeader.DEFAULT_HTTP_HEADER_VERSION.equals(
          connection.getHeaderField(ShuffleHeader.HTTP_HEADER_VERSION))) {
    throw new IOException("Incompatible shuffle response version");
  }
  // get the replyHash which is HMac of the encHash we sent to the server
  String replyHash = connection.getHeaderField(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);
  if(replyHash==null) {
    throw new IOException("security validation of TT Map output failed");
  }
  LOG.debug("url="+msgToEncode+";encHash="+encHash+";replyHash="+replyHash);
  // verify that replyHash is HMac of encHash
  SecureShuffleUtils.verifyReply(replyHash, encHash, shuffleSecretKey);
  LOG.debug("for url="+msgToEncode+" sent hash and received reply");
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:Fetcher.java

示例3: setupSecureConnection

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
public InputStream setupSecureConnection(MapOutputLocation mapOutputLoc, 
    URLConnection connection) throws IOException {

  // generate hash of the url
  String msgToEncode = 
    SecureShuffleUtils.buildMsgFrom(connection.getURL());
  String encHash = SecureShuffleUtils.hashFromString(msgToEncode, 
      jobTokenSecret);

  // put url hash into http header
  connection.setRequestProperty(
      SecureShuffleUtils.HTTP_HEADER_URL_HASH, encHash);
  
  InputStream input = getInputStream(connection, shuffleConnectionTimeout,
                                     shuffleReadTimeout); 

  // get the replyHash which is HMac of the encHash we sent to the server
  String replyHash = connection.getHeaderField(
      SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);
  if(replyHash==null) {
    throw new IOException("security validation of TT Map output failed");
  }
  if (LOG.isDebugEnabled())
    LOG.debug("url="+msgToEncode+";encHash="+encHash+";replyHash="
        +replyHash);
  // verify that replyHash is HMac of encHash
  SecureShuffleUtils.verifyReply(replyHash, encHash, jobTokenSecret);
  if (LOG.isDebugEnabled())
    LOG.debug("for url="+msgToEncode+" sent hash and receievd reply");
  return input;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:32,代码来源:ReduceTask.java

示例4: verifyRequest

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
/**
 * verify that request has correct HASH for the url
 * and also add a field to reply header with hash of the HASH
 * @param request
 * @param response
 * @param jt the job token
 * @throws IOException
 */
private void verifyRequest(HttpServletRequest request, 
    HttpServletResponse response, TaskTracker tracker, String jobId) 
throws IOException {
  SecretKey tokenSecret = tracker.getJobTokenSecretManager()
      .retrieveTokenSecret(jobId);
  // string to encrypt
  String enc_str = SecureShuffleUtils.buildMsgFrom(request);
  
  // hash from the fetcher
  String urlHashStr = request.getHeader(SecureShuffleUtils.HTTP_HEADER_URL_HASH);
  if(urlHashStr == null) {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    throw new IOException("fetcher cannot be authenticated " + 
        request.getRemoteHost());
  }
  int len = urlHashStr.length();
  LOG.debug("verifying request. enc_str="+enc_str+"; hash=..."+
      urlHashStr.substring(len-len/2, len-1)); // half of the hash for debug

  // verify - throws exception
  try {
    SecureShuffleUtils.verifyReply(urlHashStr, enc_str, tokenSecret);
  } catch (IOException ioe) {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    throw ioe;
  }
  
  // verification passed - encode the reply
  String reply = SecureShuffleUtils.generateHash(urlHashStr.getBytes(), tokenSecret);
  response.addHeader(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH, reply);
  
  len = reply.length();
  LOG.debug("Fetcher request verfied. enc_str="+enc_str+";reply="
      +reply.substring(len-len/2, len-1));
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:44,代码来源:TaskTracker.java

示例5: setupSecureConnection

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
private InputStream setupSecureConnection(MapOutputLocation mapOutputLoc, 
    URLConnection connection) throws IOException {

  // generate hash of the url
  String msgToEncode = 
    SecureShuffleUtils.buildMsgFrom(connection.getURL());
  String encHash = SecureShuffleUtils.hashFromString(msgToEncode, 
      jobTokenSecret);

  // put url hash into http header
  connection.setRequestProperty(
      SecureShuffleUtils.HTTP_HEADER_URL_HASH, encHash);
  
  InputStream input = getInputStream(connection, shuffleConnectionTimeout,
                                     shuffleReadTimeout); 

  // get the replyHash which is HMac of the encHash we sent to the server
  String replyHash = connection.getHeaderField(
      SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);
  if(replyHash==null) {
    throw new IOException("security validation of TT Map output failed");
  }
  if (LOG.isDebugEnabled())
    LOG.debug("url="+msgToEncode+";encHash="+encHash+";replyHash="
        +replyHash);
  // verify that replyHash is HMac of encHash
  SecureShuffleUtils.verifyReply(replyHash, encHash, jobTokenSecret);
  if (LOG.isDebugEnabled())
    LOG.debug("for url="+msgToEncode+" sent hash and receievd reply");
  return input;
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:32,代码来源:ReduceTask.java

示例6: verifyRequest

import org.apache.hadoop.mapreduce.security.SecureShuffleUtils; //导入方法依赖的package包/类
/**
 * verify that request has correct HASH for the url
 * and also add a field to reply header with hash of the HASH
 * @param request
 * @param response
 * @param jt the job token
 * @throws IOException
 */
private void verifyRequest(HttpServletRequest request, 
    HttpServletResponse response, TaskTracker tracker, String jobId) 
throws IOException {
  SecretKey tokenSecret = tracker.getJobTokenSecretManager()
      .retrieveTokenSecret(jobId);
  // string to encrypt
  String enc_str = SecureShuffleUtils.buildMsgFrom(request);
  
  // hash from the fetcher
  String urlHashStr = request.getHeader(SecureShuffleUtils.HTTP_HEADER_URL_HASH);
  if(urlHashStr == null) {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    throw new IOException("fetcher cannot be authenticated");
  }
  int len = urlHashStr.length();
  LOG.debug("verifying request. enc_str="+enc_str+"; hash=..."+
      urlHashStr.substring(len-len/2, len-1)); // half of the hash for debug

  // verify - throws exception
  try {
    SecureShuffleUtils.verifyReply(urlHashStr, enc_str, tokenSecret);
  } catch (IOException ioe) {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    throw ioe;
  }
  
  // verification passed - encode the reply
  String reply = SecureShuffleUtils.generateHash(urlHashStr.getBytes(), tokenSecret);
  response.addHeader(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH, reply);
  
  len = reply.length();
  LOG.debug("Fetcher request verfied. enc_str="+enc_str+";reply="
      +reply.substring(len-len/2, len-1));
}
 
开发者ID:rekhajoshm,项目名称:mapreduce-fork,代码行数:43,代码来源:TaskTracker.java


注:本文中的org.apache.hadoop.mapreduce.security.SecureShuffleUtils.verifyReply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。