<commit_before>package com.manheim.util;

import com.amazonaws.auth.AWSCredentialsProviderChain;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.StringEntity;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Signs requests using the (at this time current) V4 request signing scheme.
 *
 * @see http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
 *
 * @author <NAME>
 */
class V4RequestSigner implements RequestSigner {
   public static final String ENCODING = "UTF8";
   public static final String ISO_8601_TIME_FORMAT = "yyyyMMdd'T'HHmmss'Z'";
   public static final String ISO_8601_DATE_FORMAT = "yyyyMMdd";
   public static final String PAYLOAD_HASHING_ALGORITHM = "SHA-256";
   public static final String SIGN_STRING_ALGORITHM_NAME = "AWS4-HMAC-SHA256";
   public static final String SIGNATURE_HASHING_ALGORITHM = "HmacSHA256";
   public static final String DATE_HEADER_NAME = "x-amz-date";
   public static final String HOST_HEADER_NAME = "host";
   public static final String AUTH_HEADER_NAME = "Authorization";
   public static final String AUTH_HEADER_FORMAT =
         SIGN_STRING_ALGORITHM_NAME + " Credential=%s/%s, SignedHeaders=%s, Signature=%s";

   private final String regionName;
   private final String serviceName;
   private final AWSCredentialsProviderChain awsCredentialsProvider;
   private final Date currentTime;

   public V4RequestSigner(AWSCredentialsProviderChain awsCredentialsProvider, String regionName, String serviceName) {
      this(awsCredentialsProvider, regionName, serviceName, null);<commit_msg>Set V4 signer to public access.<commit_after>package com.manheim.util;

import com.amazonaws.auth.AWSCredentialsProviderChain;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.StringEntity;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Signs requests using the (at this time current) V4 request signing scheme.
 *
 * @see http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
 *
 * @author <NAME>
 */
public class V4RequestSigner implements RequestSigner {
   public static final String ENCODING = "UTF8";
   public static final String ISO_8601_TIME_FORMAT = "yyyyMMdd'T'HHmmss'Z'";
   public static final String ISO_8601_DATE_FORMAT = "yyyyMMdd";
   public static final String PAYLOAD_HASHING_ALGORITHM = "SHA-256";
   public static final String SIGN_STRING_ALGORITHM_NAME = "AWS4-HMAC-SHA256";
   public static final String SIGNATURE_HASHING_ALGORITHM = "HmacSHA256";
   public static final String DATE_HEADER_NAME = "x-amz-date";
   public static final String HOST_HEADER_NAME = "host";
   public static final String AUTH_HEADER_NAME = "Authorization";
   public static final String AUTH_HEADER_FORMAT =
         SIGN_STRING_ALGORITHM_NAME + " Credential=%s/%s, SignedHeaders=%s, Signature=%s";

   private final String regionName;
   private final String serviceName;
   private final AWSCredentialsProviderChain awsCredentialsProvider;
   private final Date currentTime;

   public V4RequestSigner(AWSCredentialsProviderChain awsCredentialsProvider, String regionName, String serviceName) {
      this(awsCredentialsProvider, regionName, serviceName, null);
{'fraction_non_alphanumeric': 0.08503974945796193, 'fraction_numerical': 0.011322572874006263, 'mean_word_length': 5.718446601941747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5390411', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1240, 'n_words': 297}