Class BasicClaimsSourceImpl
- java.lang.Object
-
- org.oa4mp.server.loader.oauth2.claims.BasicClaimsSourceImpl
-
- All Implemented Interfaces:
ClaimSource
,Serializable
- Direct Known Subclasses:
CodeClaimSource
,FSClaimSource
,HTTPHeaderClaimsSource
,LDAPClaimsSource
,TestClaimSource
public class BasicClaimsSourceImpl extends Object implements ClaimSource
The most basic implementation of aClaimSource
.Extending this class
If you want to write your own custom Java claim source and invoke it, you must extend this class and over-right the
realProcessing(JSONObject, HttpServletRequest, ServiceTransaction)
method. Generally when claims are being gotten, the configuration that is created is passed along faithfully and you may access your custom parameters by invokingClaimSourceConfiguration.getProperty(String)
. An example is inTestClaimSource
.Created by Jeff Gaynor
on 8/17/15 at 4:10 PM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected GroupHandler
groupHandler
-
Constructor Summary
Constructors Constructor Description BasicClaimsSourceImpl()
BasicClaimsSourceImpl(OA2SE oa2SE)
BasicClaimsSourceImpl(edu.uiuc.ncsa.qdl.variables.QDLStem stem)
BasicClaimsSourceImpl(edu.uiuc.ncsa.qdl.variables.QDLStem stem, OA2SE oa2SE)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fromQDL(edu.uiuc.ncsa.qdl.variables.QDLStem stem)
Collection<String>
getClaims()
returns a (unique) collection of claims.ClaimSourceConfiguration
getConfiguration()
GroupHandler
getGroupHandler()
OA2SE
getOa2SE()
Optionally, the service environment may be injected into a scope handler to get configuration of components, e.g.List<String>
getOmitList()
This is the list of claims from the headers to omit.edu.uiuc.ncsa.security.util.functor.parser.FunctorScript
getPostProcessor()
See comment inClaimSource.getPreProcessor()
.edu.uiuc.ncsa.security.util.functor.parser.FunctorScript
getPreProcessor()
This is the preprocessor after it has run.Collection<String>
getScopes()
A list of scopes that this source supports.boolean
hasConfiguration()
boolean
hasJSONPostProcessor()
boolean
hasJSONPreProcessor()
boolean
isEnabled()
boolean
isRunAtAuthorization()
This should usually be false.net.sf.json.JSONObject
process(net.sf.json.JSONObject claims, ServiceTransaction transaction)
At the most basic level, this just returns theUserInfo
object passed to it.net.sf.json.JSONObject
process(net.sf.json.JSONObject claims, javax.servlet.http.HttpServletRequest request, ServiceTransaction transaction)
This also just returns theUserInfo
object passed in.protected net.sf.json.JSONObject
realProcessing(net.sf.json.JSONObject claims, javax.servlet.http.HttpServletRequest request, ServiceTransaction transaction)
This is the actual place to put your code that only processes the claim source.void
setConfiguration(ClaimSourceConfiguration configuration)
This passes in aJSONObject
that is in turn used to configure the source.void
setGroupHandler(GroupHandler groupHandler)
void
setOa2SE(OA2SE oa2SE)
void
setOmitList(List<String> omitList)
void
setScopes(Collection<String> scopes)
Set the scopes for this source.edu.uiuc.ncsa.qdl.variables.QDLStem
toQDL()
-
-
-
Field Detail
-
groupHandler
protected GroupHandler groupHandler
-
-
Constructor Detail
-
BasicClaimsSourceImpl
public BasicClaimsSourceImpl(OA2SE oa2SE)
-
BasicClaimsSourceImpl
public BasicClaimsSourceImpl()
-
BasicClaimsSourceImpl
public BasicClaimsSourceImpl(edu.uiuc.ncsa.qdl.variables.QDLStem stem)
-
BasicClaimsSourceImpl
public BasicClaimsSourceImpl(edu.uiuc.ncsa.qdl.variables.QDLStem stem, OA2SE oa2SE)
-
-
Method Detail
-
getOmitList
public List<String> getOmitList()
This is the list of claims from the headers to omit. In other words, this module will reject these out of hand and never return them in a claims object. This is extremely useful in not having existing claims being over-written (which can happen if something like mod_auth_openidc is acting as an intermediary and adding spurious claims.)- Returns:
-
setConfiguration
public void setConfiguration(ClaimSourceConfiguration configuration)
Description copied from interface:ClaimSource
This passes in aJSONObject
that is in turn used to configure the source. It is up to the implementaton to make sense of this.- Specified by:
setConfiguration
in interfaceClaimSource
-
getConfiguration
public ClaimSourceConfiguration getConfiguration()
- Specified by:
getConfiguration
in interfaceClaimSource
-
hasConfiguration
public boolean hasConfiguration()
- Specified by:
hasConfiguration
in interfaceClaimSource
-
hasJSONPreProcessor
public boolean hasJSONPreProcessor()
-
hasJSONPostProcessor
public boolean hasJSONPostProcessor()
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabled
in interfaceClaimSource
-
getOa2SE
public OA2SE getOa2SE()
Optionally, the service environment may be injected into a scope handler to get configuration of components, e.g.- Returns:
-
setOa2SE
public void setOa2SE(OA2SE oa2SE)
-
getScopes
public Collection<String> getScopes()
Description copied from interface:ClaimSource
A list of scopes that this source supports. Any scope that is not recognized by this source should be rejected.- Specified by:
getScopes
in interfaceClaimSource
- Returns:
-
process
public net.sf.json.JSONObject process(net.sf.json.JSONObject claims, ServiceTransaction transaction) throws UnsupportedScopeException
At the most basic level, this just returns theUserInfo
object passed to it. Override as you deem fit.- Specified by:
process
in interfaceClaimSource
- Parameters:
claims
-transaction
-- Returns:
- Throws:
UnsupportedScopeException
-
process
public net.sf.json.JSONObject process(net.sf.json.JSONObject claims, javax.servlet.http.HttpServletRequest request, ServiceTransaction transaction) throws UnsupportedScopeException
This also just returns theUserInfo
object passed in. This has some legacy code. If you are writing a custom claim source, you really only need to invokerealProcessing(JSONObject, HttpServletRequest, ServiceTransaction)
at the right time.- Specified by:
process
in interfaceClaimSource
- Parameters:
claims
-request
-transaction
-- Returns:
- Throws:
UnsupportedScopeException
-
getGroupHandler
public GroupHandler getGroupHandler()
-
setGroupHandler
public void setGroupHandler(GroupHandler groupHandler)
-
realProcessing
protected net.sf.json.JSONObject realProcessing(net.sf.json.JSONObject claims, javax.servlet.http.HttpServletRequest request, ServiceTransaction transaction) throws UnsupportedScopeException
This is the actual place to put your code that only processes the claim source. Theprocess(JSONObject, HttpServletRequest, ServiceTransaction)
calls wrap this and invoke the pre/post processor for you. Your code should take whatever metadata is for the user and add it to the claims object.- Parameters:
claims
-request
-transaction
-- Returns:
- Throws:
UnsupportedScopeException
-
setScopes
public void setScopes(Collection<String> scopes)
Description copied from interface:ClaimSource
Set the scopes for this source.- Specified by:
setScopes
in interfaceClaimSource
-
getClaims
public Collection<String> getClaims()
returns a (unique) collection of claims.- Specified by:
getClaims
in interfaceClaimSource
- Returns:
-
isRunAtAuthorization
public boolean isRunAtAuthorization()
This should usually be false. It is true only for those sources that can ONLY run at authorization, such asHTTPHeaderClaimsSource
, where the information is simply not available in later phases.- Specified by:
isRunAtAuthorization
in interfaceClaimSource
- Returns:
-
getPostProcessor
public edu.uiuc.ncsa.security.util.functor.parser.FunctorScript getPostProcessor()
Description copied from interface:ClaimSource
See comment inClaimSource.getPreProcessor()
.- Specified by:
getPostProcessor
in interfaceClaimSource
- Returns:
-
getPreProcessor
public edu.uiuc.ncsa.security.util.functor.parser.FunctorScript getPreProcessor()
Description copied from interface:ClaimSource
This is the preprocessor after it has run. It is not available until execution time since it has to be constructed on the fly from the current state of the claims.- Specified by:
getPreProcessor
in interfaceClaimSource
- Returns:
-
fromQDL
public void fromQDL(edu.uiuc.ncsa.qdl.variables.QDLStem stem)
- Specified by:
fromQDL
in interfaceClaimSource
-
toQDL
public edu.uiuc.ncsa.qdl.variables.QDLStem toQDL()
- Specified by:
toQDL
in interfaceClaimSource
-
-