com.dyuproject.oauth
Class Token

java.lang.Object
  extended by com.dyuproject.oauth.Token
All Implemented Interfaces:
Serializable, org.mortbay.util.ajax.JSON.Convertible

public final class Token
extends Object
implements Serializable, org.mortbay.util.ajax.JSON.Convertible

Token - stores the keys and state whether it is already useable or not.

Author:
David Yu
See Also:
Serialized Form
Date created:
May 30, 2009

Field Summary
static int ACCESS_TOKEN
          Access token state.
static int AUTHORIZED
          Authorized state.
static int UNAUTHORIZED
          Unauthorized state.
static int UNITIALIZED
          Uninitialized state.
 
Constructor Summary
Token()
           
Token(String ck)
           
Token(String ck, String key, String secret)
           
Token(String ck, String key, String secret, int state)
           
 
Method Summary
 boolean authorize(String key, String verifier)
          Checks whether the key and the verifier is authorized or not.
 void fromJSON(Map map)
           
 Object getAttribute(String key)
          Gets an attribute based from the given key.
 Map<String,Object> getAttributes()
          Gets the attributes of this token.
 String getCk()
          Gets the consumer secret.
 String getKey()
          Gets the consumer key.
 String getSecret()
          Gets the secret key; This is obtained from the exchanges (OAuth dance).
 int getState()
          Gets the state of the token.
 boolean isAuthentic()
          Checks whether the token is authentic (aka useable to make auth requests against the service provider.
 void setAttribute(String key, Object value)
          Sets an attribute based from the given key and value.
 void toJSON(org.mortbay.util.ajax.JSON.Output out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNITIALIZED

public static final int UNITIALIZED
Uninitialized state.

See Also:
Constant Field Values

UNAUTHORIZED

public static final int UNAUTHORIZED
Unauthorized state.

See Also:
Constant Field Values

AUTHORIZED

public static final int AUTHORIZED
Authorized state.

See Also:
Constant Field Values

ACCESS_TOKEN

public static final int ACCESS_TOKEN
Access token state. The token can already be used to do query data from the service provider.

See Also:
Constant Field Values
Constructor Detail

Token

public Token()

Token

public Token(String ck)

Token

public Token(String ck,
             String key,
             String secret)

Token

public Token(String ck,
             String key,
             String secret,
             int state)
Method Detail

getState

public int getState()
Gets the state of the token.


getCk

public String getCk()
Gets the consumer secret.


getKey

public String getKey()
Gets the consumer key.


getSecret

public String getSecret()
Gets the secret key; This is obtained from the exchanges (OAuth dance).


authorize

public boolean authorize(String key,
                         String verifier)
Checks whether the key and the verifier is authorized or not.


isAuthentic

public boolean isAuthentic()
Checks whether the token is authentic (aka useable to make auth requests against the service provider.


getAttributes

public Map<String,Object> getAttributes()
Gets the attributes of this token.


getAttribute

public Object getAttribute(String key)
Gets an attribute based from the given key.


setAttribute

public void setAttribute(String key,
                         Object value)
Sets an attribute based from the given key and value.


fromJSON

public void fromJSON(Map map)
Specified by:
fromJSON in interface org.mortbay.util.ajax.JSON.Convertible

toJSON

public void toJSON(org.mortbay.util.ajax.JSON.Output out)
Specified by:
toJSON in interface org.mortbay.util.ajax.JSON.Convertible


Copyright © 2008-2013. All Rights Reserved.