Class TokenImpl
- java.lang.Object
-
- org.oa4mp.delegation.common.token.impl.TokenImpl
-
- All Implemented Interfaces:
Serializable,NewToken,Token
- Direct Known Subclasses:
AccessTokenImpl,AuthorizationGrantImpl,IDTokenImpl,RefreshTokenImpl
public class TokenImpl extends Object implements NewToken
OAuth 1.0 tokens always have an associated shared secret. These do not.Created by Jeff Gaynor
on Mar 16, 2011 at 12:58:52 PM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringEXPIRES_ATstatic StringIS_JWTstatic StringJTIstatic StringPAYLOADstatic StringTOKENstatic StringTOKEN_TYPE-
Fields inherited from interface org.oa4mp.delegation.common.token.NewToken
OLD_SYSTEM_DEFAULT_LIFETIME
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringBuildercreateString()Does everything but final ].voiddecodeToken(String b32Encoded)StringencodeToken()booleanequals(Object obj)voidfromJSON(net.sf.json.JSONObject json)longgetExpiresAt()longgetIssuedAt()URIgetJti()If this is a JWT, then this returns the JTI.edu.uiuc.ncsa.security.core.IdentifiergetJTIAsIdentifier()Convenience method to return the JTI as an identifier.longgetLifetime()net.sf.json.JSONObjectgetPayload()If this token is a JWT, the is the actual payload.StringgetToken()The token.protected StringgetTokenType()URIgetURIToken()StringgetVersion()booleanhasJTI()booleanhasPayload()protected voidinit(URI uri)booleanisExpired()booleanisJWT()booleanisOldVersion()Checks if the version is null, effectively meaning it was created before versions existed.static voidmain(String[] args)protected voidnewFromJSON(net.sf.json.JSONObject json)protected net.sf.json.JSONObjectnewToJSON()voidoldFromJSON(net.sf.json.JSONObject json)protected net.sf.json.JSONObjectoldToJSON()voidsetExpiresAt(long expiresAt)voidsetIssuedAt(long issuedAt)voidsetJti(URI jti)voidsetJWT(boolean JWT)voidsetLifetime(long lifetime)voidsetPayload(net.sf.json.JSONObject payload)voidsetToken(String token)voidsetToken(URI token)voidsetVersion(String version)net.sf.json.JSONObjecttoJSON()StringtoString()
-
-
-
Field Detail
-
TOKEN_TYPE
public static final String TOKEN_TYPE
- See Also:
- Constant Field Values
-
EXPIRES_AT
public static final String EXPIRES_AT
- See Also:
- Constant Field Values
-
IS_JWT
public static final String IS_JWT
- See Also:
- Constant Field Values
-
PAYLOAD
public static final String PAYLOAD
- See Also:
- Constant Field Values
-
TOKEN
public static final String TOKEN
- See Also:
- Constant Field Values
-
JTI
public static final String JTI
- See Also:
- Constant Field Values
-
-
Method Detail
-
getVersion
public String getVersion()
- Specified by:
getVersionin interfaceNewToken
-
hasJTI
public boolean hasJTI()
-
getJti
public URI getJti()
If this is a JWT, then this returns the JTI. If not, it just returns the token.
-
setJti
public void setJti(URI jti)
-
getJTIAsIdentifier
public edu.uiuc.ncsa.security.core.Identifier getJTIAsIdentifier()
Convenience method to return the JTI as an identifier.- Specified by:
getJTIAsIdentifierin interfaceNewToken- Returns:
-
isOldVersion
public boolean isOldVersion()
Checks if the version is null, effectively meaning it was created before versions existed.- Returns:
-
isJWT
public boolean isJWT()
-
setJWT
public void setJWT(boolean JWT)
-
init
protected void init(URI uri)
-
getURIToken
public URI getURIToken()
-
setToken
public void setToken(URI token)
-
setToken
public void setToken(String token)
-
createString
protected StringBuilder createString()
Does everything but final ]. Over-ride this and yourtoString()will work- Returns:
-
setLifetime
public void setLifetime(long lifetime)
-
getLifetime
public long getLifetime()
- Specified by:
getLifetimein interfaceNewToken
-
setVersion
public void setVersion(String version)
-
setIssuedAt
public void setIssuedAt(long issuedAt)
-
getIssuedAt
public long getIssuedAt()
- Specified by:
getIssuedAtin interfaceNewToken
-
newToJSON
protected net.sf.json.JSONObject newToJSON()
-
oldToJSON
protected net.sf.json.JSONObject oldToJSON()
-
hasPayload
public boolean hasPayload()
-
getPayload
public net.sf.json.JSONObject getPayload()
If this token is a JWT, the is the actual payload.- Returns:
-
setPayload
public void setPayload(net.sf.json.JSONObject payload)
-
fromJSON
public void fromJSON(net.sf.json.JSONObject json)
-
getTokenType
protected String getTokenType()
-
oldFromJSON
public void oldFromJSON(net.sf.json.JSONObject json)
-
newFromJSON
protected void newFromJSON(net.sf.json.JSONObject json)
-
encodeToken
public String encodeToken()
- Specified by:
encodeTokenin interfaceNewToken
-
decodeToken
public void decodeToken(String b32Encoded)
- Specified by:
decodeTokenin interfaceNewToken
-
main
public static void main(String[] args)
-
getExpiresAt
public long getExpiresAt()
-
setExpiresAt
public void setExpiresAt(long expiresAt)
-
-