Class AbstractPayloadHandler
- java.lang.Object
-
- org.oa4mp.server.loader.oauth2.claims.AbstractPayloadHandler
-
- All Implemented Interfaces:
PayloadHandler
,Serializable
- Direct Known Subclasses:
AbstractAccessTokenHandler
,BasicRefreshTokenHandler
,IDTokenHandler
public abstract class AbstractPayloadHandler extends Object implements PayloadHandler
Created by Jeff Gaynor
on 4/21/20 at 5:00 PM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected net.sf.json.JSONObject
claims
protected OA2SE
oa2se
protected javax.servlet.http.HttpServletRequest
request
protected OA2ServiceTransaction
transaction
-
Constructor Summary
Constructors Constructor Description AbstractPayloadHandler(PayloadHandlerConfigImpl payloadHandlerConfig)
Create the instance for the authorization phase, while there is anHttpServletRequest
with possible headers that need to be processed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doServerVariables(net.sf.json.JSONObject targetClaims)
Used by access tokens and refresh tokens.protected void
doSubstitution(String key, net.sf.json.JSONObject targetClaims, net.sf.json.JSONObject x)
Do template substitutions for subject, audience, resource and issuer.net.sf.json.JSONObject
execute(ClaimSource source, net.sf.json.JSONObject claims)
Runs this specific claim source against the internal state of this class.net.sf.json.JSONObject
getClaims()
Get the claims (the actual payload).net.sf.json.JSONObject
getExtendedAttributes()
Gets the extended attributes from the current transaction.PayloadHandlerConfigImpl
getPhCfg()
int
getResponseCode()
String
getToken(edu.uiuc.ncsa.security.util.jwk.JSONWebKey key)
Returns the payload from this handler encoded with a key, if applicable.void
handleResponse(edu.uiuc.ncsa.security.util.scripting.ScriptRunResponse resp)
This takes the response from a script and unmarshalls the resourcesboolean
hasScript()
protected boolean
isEmpty(String x)
protected String
listToString(List list)
A utility to take a list and convert it to a blank delimited string.void
refresh()
If the claims need to be updated (e.g.void
setClaims(net.sf.json.JSONObject claims)
void
setExtendedAttributes(net.sf.json.JSONObject extendedAttributes)
void
setPhCfg(PayloadHandlerConfig phCfg)
void
setResponseCode(int responseCode)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.uiuc.ncsa.oa4mp.delegation.oa2.jwt.PayloadHandler
addRequestState, checkClaims, finish, getSources, init, refreshAccountingInformation, saveState, setAccountingInformation
-
-
-
-
Field Detail
-
transaction
protected OA2ServiceTransaction transaction
-
oa2se
protected OA2SE oa2se
-
claims
protected net.sf.json.JSONObject claims
-
request
protected javax.servlet.http.HttpServletRequest request
-
-
Constructor Detail
-
AbstractPayloadHandler
public AbstractPayloadHandler(PayloadHandlerConfigImpl payloadHandlerConfig)
Create the instance for the authorization phase, while there is anHttpServletRequest
with possible headers that need to be processed.- Parameters:
payloadHandlerConfig
-
-
-
Method Detail
-
getPhCfg
public PayloadHandlerConfigImpl getPhCfg()
- Specified by:
getPhCfg
in interfacePayloadHandler
-
getClaims
public net.sf.json.JSONObject getClaims()
Description copied from interface:PayloadHandler
Get the claims (the actual payload).- Specified by:
getClaims
in interfacePayloadHandler
- Returns:
-
setClaims
public void setClaims(net.sf.json.JSONObject claims)
-
setExtendedAttributes
public void setExtendedAttributes(net.sf.json.JSONObject extendedAttributes)
-
getExtendedAttributes
public net.sf.json.JSONObject getExtendedAttributes()
Gets the extended attributes from the current transaction. SeeOA2ServiceTransaction.getExtendedAttributes()
for more.- Specified by:
getExtendedAttributes
in interfacePayloadHandler
- Returns:
-
isEmpty
protected boolean isEmpty(String x)
-
execute
public net.sf.json.JSONObject execute(ClaimSource source, net.sf.json.JSONObject claims) throws Throwable
Description copied from interface:PayloadHandler
Runs this specific claim source against the internal state of this class. Note that the contract is that it returns the updated claims and if there are no new claims, it should just return its claims argument.- Specified by:
execute
in interfacePayloadHandler
- Returns:
- Throws:
Throwable
-
refresh
public void refresh() throws Throwable
Description copied from interface:PayloadHandler
If the claims need to be updated (e.g. for a refresh and the timestamps need adjusting) this method needs to be called. It's contract is to reget all of the claims.- Specified by:
refresh
in interfacePayloadHandler
- Throws:
Throwable
-
setPhCfg
public void setPhCfg(PayloadHandlerConfig phCfg)
- Specified by:
setPhCfg
in interfacePayloadHandler
-
getToken
public String getToken(edu.uiuc.ncsa.security.util.jwk.JSONWebKey key)
Description copied from interface:PayloadHandler
Returns the payload from this handler encoded with a key, if applicable.- Specified by:
getToken
in interfacePayloadHandler
- Returns:
-
setResponseCode
public void setResponseCode(int responseCode)
- Specified by:
setResponseCode
in interfacePayloadHandler
-
getResponseCode
public int getResponseCode()
- Specified by:
getResponseCode
in interfacePayloadHandler
-
handleResponse
public void handleResponse(edu.uiuc.ncsa.security.util.scripting.ScriptRunResponse resp) throws Throwable
Description copied from interface:PayloadHandler
This takes the response from a script and unmarshalls the resources- Specified by:
handleResponse
in interfacePayloadHandler
- Throws:
Throwable
-
listToString
protected String listToString(List list)
A utility to take a list and convert it to a blank delimited string. This is returned by any number of handlers. Note that objects- Parameters:
list
-- Returns:
-
hasScript
public boolean hasScript()
- Specified by:
hasScript
in interfacePayloadHandler
-
doServerVariables
protected void doServerVariables(net.sf.json.JSONObject targetClaims)
Used by access tokens and refresh tokens. This allows for certain substitutions for various server variables.- Parameters:
targetClaims
-
-
doSubstitution
protected void doSubstitution(String key, net.sf.json.JSONObject targetClaims, net.sf.json.JSONObject x)
Do template substitutions for subject, audience, resource and issuer.- Parameters:
key
-targetClaims
-x
-
-
-