Java Code Examples for net.oauth.OAuthConsumer#setProperty()

The following examples show how to use net.oauth.OAuthConsumer#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static OAuthAccessor convertToOAuthAccessor(Accessor accessor, OAuthConsumer oAuthConsumer)
        throws OAuthProblemException {
    if (accessor == null)
        return null;
    if (!oAuthConsumer.consumerKey.equals(accessor.getConsumerId()))
        throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_REFUSED);
    OAuthAccessor oAuthAccessor = new OAuthAccessor(oAuthConsumer);
    if (accessor.getType() == Accessor.Type.ACCESS)
        oAuthAccessor.accessToken = accessor.getToken();
    else
        oAuthAccessor.requestToken = accessor.getToken();
    oAuthAccessor.tokenSecret = accessor.getSecret();
    // Support Variable Accessor Secret http://wiki.oauth.net/w/page/12238502/AccessorSecret
    if (accessor.getAccessorSecret() != null)
        oAuthConsumer.setProperty(OAuthConsumer.ACCESSOR_SECRET, accessor.getAccessorSecret());
    return oAuthAccessor;
}
 
Example 2
Source File: WaveService.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param consumerKey the consumer key.
 * @param consumerSecret the consumer secret
 * @param rpcServerUrl the URL of the JSON-RPC request handler
 */
public ConsumerData(String consumerKey, String consumerSecret, String rpcServerUrl) {
  String consumerKeyPrefix = "";
  // NOTE(ljvderijk): Present for backwards capability.
  if (RPC_URL.equals(rpcServerUrl) || SANDBOX_RPC_URL.equals(rpcServerUrl)) {
    consumerKeyPrefix = "google.com:";
  }
  this.consumerKey = consumerKeyPrefix + consumerKey;
  this.consumerSecret = consumerSecret;
  this.rpcServerUrl = rpcServerUrl;

  userAuthenticated = false;
  OAuthConsumer consumer = new OAuthConsumer(null, consumerKey, consumerSecret, null);
  consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
  accessor = new OAuthAccessor(consumer);
}
 
Example 3
Source File: Util.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static OAuthAccessor convertToOAuthAccessor(Accessor accessor, OAuthConsumer oAuthConsumer)
        throws OAuthProblemException {
    if (accessor == null)
        return null;
    if (!oAuthConsumer.consumerKey.equals(accessor.getConsumerId()))
        throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_REFUSED);
    OAuthAccessor oAuthAccessor = new OAuthAccessor(oAuthConsumer);
    if (accessor.getType() == Accessor.Type.ACCESS)
        oAuthAccessor.accessToken = accessor.getToken();
    else
        oAuthAccessor.requestToken = accessor.getToken();
    oAuthAccessor.tokenSecret = accessor.getSecret();
    // Support Variable Accessor Secret http://wiki.oauth.net/w/page/12238502/AccessorSecret
    if (accessor.getAccessorSecret() != null)
        oAuthConsumer.setProperty(OAuthConsumer.ACCESSOR_SECRET, accessor.getAccessorSecret());
    return oAuthAccessor;
}
 
Example 4
Source File: WaveService.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param consumerKey the consumer key.
 * @param consumerSecret the consumer secret
 * @param rpcServerUrl the URL of the JSON-RPC request handler
 */
public ConsumerData(String consumerKey, String consumerSecret, String rpcServerUrl) {
  String consumerKeyPrefix = "";
  // NOTE(ljvderijk): Present for backwards capability.
  if (RPC_URL.equals(rpcServerUrl) || SANDBOX_RPC_URL.equals(rpcServerUrl)) {
    consumerKeyPrefix = "google.com:";
  }
  this.consumerKey = consumerKeyPrefix + consumerKey;
  this.consumerSecret = consumerSecret;
  this.rpcServerUrl = rpcServerUrl;

  userAuthenticated = false;
  OAuthConsumer consumer = new OAuthConsumer(null, consumerKey, consumerSecret, null);
  consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
  accessor = new OAuthAccessor(consumer);
}
 
Example 5
Source File: Util.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static OAuthConsumer convertToOAuthConsumer(Consumer consumer) {
    if (consumer == null)
        return null;
    OAuthConsumer oAuthConsumer = new OAuthConsumer(consumer.getCallbackUrl(), consumer.getId(),
            consumer.getSecret(), null);
    // Support Accessor Secret http://wiki.oauth.net/w/page/12238502/AccessorSecret
    oAuthConsumer.setProperty(OAuthConsumer.ACCESSOR_SECRET, consumer.getAccessorSecret());
    return oAuthConsumer;
}
 
Example 6
Source File: Util.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static OAuthConsumer convertToOAuthConsumer(Consumer consumer) {
    if (consumer == null)
        return null;
    OAuthConsumer oAuthConsumer = new OAuthConsumer(consumer.getCallbackUrl(), consumer.getId(),
            consumer.getSecret(), null);
    // Support Accessor Secret http://wiki.oauth.net/w/page/12238502/AccessorSecret
    oAuthConsumer.setProperty(OAuthConsumer.ACCESSOR_SECRET, consumer.getAccessorSecret());
    return oAuthConsumer;
}
 
Example 7
Source File: OAuthClientUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static OAuthAccessor createAccessor(Consumer consumer, Map<String, Object> props) {
    OAuthConsumer oAuthConsumer = new OAuthConsumer(null, consumer.getKey(), consumer.getSecret(),
                                                    null);
    if (props != null) {
        for (Map.Entry<String, Object> entry : props.entrySet()) {
            oAuthConsumer.setProperty(entry.getKey(), entry.getValue());
        }
    }
    return new OAuthAccessor(oAuthConsumer);
}