Example usage for org.springframework.security.oauth.common.signature HMAC_SHA1SignatureMethod MAC_NAME

List of usage examples for org.springframework.security.oauth.common.signature HMAC_SHA1SignatureMethod MAC_NAME

Introduction

In this page you can find the example usage for org.springframework.security.oauth.common.signature HMAC_SHA1SignatureMethod MAC_NAME.

Prototype

String MAC_NAME

To view the source code for org.springframework.security.oauth.common.signature HMAC_SHA1SignatureMethod MAC_NAME.

Click Source Link

Document

The MAC name (for interfacing with javax.crypto.*).

Usage

From source file:net.oauth.signature.GoogleCodeCompatibilityTests.java

/**
 * tests compatibilty with the google code HMAC_SHA1 signature.
 *//*  w  ww .j  a va 2  s. com*/
@Test
public void testHMAC_SHA1_1() throws Exception {
    HMAC_SHA1 theirMethod = new HMAC_SHA1();
    String baseString = "GET&http%3A%2F%2Flocalhost%3A8080%2Fgrailscrowd%2Foauth%2Frequest_token&oauth_consumer_key%3Dtonrconsumerkey%26oauth_nonce%3D1227967049787975000%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1227967049%26oauth_version%3D1.0";
    theirMethod.setConsumerSecret("xxxxxx");
    theirMethod.setTokenSecret("");
    SecretKeySpec spec = new SecretKeySpec("xxxxxx&".getBytes("UTF-8"), HMAC_SHA1SignatureMethod.MAC_NAME);
    HMAC_SHA1SignatureMethod ourMethod = new HMAC_SHA1SignatureMethod(spec);
    String theirSignature = theirMethod.getSignature(baseString);
    String ourSignature = ourMethod.sign(baseString);
    assertEquals(theirSignature, ourSignature);
}