forked from scribejava/scribejava
/
Token.java
78 lines (67 loc) · 1.51 KB
/
Token.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package org.scribe.model;
import java.io.Serializable;
/**
* Represents an OAuth token (either request or access token) and its secret
*
* @author Pablo Fernandez
*/
public class Token implements Serializable
{
private static final long serialVersionUID = 715000866082812683L;
private final String token;
private final String secret;
private final String rawResponse;
/**
* Default constructor
*
* @param token token value
* @param secret token secret
*/
public Token(String token, String secret)
{
this(token, secret, null);
}
public Token(String token, String secret, String rawResponse)
{
this.token = token;
this.secret = secret;
this.rawResponse = rawResponse;
}
public String getToken()
{
return token;
}
public String getSecret()
{
return secret;
}
public String getRawResponse()
{
if (rawResponse == null)
{
throw new IllegalStateException("This token object was not constructed by scribe and does not have a rawResponse");
}
return rawResponse;
}
@Override
public String toString()
{
return String.format("Token[%s , %s]", token, secret);
}
/**
* Returns true if the token is empty (token = "", secret = "")
*/
public boolean isEmpty()
{
return "".equals(this.token) && "".equals(this.secret);
}
/**
* Factory method that returns an empty token (token = "", secret = "").
*
* Useful for two legged OAuth.
*/
public static Token empty()
{
return new Token("","");
}
}