public static void info(OperationContext opContext, String format, Object... args) { if (shouldLog(opContext, Log.INFO)) { Log.i(Constants.LOG_TAG, formatLogEntry(opContext, format, args)); } }
Logger.info(opContext, LogConstants.START_REQUEST, request.getURL(), request.getRequestProperty(Constants.HeaderConstants.DATE)); try { if (task.getSendStream() != null) { Logger.info(opContext, LogConstants.UPLOAD); final StreamMd5AndLength descriptor = Utility.writeToOutputStream(task.getSendStream(), request.getOutputStream(), task.getLength(), false /* rewindStream */, Logger.info(opContext, LogConstants.UPLOADDONE); Logger.info(opContext, LogConstants.GET_RESPONSE); Logger.info(opContext, LogConstants.RESPONSE_RECEIVED, currResult.getStatusCode(), currResult.getServiceRequestID(), currResult.getContentMD5(), currResult.getEtag(), currResult.getRequestDate()); Logger.info(opContext, LogConstants.ERROR_RECEIVING_RESPONSE); if (!responseReceivedEventTriggered) { if (task.getResult().getStartDate() == null) { Logger.info(opContext, LogConstants.PRE_PROCESS); RESULT_TYPE result = task.preProcessResponse(parentObject, client, opContext); Logger.info(opContext, LogConstants.PRE_PROCESS_DONE); Logger.info(opContext, LogConstants.POST_PROCESS); result = task.postProcessResponse(request, parentObject, client, opContext, result); Logger.info(opContext, LogConstants.POST_PROCESS_DONE);
@Override public Integer postProcessResponse(HttpURLConnection connection, CloudFile file, CloudFileClient client, OperationContext context, Integer storageObject) throws Exception { final Boolean validateMD5 = !options.getDisableContentMD5Validation() && !Utility.isNullOrEmpty(this.getContentMD5()); final String contentLength = connection.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); final long expectedLength = Long.parseLong(contentLength); Logger.info(context, String.format(SR.CREATING_NETWORK_STREAM, expectedLength)); final NetworkInputStream streamRef = new NetworkInputStream(connection.getInputStream(), expectedLength); try { // writeToOutputStream will update the currentRequestByteCount on this request in case a retry // is needed and download should resume from that point final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, validateMD5, context, options, true, this, this.getCurrentDescriptor()); // length was already checked by the NetworkInputStream, now check Md5 if (validateMD5 && !this.getContentMD5().equals(descriptor.getMd5())) { throw new StorageException(StorageErrorCodeStrings.INVALID_MD5, String.format( SR.FILE_HASH_MISMATCH, this.getContentMD5(), descriptor.getMd5()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } } finally { // Close the stream and return. Closing an already closed stream is harmless. So its fine to try // to drain the response and close the stream again in the executor. streamRef.close(); } return null; }
/** * Get the signature hash embedded inside the Shared Access Signature. * * @param stringToSign * The string to decode and hash * @param creds * Reference to the {@link StorageCredentials.}. * * @return The signature hash embedded inside the Shared Access Signature. * * @throws InvalidKeyException * @throws StorageException */ private static String generateSharedAccessSignatureHashHelper(String stringToSign, final StorageCredentials creds) throws StorageException, InvalidKeyException { Utility.assertNotNull("credentials", creds); Logger.debug(null, LogConstants.SIGNING, stringToSign); stringToSign = Utility.safeDecode(stringToSign); final String signature = StorageCredentialsHelper.computeHmac256(creds, stringToSign); Logger.verbose(null, LogConstants.SIGNING, stringToSign); return signature; }
Logger.debug(opContext, LogConstants.SIGNING, stringToSign);
Logger.trace(opContext, LogConstants.SIGNING, stringToSign);
Logger.info(opContext, LogConstants.START_REQUEST, request.getURL(), request.getRequestProperty(Constants.HeaderConstants.DATE)); try { if (task.getSendStream() != null) { Logger.info(opContext, LogConstants.UPLOAD); Logger.info(opContext, LogConstants.UPLOADDONE); Logger.info(opContext, LogConstants.GET_RESPONSE); Logger.info(opContext, LogConstants.RESPONSE_RECEIVED, currResult.getStatusCode(), currResult.getServiceRequestID(), currResult.getContentMD5(), currResult.getEtag(), currResult.getRequestDate()); Logger.info(opContext, LogConstants.ERROR_RECEIVING_RESPONSE); if (!responseReceivedEventTriggered) { if (task.getResult().getStartDate() == null) { Logger.info(opContext, LogConstants.PRE_PROCESS); RESULT_TYPE result = task.preProcessResponse(parentObject, client, opContext); Logger.info(opContext, LogConstants.PRE_PROCESS_DONE); Logger.info(opContext, LogConstants.POST_PROCESS); result = task.postProcessResponse(request, parentObject, client, opContext, result); Logger.info(opContext, LogConstants.POST_PROCESS_DONE); Logger.info(opContext, LogConstants.COMPLETE);
@Override public Integer postProcessResponse(HttpURLConnection connection, CloudBlob blob, CloudBlobClient client, OperationContext context, Integer storageObject) throws Exception { final Boolean validateMD5 = !options.getDisableContentMD5Validation() && !Utility.isNullOrEmpty(this.getContentMD5()); final String contentLength = connection.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); final long expectedLength = Long.parseLong(contentLength); Logger.info(context, String.format(SR.CREATING_NETWORK_STREAM, expectedLength)); final NetworkInputStream streamRef = new NetworkInputStream(connection.getInputStream(), expectedLength); try { // writeToOutputStream will update the currentRequestByteCount on this request in case a retry // is needed and download should resume from that point final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, validateMD5, context, options, this, this.getCurrentDescriptor()); // length was already checked by the NetworkInputStream, now check Md5 if (validateMD5 && !this.getContentMD5().equals(descriptor.getMd5())) { throw new StorageException(StorageErrorCodeStrings.INVALID_MD5, String.format( SR.BLOB_HASH_MISMATCH, this.getContentMD5(), descriptor.getMd5()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } } finally { // Close the stream and return. Closing an already closed stream is harmless. So its fine to try // to drain the response and close the stream again in the executor. streamRef.close(); } return null; }
Logger.debug(opContext, LogConstants.SIGNING, stringToSign);
/** * Get the signature hash embedded inside the Shared Access Signature. * * @param stringToSign * The string to decode and hash * @param creds * Reference to the {@link StorageCredentials}. * * @return The signature hash embedded inside the Shared Access Signature. * * @throws InvalidKeyException * @throws StorageException */ private static String generateSharedAccessSignatureHashHelper(String stringToSign, final StorageCredentials creds) throws StorageException, InvalidKeyException { Utility.assertNotNull("credentials", creds); Logger.trace(null, LogConstants.SIGNING, stringToSign); stringToSign = Utility.safeDecode(stringToSign); return StorageCredentialsHelper.computeHmac256(creds, stringToSign); }
public static void verbose(OperationContext opContext, String format, Object arg1) { if (shouldLog(opContext, Log.VERBOSE)) { Log.v(Constants.LOG_TAG, formatLogEntry(opContext, format, arg1)); } }
@Override public Integer postProcessResponse(HttpURLConnection connection, CloudFile file, CloudFileClient client, OperationContext context, Integer storageObject) throws Exception { final Boolean validateMD5 = !options.getDisableContentMD5Validation() && !Utility.isNullOrEmpty(this.getContentMD5()); final String contentLength = connection.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); final long expectedLength = Long.parseLong(contentLength); Logger.info(context, String.format(SR.CREATING_NETWORK_STREAM, expectedLength)); final NetworkInputStream streamRef = new NetworkInputStream(connection.getInputStream(), expectedLength); try { // writeToOutputStream will update the currentRequestByteCount on this request in case a retry // is needed and download should resume from that point final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, validateMD5, context, options, this, this.getCurrentDescriptor()); // length was already checked by the NetworkInputStream, now check Md5 if (validateMD5 && !this.getContentMD5().equals(descriptor.getMd5())) { throw new StorageException(StorageErrorCodeStrings.INVALID_MD5, String.format( SR.FILE_HASH_MISMATCH, this.getContentMD5(), descriptor.getMd5()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } } finally { // Close the stream and return. Closing an already closed stream is harmless. So its fine to try // to drain the response and close the stream again in the executor. streamRef.close(); } return null; }
Logger.trace(opContext, LogConstants.SIGNING, stringToSign);
public static void verbose(OperationContext opContext, String format, Object arg1, Object arg2) { if (shouldLog(opContext, Log.VERBOSE)) { Log.v(Constants.LOG_TAG, formatLogEntry(opContext, format, arg1, arg2)); } }