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 OA2Clientclientprotected OA2SEoa2seprotected org.kordamp.json.JSONObjectpayloadprotected javax.servlet.http.HttpServletRequestrequestprotected OA2ServiceTransactiontransaction-
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 anHttpServletRequestwith possible headers that need to be processed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoServerVariables(org.kordamp.json.JSONObject targetClaims, org.kordamp.json.JSONObject userMetaData)Used by access tokens and refresh tokens.protected voiddoSubstitution(String key, org.kordamp.json.JSONObject targetClaims, org.kordamp.json.JSONObject x)Do template substitutions for subject, audience, resource and issuer.org.kordamp.json.JSONObjectexecute(ClaimSource source, org.kordamp.json.JSONObject claims)Runs this specific claim source against the internal state of this class.org.kordamp.json.JSONObjectgetExtendedAttributes()Gets the extended attributes from the current transaction.PayloadHandlerConfigImplgetPhCfg()intgetResponseCode()TXRecordgetTXRecord()voidhandleResponse(edu.uiuc.ncsa.security.util.scripting.ScriptRunResponse resp)This takes the response from a script and unmarshalls the resourcesbooleanhasScript()booleanhasTXRecord()protected booleanisEmpty(String x)protected StringlistToString(List list)A utility to take a list and convert it to a blank delimited string.voidrefresh()If the claims need to be updated (e.g. for a refresh and the timestamps need adjusting) this method needs to be called.voidsaveState(String execPhase)Called at the end of each block, this lets the handler save its state.voidsetExtendedAttributes(org.kordamp.json.JSONObject extendedAttributes)voidsetPayload(org.kordamp.json.JSONObject payload)voidsetPhCfg(PayloadHandlerConfig phCfg)voidsetResponseCode(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 org.kordamp.json.JSONObject payload
-
-
Constructor Detail
-
AbstractPayloadHandler
public AbstractPayloadHandler(PayloadHandlerConfigImpl payloadHandlerConfig)
Create the instance for the authorization phase, while there is anHttpServletRequestwith possible headers that need to be processed.- Parameters:
payloadHandlerConfig-
-
-
Method Detail
-
getPhCfg
public PayloadHandlerConfigImpl getPhCfg()
- Specified by:
getPhCfgin interfacePayloadHandler
-
hasTXRecord
public boolean hasTXRecord()
-
getTXRecord
public TXRecord getTXRecord()
-
setExtendedAttributes
public void setExtendedAttributes(org.kordamp.json.JSONObject extendedAttributes)
-
getExtendedAttributes
public org.kordamp.json.JSONObject getExtendedAttributes()
Gets the extended attributes from the current transaction. SeeOA2ServiceTransaction.getExtendedAttributes()for more.- Specified by:
getExtendedAttributesin interfacePayloadHandler- Returns:
-
isEmpty
protected boolean isEmpty(String x)
-
execute
public org.kordamp.json.JSONObject execute(ClaimSource source, org.kordamp.json.JSONObject claims) throws Throwable
Description copied from interface:PayloadHandlerRuns 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:
executein interfacePayloadHandler- Returns:
- Throws:
Throwable
-
refresh
public void refresh() throws ThrowableDescription copied from interface:PayloadHandlerIf 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:
refreshin interfacePayloadHandler- Throws:
Throwable
-
setPhCfg
public void setPhCfg(PayloadHandlerConfig phCfg)
- Specified by:
setPhCfgin interfacePayloadHandler
-
setResponseCode
public void setResponseCode(int responseCode)
- Specified by:
setResponseCodein interfacePayloadHandler
-
getResponseCode
public int getResponseCode()
- Specified by:
getResponseCodein interfacePayloadHandler
-
handleResponse
public void handleResponse(edu.uiuc.ncsa.security.util.scripting.ScriptRunResponse resp) throws ThrowableDescription copied from interface:PayloadHandlerThis takes the response from a script and unmarshalls the resources- Specified by:
handleResponsein 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:
hasScriptin interfacePayloadHandler
-
doServerVariables
protected void doServerVariables(org.kordamp.json.JSONObject targetClaims, org.kordamp.json.JSONObject userMetaData)Used by access tokens and refresh tokens. This allows for certain substitutions for various server variables. So e.g. if a template is of the formread:/path/to/${sub}then the value of the sub claim will be used in place of ${sub}.See the Server Constants section in the token handler configuration.
- Parameters:
targetClaims-
-
doSubstitution
protected void doSubstitution(String key, org.kordamp.json.JSONObject targetClaims, org.kordamp.json.JSONObject x)
Do template substitutions for subject, audience, resource and issuer. This allows for strings and JSON arrays of strings to be substituted, but skips unknown object types.- Parameters:
key-targetClaims-x-
-
saveState
public void saveState(String execPhase) throws Throwable
Description copied from interface:PayloadHandlerCalled 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:
saveStatein interfacePayloadHandler- Throws:
Throwable
-
setPayload
public void setPayload(org.kordamp.json.JSONObject payload)
- Specified by:
setPayloadin interfacePayloadHandler
-
-