本文整理汇总了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");
}
示例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");
}
示例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;
}
示例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));
}
示例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;
}
示例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));
}