List of usage examples for org.springframework.security.oauth.common.signature HMAC_SHA1SignatureMethod HMAC_SHA1SignatureMethod
public HMAC_SHA1SignatureMethod(SecretKey key)
From source file:net.oauth.signature.GoogleCodeCompatibilityTests.java
/** * tests compatibilty with the google code HMAC_SHA1 signature. *//*ww w . j ava 2 s. co m*/ @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); }