consumer.setProperty(RSA_SHA1.PRIVATE_KEY, cks.getConsumerSecret()); } else if (keyType == KeyType.PLAINTEXT) { consumer = new OAuthConsumer(null, cks.getConsumerKey(), cks.getConsumerSecret(), provider); consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, "PLAINTEXT"); } else { consumer = new OAuthConsumer(null, cks.getConsumerKey(), cks.getConsumerSecret(), provider); consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
public ConsumerInfo getConsumerKeyAndSecret( SecurityToken securityToken, String serviceName, OAuthServiceProvider provider) throws GadgetException { ++consumerKeyLookupCount; BasicOAuthStoreConsumerIndex pk = new BasicOAuthStoreConsumerIndex(); pk.setGadgetUri(securityToken.getAppUrl()); pk.setServiceName(serviceName); BasicOAuthStoreConsumerKeyAndSecret cks = consumerInfos.get(pk); if (cks == null) { cks = defaultKey; } if (cks == null) { throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, "No key for gadget " + securityToken.getAppUrl() + " and service " + serviceName); } OAuthConsumer consumer = null; if (cks.getKeyType() == KeyType.RSA_PRIVATE) { consumer = new OAuthConsumer(null, cks.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, cks.getConsumerSecret()); } else { consumer = new OAuthConsumer(null, cks.getConsumerKey(), cks.getConsumerSecret(), provider); consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1); } String callback = (cks.getCallbackUrl() != null ? cks.getCallbackUrl() : defaultCallbackUrl); return new ConsumerInfo(consumer, cks.getKeyName(), callback); }
public ConsumerInfo getConsumerKeyAndSecret( SecurityToken securityToken, String serviceName, OAuthServiceProvider provider) throws GadgetException { ++consumerKeyLookupCount; BasicOAuthStoreConsumerIndex pk = new BasicOAuthStoreConsumerIndex(); pk.setGadgetUri(securityToken.getAppUrl()); pk.setServiceName(serviceName); BasicOAuthStoreConsumerKeyAndSecret cks = consumerInfos.get(pk); if (cks == null) { cks = defaultKey; } if (cks == null) { throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, "No key for gadget " + securityToken.getAppUrl() + " and service " + serviceName); } OAuthConsumer consumer = null; if (cks.getKeyType() == KeyType.RSA_PRIVATE) { consumer = new OAuthConsumer(null, cks.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, cks.getConsumerSecret()); } else { consumer = new OAuthConsumer(null, cks.getConsumerKey(), cks.getConsumerSecret(), provider); consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1); } String callback = (cks.getCallbackUrl() != null ? cks.getCallbackUrl() : defaultCallbackUrl); return new ConsumerInfo(consumer, cks.getKeyName(), callback); }