if(client == null) {
throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR,
"The Domino OAuth Store for container " + securityToken.getContainer() + " did not return client information for viewer: " +
securityToken.getViewerId() + ", service: " + serviceName + " gadget: " + securityToken.getAppUrl());
}
OAuthConsumer consumer;
final KeyType keyType = client.getKeyType();
if (keyType == KeyType.RSA_PRIVATE) {
consumer = new OAuthConsumer(null, client.getConsumerKey(), null, provider);
// The oauth.net java code has lots of magic. By setting this property here, code thousands
// of lines away knows that the consumerSecret value in the consumer should be treated as
// an RSA private key and not an HMAC key.
consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.RSA_SHA1);
consumer.setProperty(RSA_SHA1.PRIVATE_KEY, client.getConsumerSecret());
} else if (keyType == KeyType.PLAINTEXT) {
consumer = new OAuthConsumer(null, client.getConsumerKey(), client.getConsumerSecret(), provider);
consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, "PLAINTEXT");
} else {
consumer = new OAuthConsumer(null, client.getConsumerKey(), client.getConsumerSecret(), provider);
consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
}
String callback = createCallback(client.isForceCallbackOverHttps());
return new ConsumerInfo(consumer, null, callback, false);
}