Can I suggest the following snippets of code for the java implementation of
ServiceProvider, allowing multiple clients having each one secret and one key :
#the loop loading the file into SampleOAuthProvider/loadConsumer
// for each entry in the properties file create a OAuthConsumer
for(Map.Entry prop : p.entrySet()) {
String consumerName = (String) prop.getKey();
//if we have a [OAuthConsumer] and not anything else like []
if(consumerName.matches("^\\[[\\w]+\\]$")){
consumerName = consumerName.substring(1,
consumerName.length()-1);
String consumerKey = (String)
p.getProperty(consumerName+".key");
String consumerSecret = (String)
p.getProperty(consumerName+".secret");
String consumerDescription = (String)
p.getProperty(consumerName+".description");
if(consumerKey!=null && consumerName!=null &&
consumerDescription!=null){
/**
* Creation of the consumer with the given information
*/
OAuthConsumer consumer = new OAuthConsumer(
null,
consumerKey,
consumerSecret,
null);
consumer.setProperty("name", consumerName);
consumer.setProperty("description", consumerDescription);
/**
* We add the consumer to the list
*/
ALL_CONSUMERS.put(consumerKey, consumer);
}
->with the give properties files
#
# Olivier ROMAND
#
# We define the following structure.
# Keep in mind to use the SAME case and name !
#
# for a tuple, called [OAuthConsumer], we define a set of
# - OAuthConsumer.key : the key for the given consumer
# - OAuthConsumer.secret : the shared secret
# - OAuthConsumer.description : inform who is accessing the service
#
# We don't provide the callback_url cause can be submitted during the call
# An example is
#
# [renderfarm]
# renderfarm.key=valueKey
# renderfarm.secret=valueSecret
# renderfarm.description=Renderfarm.fi
#first consumer
[testClient]
testClient.key=myKey
testClient.secret=mySecret
testClient.description=Test Client Application
Original issue reported on code.google.com by oliv.rm@gmail.com on 7 May 2010 at 10:05
Original issue reported on code.google.com by
oliv.rm@gmail.com
on 7 May 2010 at 10:05