com.dropbox.client2.session.TokenPair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropbox-java-sdk Show documentation
Show all versions of dropbox-java-sdk Show documentation
The Dropbox API for Java is a Dropbox supported client library for accessing the
JSON+REST interface to Dropbox. It supports OAuth proxied authentication. It is
designed to be simple and easy to use, as well as instructional in case you want
to write your own. It is MIT licensed.
The newest version!
package com.dropbox.client2.session;
import java.io.Serializable;
/**
*
* Just two strings -- a "key" and a "secret". Used by OAuth in several
* places (consumer key/secret, request token/secret, access token/secret).
* Use specific subclasses instead of using this class directly.
*
*/
public abstract class TokenPair implements Serializable
{
private static final long serialVersionUID = -42727403799660313L;
/**
* The "key" portion of the pair. For example, the "consumer key",
* "request token", or "access token". Will never contain the "|"
* character.
*/
public final String key;
/**
* The "secret" portion of the pair. For example, the "consumer secret",
* "request token secret", or "access token secret".
*/
public final String secret;
/**
* @param key assigned to {@link #key}.
* @param secret assigned to {@link #secret}.
*
* @throws IllegalArgumentException if key or secret is null or invalid.
*/
public TokenPair(String key, String secret) {
if (key == null)
throw new IllegalArgumentException("'key' must be non-null");
if (key.contains("|"))
throw new IllegalArgumentException("'key' must not contain a \"|\" character: \"" + key + "\"");
if (secret == null)
throw new IllegalArgumentException("'secret' must be non-null");
this.key = key;
this.secret = secret;
}
@Override
public int hashCode() {
return key.hashCode() ^ (secret.hashCode() << 1);
}
@Override
public boolean equals(Object o) {
return o instanceof TokenPair && equals((TokenPair) o);
}
public boolean equals(TokenPair o) {
return key.equals(o.key) && secret.equals(o.secret);
}
@Override
public String toString() {
return "{key=\"" + key + "\", secret=\"" + secret + "\"}";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy