Example usage for org.apache.commons.codec.digest HmacAlgorithms HMAC_SHA_256

List of usage examples for org.apache.commons.codec.digest HmacAlgorithms HMAC_SHA_256

Introduction

In this page you can find the example usage for org.apache.commons.codec.digest HmacAlgorithms HMAC_SHA_256.

Prototype

HmacAlgorithms HMAC_SHA_256

To view the source code for org.apache.commons.codec.digest HmacAlgorithms HMAC_SHA_256.

Click Source Link

Document

The HmacSHA256 Message Authentication Code (MAC) algorithm specified in RFC 2104 and FIPS PUB 180-2.

Usage

From source file:com.arrow.acs.GatewayPayloadSigner.java

public String signV1() {
    String method = "signV1";
    AcsUtils.notEmpty(apiKey, "apiKey is required");
    AcsUtils.notEmpty(secretKey, "secretKey is required");

    StringBuilder stringToSign = new StringBuilder();
    stringToSign.append(hash(buildCanonicalRequest())).append('\n');
    stringToSign.append(apiKey).append('\n');
    stringToSign.append(PAYLOAD_SIGNATURE_VERSION_1);
    logDebug(method, "stringToSign: %s", stringToSign);

    String signingKey = new HmacUtils(HmacAlgorithms.HMAC_SHA_256, PAYLOAD_SIGNATURE_VERSION_1)
            .hmacHex(new HmacUtils(HmacAlgorithms.HMAC_SHA_256, apiKey).hmacHex(secretKey));
    logDebug(method, "signingKey: %s", signingKey);

    String signature = new HmacUtils(HmacAlgorithms.HMAC_SHA_256, signingKey).hmacHex(stringToSign.toString());
    logDebug(method, "signature: %s", signature);

    return signature;
}

From source file:alfio.model.Ticket.java

private static String hmacSHA256Base64(String key, String code) {
    return Base64.getEncoder().encodeToString(new HmacUtils(HmacAlgorithms.HMAC_SHA_256, key).hmac(code));
}

From source file:alfio.manager.PaypalManager.java

private static String computeHMAC(CustomerName customerName, String email, String billingAddress, Event event) {
    return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, event.getPrivateKey())
            .hmacHex(StringUtils.trimToEmpty(customerName.getFullName()) + StringUtils.trimToEmpty(email)
                    + StringUtils.trimToEmpty(billingAddress));
}

From source file:org.ligoj.app.plugin.prov.aws.auth.AWS4SignerBase.java

/**
 * do a HMac sha256 sign/*from   w  w w. j a  v a 2s  .c o  m*/
 * 
 * @param stringData
 *            data as string
 * @param key
 *            key
 * @return signature
 */
protected byte[] sign(final String stringData, final byte[] key) {
    return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, key).hmac(stringData);
}