• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Generating Nonce value for Orkut Oauth

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can anyone please help me with the following issue..

I am creating an web based application for orkut. But for that i need to generate oauth request which is mandatory.
So for it we need a parameter called "nonce".. which means

Random 64-bit, unsigned number encoded as an ASCII string in decimal format. The nonce/timestamp pair should always be unique to prevent replay attacks.


For genrating nonce value i am writing following code:

Random ran = new Random();
long nonce1 = ran.nextLong();

Long nonce = Math.abs(new Long(nonce1));
String hexString = Long.toHexString(nonce);



Please help me where i am going wrong or can anyone provide with the code??



 
Ranch Hand
Posts: 607
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the problem that you are facing with this code is?
 
kalpesh pradhan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sam Mercs wrote:And the problem that you are facing with this code is?




That its not correctly generating the nonce value... we get invalid signature as response.
 
Bartender
Posts: 2330
100
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take system time in ms, XOR it with some predefined value say XXX and then take the MD5 hash of the result.

where XXX is any predetermined constant say : "@$#SDFG$#^%E%DSFdfgjhk6875678wqe35REYT"
 
kalpesh pradhan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

salvin francis wrote:Take system time in ms, XOR it with some predefined value say XXX and then take the MD5 hash of the result.

where XXX is any predetermined constant say : "@$#SDFG$#^%E%DSFdfgjhk6875678wqe35REYT"





Can you please give me the java code itself... please its urgent
 
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
salvin francis
Bartender
Posts: 2330
100
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kalpesh,
Post your code here and i could help you complete it.

no problems if its incomplete or wrong...

As i suggested:

1. You need to obtain the system time in milliseconds, you could use the Calendar class for that
2. You need a hard coded (or maybe read from file) value to be XORed
3. You need to calculate MD5 hash of the XORed value:


 
salvin francis
Bartender
Posts: 2330
100
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also its not necessary that my approach is right, there could be a better approach, keep in mind that calculating an hash is generally not a fast process.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your directions say "decimal format", not "hexadecimal format." Is the correct answer to just use nonce.toString() instead of toHexString() in the original code? Or are the directions wrong?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!