Class AbstractPayloadHandler
- java.lang.Object
-
- org.oa4mp.server.loader.oauth2.claims.AbstractPayloadHandler
-
- All Implemented Interfaces:
Serializable
,PayloadHandler
,OA2Scopes
- Direct Known Subclasses:
AbstractAccessTokenHandler
,BasicRefreshTokenHandler
,IDTokenHandler
public abstract class AbstractPayloadHandler extends Object implements PayloadHandler, OA2Scopes
Created by Jeff Gaynor
on 4/21/20 at 5:00 PM- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.oa4mp.delegation.server.OA2Scopes
OA2Scopes.ScopeUtil
-
-
Field Summary
Fields Modifier and Type Field Description protected OA2Client
client
protected OA2SE
oa2se
protected net.sf.json.JSONObject
payload
protected javax.servlet.http.HttpServletRequest
request
protected OA2ServiceTransaction
transaction
-
Fields inherited from interface org.oa4mp.delegation.server.OA2Scopes
basicScopes, EDU_PERSON_ORC_ID, nonPublicScopes, SCOPE_ADDRESS, SCOPE_CILOGON_INFO, SCOPE_EMAIL, SCOPE_MYPROXY, SCOPE_OFFLINE_ACCESS, SCOPE_OPENID, SCOPE_PHONE, SCOPE_PROFILE, SCOPE_TOKEN_MANAGER, SCOPE_USER_INFO
-
-
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, net.sf.json.JSONObject userMetaData)
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
getExtendedAttributes()
Gets the extended attributes from the current transaction.PayloadHandlerConfigImpl
getPhCfg()
int
getResponseCode()
TXRecord
getTXRecord()
void
handleResponse(edu.uiuc.ncsa.security.util.scripting.ScriptRunResponse resp)
This takes the response from a script and unmarshalls the resourcesboolean
hasScript()
boolean
hasTXRecord()
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
saveState(String execPhase)
Called at the end of each block, this lets the handler save its state.void
setExtendedAttributes(net.sf.json.JSONObject extendedAttributes)
void
setPayload(net.sf.json.JSONObject payload)
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 org.oa4mp.delegation.server.jwt.PayloadHandler
addRequestState, checkClaims, finish, getPayload, getSignedPayload, getSignedPayload, getSources, init, refreshAccountingInformation, setAccountingInformation
-
-
-
-
Field Detail
-
transaction
protected OA2ServiceTransaction transaction
-
oa2se
protected OA2SE oa2se
-
request
protected javax.servlet.http.HttpServletRequest request
-
client
protected OA2Client client
-
payload
protected net.sf.json.JSONObject payload
-
-
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
-
hasTXRecord
public boolean hasTXRecord()
-
getTXRecord
public TXRecord getTXRecord()
-
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
-
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, net.sf.json.JSONObject userMetaData)
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
-
-
saveState
public void saveState(String execPhase) throws Throwable
Description copied from interface:PayloadHandler
Called at the end of each block, this lets the handler save its state. Note that for OA4MP, the state is saved in the transaction which is saved once after the handlers run. Only put actual save code in here if needed, since it is apt to get called a lot.- Specified by:
saveState
in interfacePayloadHandler
- Throws:
Throwable
-
setPayload
public void setPayload(net.sf.json.JSONObject payload)
- Specified by:
setPayload
in interfacePayloadHandler
-
-