UserService.login Example DataThis is a featured page

To assist in developing your login code, the following example data can be used to unit test your timestamp and signature generation methods.

Given the following values:

Developer Key1f7d14a2db95e2f1d150207ddef31e329e02941a
User IDtestuser
Current Time2008-05-02T12:00:00.000-08:00
Secretf2326ecc6ae62ad118a23829b3a979eeef3d3dc5

Wetpaint expects the following parameters to be passed to the UserService.login, UserService.changeRole, and UserService.getReputation method:

cred.ts1209758400
cred.sigd2d6f6516bffe756557ca4cb77a0304d684f5fc8

For example login code, please see Sample Applications.



No user avatar
wetpaint
Latest page update: made by wetpaint , May 13 2008, 4:50 PM EDT (about this update About This Update wetpaint Edited by wetpaint


view changes

- complete history)
Keyword tags: None
More Info: links to this page
Started By Thread Subject Replies Last Post
cpatni Test Data is matching 3 May 15 2008, 1:52 PM EDT by blake
Thread started: May 14 2008, 11:11 PM EDT  Watch
I am getting df3490817aa209bb30bd27a8c0dd when I ran this test case.

@Test
public void testSignatureHMac() throws DatatypeConfigurationException, NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException {
String developerKey = "1f7d14a2db95e2f1d150207ddef31e329e02941a";
String userId = "testuser";
Date time = Wetpaint.xmlDate("2008-05-02T12:00:00.000-08:00");
String secret = "f2326ecc6ae62ad118a23829b3a979eeef3d3dc5";
int timestamp = 1209758400;
Assert.assertEquals(time.getTime() /1000, 1209758400);
String s = developerKey + userId + timestamp;
SecretKeySpec sks = new SecretKeySpec(Strings.hex(secret), "HmacSHA1");
Mac mac = Mac.getInstance(sks.getAlgorithm());
mac.init(sks);
String sig = Strings.hex(mac.doFinal(s.getBytes("UTF-8")));
Assert.assertEquals("d2d6f6516bffe756557ca4cb77a0304d684f5fc8", sig);
}

public static Date xmlDate(String text) throws DatatypeConfigurationException {
XMLGregorianCalendar xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(text);
return xgc.toGregorianCalendar().getTime();
}
Do you find this valuable?    
Keyword tags: XML:KEY:DATATYPE:
Show Last Reply
Showing 1 of 1 threads for this page