本文整理汇总了Java中com.amazonaws.util.Md5Utils.computeMD5Hash方法的典型用法代码示例。如果您正苦于以下问题:Java Md5Utils.computeMD5Hash方法的具体用法?Java Md5Utils.computeMD5Hash怎么用?Java Md5Utils.computeMD5Hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.util.Md5Utils
的用法示例。
在下文中一共展示了Md5Utils.computeMD5Hash方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObjectMD5
import com.amazonaws.util.Md5Utils; //导入方法依赖的package包/类
private String getObjectMD5(byte[] objectData) {
byte[] expectedMd5 = null;
try {
expectedMd5 = Md5Utils.computeMD5Hash(objectData);
} catch (Exception e) {}
return BinaryUtils.toHex(expectedMd5);
}
示例2: getAwsMessageMD5
import com.amazonaws.util.Md5Utils; //导入方法依赖的package包/类
private String getAwsMessageMD5(String message) {
byte[] expectedMd5 = null;
try {
expectedMd5 = Md5Utils.computeMD5Hash(message.getBytes(UTF8));
} catch (Exception e) {}
return BinaryUtils.toHex(expectedMd5);
}
示例3: setBucketCrossOriginConfiguration
import com.amazonaws.util.Md5Utils; //导入方法依赖的package包/类
@Override
public void setBucketCrossOriginConfiguration(
SetBucketCrossOriginConfigurationRequest setBucketCrossOriginConfigurationRequest) {
setBucketCrossOriginConfigurationRequest = beforeClientExecution(setBucketCrossOriginConfigurationRequest);
rejectNull(setBucketCrossOriginConfigurationRequest,
"The set bucket cross origin configuration request object must be specified.");
String bucketName = setBucketCrossOriginConfigurationRequest.getBucketName();
BucketCrossOriginConfiguration bucketCrossOriginConfiguration = setBucketCrossOriginConfigurationRequest.getCrossOriginConfiguration();
rejectNull(bucketName,
"The bucket name parameter must be specified when setting bucket cross origin configuration.");
rejectNull(bucketCrossOriginConfiguration,
"The cross origin configuration parameter must be specified when setting bucket cross origin configuration.");
Request<SetBucketCrossOriginConfigurationRequest> request = createRequest(bucketName, null, setBucketCrossOriginConfigurationRequest, HttpMethodName.PUT);
request.addParameter("cors", null);
byte[] content = new BucketConfigurationXmlFactory().convertToXmlByteArray(bucketCrossOriginConfiguration);
request.addHeader("Content-Length", String.valueOf(content.length));
request.addHeader("Content-Type", "application/xml");
request.setContent(new ByteArrayInputStream(content));
try {
byte[] md5 = Md5Utils.computeMD5Hash(content);
String md5Base64 = BinaryUtils.toBase64(md5);
request.addHeader("Content-MD5", md5Base64);
} catch ( Exception e ) {
throw new SdkClientException("Couldn't compute md5 sum", e);
}
invoke(request, voidResponseHandler, bucketName, null);
}
示例4: setBucketTaggingConfiguration
import com.amazonaws.util.Md5Utils; //导入方法依赖的package包/类
@Override
public void setBucketTaggingConfiguration(
SetBucketTaggingConfigurationRequest setBucketTaggingConfigurationRequest) {
setBucketTaggingConfigurationRequest = beforeClientExecution(setBucketTaggingConfigurationRequest);
rejectNull(setBucketTaggingConfigurationRequest,
"The set bucket tagging configuration request object must be specified.");
String bucketName = setBucketTaggingConfigurationRequest.getBucketName();
BucketTaggingConfiguration bucketTaggingConfiguration = setBucketTaggingConfigurationRequest.getTaggingConfiguration();
rejectNull(bucketName,
"The bucket name parameter must be specified when setting bucket tagging configuration.");
rejectNull(bucketTaggingConfiguration,
"The tagging configuration parameter must be specified when setting bucket tagging configuration.");
Request<SetBucketTaggingConfigurationRequest> request = createRequest(bucketName, null, setBucketTaggingConfigurationRequest, HttpMethodName.PUT);
request.addParameter("tagging", null);
byte[] content = new BucketConfigurationXmlFactory().convertToXmlByteArray(bucketTaggingConfiguration);
request.addHeader("Content-Length", String.valueOf(content.length));
request.addHeader("Content-Type", "application/xml");
request.setContent(new ByteArrayInputStream(content));
try {
byte[] md5 = Md5Utils.computeMD5Hash(content);
String md5Base64 = BinaryUtils.toBase64(md5);
request.addHeader("Content-MD5", md5Base64);
} catch ( Exception e ) {
throw new SdkClientException("Couldn't compute md5 sum", e);
}
invoke(request, voidResponseHandler, bucketName, null);
}
示例5: setContent
import com.amazonaws.util.Md5Utils; //导入方法依赖的package包/类
private void setContent(Request<?> request, byte[] content, String contentType, boolean setMd5) {
request.setContent(new ByteArrayInputStream(content));
request.addHeader("Content-Length", Integer.toString(content.length));
request.addHeader("Content-Type", contentType);
if (setMd5) {
try {
byte[] md5 = Md5Utils.computeMD5Hash(content);
String md5Base64 = BinaryUtils.toBase64(md5);
request.addHeader("Content-MD5", md5Base64);
} catch ( Exception e ) {
throw new AmazonClientException("Couldn't compute md5 sum", e);
}
}
}
示例6: etag
import com.amazonaws.util.Md5Utils; //导入方法依赖的package包/类
private String etag(File file) {
try {
FileInputStream fileInputStream = new FileInputStream(file);
byte[] md5Hash = Md5Utils.computeMD5Hash(fileInputStream);
return BinaryUtils.toHex(md5Hash);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
示例7: deleteObjects
import com.amazonaws.util.Md5Utils; //导入方法依赖的package包/类
@Override
public DeleteObjectsResult deleteObjects(DeleteObjectsRequest deleteObjectsRequest) {
deleteObjectsRequest = beforeClientExecution(deleteObjectsRequest);
Request<DeleteObjectsRequest> request = createRequest(deleteObjectsRequest.getBucketName(), null, deleteObjectsRequest, HttpMethodName.POST);
request.addParameter("delete", null);
if ( deleteObjectsRequest.getMfa() != null ) {
populateRequestWithMfaDetails(request, deleteObjectsRequest.getMfa());
}
populateRequesterPaysHeader(request, deleteObjectsRequest.isRequesterPays());
byte[] content = new MultiObjectDeleteXmlFactory().convertToXmlByteArray(deleteObjectsRequest);
request.addHeader("Content-Length", String.valueOf(content.length));
request.addHeader("Content-Type", "application/xml");
request.setContent(new ByteArrayInputStream(content));
try {
byte[] md5 = Md5Utils.computeMD5Hash(content);
String md5Base64 = BinaryUtils.toBase64(md5);
request.addHeader("Content-MD5", md5Base64);
} catch ( Exception e ) {
throw new SdkClientException("Couldn't compute md5 sum", e);
}
@SuppressWarnings("unchecked")
ResponseHeaderHandlerChain<DeleteObjectsResponse> responseHandler = new ResponseHeaderHandlerChain<DeleteObjectsResponse>(
new Unmarshallers.DeleteObjectsResultUnmarshaller(),
new S3RequesterChargedHeaderHandler<DeleteObjectsResponse>());
DeleteObjectsResponse response = invoke(request, responseHandler, deleteObjectsRequest.getBucketName(), null);
/*
* If the result was only partially successful, throw an exception
*/
if ( !response.getErrors().isEmpty() ) {
Map<String, String> headers = responseHandler.getResponseHeaders();
MultiObjectDeleteException ex = new MultiObjectDeleteException(
response.getErrors(),
response.getDeletedObjects());
ex.setStatusCode(200);
ex.setRequestId(headers.get(Headers.REQUEST_ID));
ex.setExtendedRequestId(headers.get(Headers.EXTENDED_REQUEST_ID));
ex.setCloudFrontId(headers.get(Headers.CLOUD_FRONT_ID));
throw ex;
}
DeleteObjectsResult result = new DeleteObjectsResult(response.getDeletedObjects(), response.isRequesterCharged());
return result;
}
示例8: getMD5
import com.amazonaws.util.Md5Utils; //导入方法依赖的package包/类
/**
* Calculates the MD5 hex code of a string (using the util class<br>
* that the AWS SDK uses for MD5 calculation).
*
* @param message Any text
* @return Upper-case MD5 checksum in HEX string format
*/
public String getMD5(String message) {
byte[] expectedMd5 = Md5Utils.computeMD5Hash(message.getBytes(UTF8));
return BinaryUtils.toHex(expectedMd5);
}