// Path: here-oauth-client/src/main/java/com/here/account/util/OAuthConstants.java
// public class OAuthConstants {
//     
//     /**
//      * We commonly use "UTF-8" charset, this String is its name.
//      */
//     public static final String UTF_8_STRING = "UTF-8";
//     
//     /**
//      * This is the constant for the "UTF-8" Charset already loaded.
//      */
//     public static final Charset UTF_8_CHARSET = Charset.forName(UTF_8_STRING);
// }


import static com.here.account.auth.SignatureMethod.ES512;
import com.here.account.util.OAuthConstants;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
            for (String key : queryParams.keySet()) {
                List<String> values = queryParams.get(key);
                for (String value : values) {
                    parameterSet.add(key, value);
                }
            }
        }

        //sort the parameters by the key and format them into key=value concatenated with &
        String parameterString = parameterSet.sortAndConcat();
        //combine the signature base and parameters
        signatureBaseString.append('&');
        signatureBaseString.append(urlEncode(parameterString));

        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("signatureBaseString=" + signatureBaseString);
        }

        return signatureBaseString.toString();
    }

    /**
     * Sign the cipher text using the given key and the specified algorithm
     * @param signatureBaseString the cipher text to be signed
     * @param key the signing key
     * @param signatureMethod signature method
     * @return signed cipher text
     */
    private static String generateSignature(String signatureBaseString, String key, SignatureMethod signatureMethod) {
        //get the bytes from the signature base string
// Path: here-oauth-client/src/main/java/com/here/account/util/OAuthConstants.java
// public class OAuthConstants {
//     
//     /**
//      * We commonly use "UTF-8" charset, this String is its name.
//      */
//     public static final String UTF_8_STRING = "UTF-8";
//     
//     /**
//      * This is the constant for the "UTF-8" Charset already loaded.
//      */
//     public static final Charset UTF_8_CHARSET = Charset.forName(UTF_8_STRING);
// }


// Path: here-oauth-client/src/main/java/com/here/account/auth/SignatureCalculator.java
import static com.here.account.auth.SignatureMethod.ES512;
import com.here.account.util.OAuthConstants;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

            for (String key : queryParams.keySet()) {
                List<String> values = queryParams.get(key);
                for (String value : values) {
                    parameterSet.add(key, value);
                }
            }
        }

        //sort the parameters by the key and format them into key=value concatenated with &
        String parameterString = parameterSet.sortAndConcat();
        //combine the signature base and parameters
        signatureBaseString.append('&');
        signatureBaseString.append(urlEncode(parameterString));

        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("signatureBaseString=" + signatureBaseString);
        }

        return signatureBaseString.toString();
    }

    /**
     * Sign the cipher text using the given key and the specified algorithm
     * @param signatureBaseString the cipher text to be signed
     * @param key the signing key
     * @param signatureMethod signature method
     * @return signed cipher text
     */
    private static String generateSignature(String signatureBaseString, String key, SignatureMethod signatureMethod) {
        //get the bytes from the signature base string
        byte[] bytesToSign = signatureBaseString.getBytes(OAuthConstants.UTF_8_CHARSET);