Class TokenFactory
- java.lang.Object
-
- org.oa4mp.delegation.common.token.impl.TokenFactory
-
public class TokenFactory extends Object
Created by Jeff Gaynor
on 10/19/23 at 1:08 PM
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TokenFactory.TokenParse
Used by theparseRawToken(String, TokenImpl)
function.
-
Constructor Summary
Constructors Constructor Description TokenFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AuthorizationGrantImpl
createAG(String rawToken)
static AccessTokenImpl
createAT(String rawToken)
static AccessTokenImpl
createAT(net.sf.json.JSONObject json)
Recreate the object from it serialized format.static IDTokenImpl
createIDT(String rawToken)
static IDTokenImpl
createIDT(net.sf.json.JSONObject json)
In some (legacy) cases, all you have is a parsed payload.static RefreshTokenImpl
createRT(String rawToken)
static RefreshTokenImpl
createRT(net.sf.json.JSONObject json)
Recreate the object from its serialized form.protected static net.sf.json.JSONObject
getPayload(String rawToken)
Given a raw signed JWT, H.P.S, this will determine if P, the payload, is a JSON object and decode it if so.protected static void
parseRawToken(String rawToken, TokenImpl token)
Parses the raw string from, e.g., a server response and populates a token from that.
-
-
-
Method Detail
-
parseRawToken
protected static void parseRawToken(String rawToken, TokenImpl token)
Parses the raw string from, e.g., a server response and populates a token from that.NOTE
This doesno validation on the raw token if it is a JWT, since many times that is not needed and it would create a lot of overhead for no reason. If you need the JWT validated, do it separately.- Parameters:
rawToken
-token
-
-
getPayload
protected static net.sf.json.JSONObject getPayload(String rawToken)
Given a raw signed JWT, H.P.S, this will determine if P, the payload, is a JSON object and decode it if so. Otherwise this returns a null.- Parameters:
rawToken
-- Returns:
-
createAG
public static AuthorizationGrantImpl createAG(String rawToken)
-
createRT
public static RefreshTokenImpl createRT(String rawToken)
-
createRT
public static RefreshTokenImpl createRT(net.sf.json.JSONObject json)
Recreate the object from its serialized form.- Parameters:
json
-- Returns:
-
createAT
public static AccessTokenImpl createAT(String rawToken)
-
createAT
public static AccessTokenImpl createAT(net.sf.json.JSONObject json)
Recreate the object from it serialized format. This will fail if the object is not serialized propertly!- Parameters:
json
-- Returns:
-
createIDT
public static IDTokenImpl createIDT(String rawToken)
-
createIDT
public static IDTokenImpl createIDT(net.sf.json.JSONObject json)
In some (legacy) cases, all you have is a parsed payload. This method will create a partial token for this, missing the raw token. Not great but about the best that can be done since the original token and its signature, header, etc. are missing is fake. Alternately, if the argument is just a serialized ID token, this will deserialize it and return it.- Parameters:
json
-- Returns:
-
-