/** * Add the appropriate Authorization header to the HttpURLConnection. * @param connection The HttpURLConnection to which the header will be added. * @param method The HTTP method to use (GET, PUT, DELETE) * @param bucket the bucket name this request is for * @param key the key this request is for * @param pathArgs path arguments which are part of this request */ private void addAuthHeader(HttpURLConnection connection, String method, String bucket, String key, Map pathArgs) { if(connection.getRequestProperty("Date") == null) { connection.setRequestProperty("Date", httpDate()); } if(connection.getRequestProperty("Content-Type") == null) { connection.setRequestProperty("Content-Type", ""); } if(this.awsAccessKeyId != null && this.awsSecretAccessKey != null) { String canonicalString= Utils.makeCanonicalString(method, bucket, key, pathArgs, connection.getRequestProperties()); String encodedCanonical=Utils.encode(this.awsSecretAccessKey, canonicalString, false); connection.setRequestProperty("Authorization", "AWS " + this.awsAccessKeyId + ":" + encodedCanonical); } }
/** * Add the appropriate Authorization header to the HttpURLConnection. * @param connection The HttpURLConnection to which the header will be added. * @param method The HTTP method to use (GET, PUT, DELETE) * @param bucket the bucket name this request is for * @param key the key this request is for * @param pathArgs path arguments which are part of this request */ private void addAuthHeader(HttpURLConnection connection, String method, String bucket, String key, Map pathArgs) { if(connection.getRequestProperty("Date") == null) { connection.setRequestProperty("Date", httpDate()); } if(connection.getRequestProperty("Content-Type") == null) { connection.setRequestProperty("Content-Type", ""); } if(this.awsAccessKeyId != null && this.awsSecretAccessKey != null) { String canonicalString= Utils.makeCanonicalString(method, bucket, key, pathArgs, connection.getRequestProperties()); String encodedCanonical=Utils.encode(this.awsSecretAccessKey, canonicalString, false); connection.setRequestProperty("Authorization", "AWS " + this.awsAccessKeyId + ":" + encodedCanonical); } }