Class OIDCCMServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- edu.uiuc.ncsa.security.servlet.AbstractServlet
-
- org.oa4mp.server.api.storage.servlet.EnvServlet
-
- org.oa4mp.server.loader.oauth2.cm.oidc_cm.OIDCCMServlet
-
- All Implemented Interfaces:
edu.uiuc.ncsa.security.core.Logable,Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
public class OIDCCMServlet extends EnvServlet
Note that in all of these calls, the assumption is that an admin client has been requested and approved out of band. The identifier and secret of that are used to make the bearer token that allows access to the calls in this API. This implements both RFC 7591 and part of RFC 7592. Mostly we do not allow the setting of client secrets via tha API and since we do not store them (only a hash of them) we cannot return them. If a secret is lost, the only option is to register a new client.
Nota Bene: RFC 7592 is not intended to become a specification since there is too much variance in how this can operate.Created by Jeff Gaynor
on 11/28/18 at 10:04 AM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPI_VERSION_5_4static StringAPI_VERSION_5_5static StringAPI_VERSION_KEYstatic StringAPI_VERSION_LATESTstatic StringAPI_VERSION_NONEThey sent nothing explicit.static StringAPPROVAL_STATUSstatic StringERSATZ_CLIENT_PROVISIONERSstatic StringFORWARD_REQUEST_SCOPES_TO_PROXYstatic StringIS_SERVICE_CLIENTstatic StringPROXY_CLAIMS_LISTstatic StringPROXY_REQUEST_SCOPESstatic StringQUERY_PARAMETERprotected SecureRandomsecureRandomstatic StringSERVICE_CLIENT_USERS-
Fields inherited from class org.oa4mp.server.api.storage.servlet.EnvServlet
ERROR_NOTIFICATION_BODY_KEY, ERROR_NOTIFICATION_SUBJECT_KEY, notificationListeners, storeUpdatesDone
-
-
Constructor Summary
Constructors Constructor Description OIDCCMServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanareAllGrantsSupported(net.sf.json.JSONArray proposedGrants, String[] supportedGrants)protected voidcheckAdminPermission(AdminClient adminClient, OA2Client client)Checks that this client exists on the system and that if it exists, the admin client actually owns it.protected booleancheckJAEntry(net.sf.json.JSONArray jsonArray, String entry)JSONArray does not check its contains sanely against strings at times.protected HashMap<String,String>defaultReplacements(javax.servlet.http.HttpServletRequest req, AdminClient adminClient, OA2Client client)protected voiddoDelete(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Remove the given client in toto.voiddoGet(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)Return information about the client.protected voiddoIt(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)protected voiddoIt2(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)The workhorse method for POST.voiddoPost(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)protected voiddoPut(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Update a client.protected voidfireMessage(boolean isAnonymous, OA2SE oa2SE, HashMap<String,String> replacements)protected StringformatIdentifiable(edu.uiuc.ncsa.security.core.Store store, edu.uiuc.ncsa.security.core.Identifiable identifiable)protected AdminClientgetAndCheckAdminClient(javax.servlet.http.HttpServletRequest request)Pulls the id and secret from the header then verifies the secret and if it passes, returns the client.protected OA2ClientgetAndCheckOA2Client(javax.servlet.http.HttpServletRequest request)protected OA2ClientgetClient(javax.servlet.http.HttpServletRequest req)Get the client from the request.static StringgetDefaultAPIVersion()edu.uiuc.ncsa.security.util.jwk.JWKUtil2getJwkUtil()protected OA2SEgetOA2SE()protected net.sf.json.JSONgetPayload(javax.servlet.http.HttpServletRequest httpServletRequest, edu.uiuc.ncsa.security.core.util.MetaDebugUtil adminDebugger)PermissionServergetPermissionServer()We want to be able to manage the permissions associated with a standard client and an admin client.protected StringgetVersion(CMConfig cmConfig, javax.servlet.http.HttpServletRequest req)protected voidhandleGrants(OA2Client client, net.sf.json.JSONObject jsonRequest, OA2ClientKeys keys)protected voidhandleResponseTypes(OA2Client client, net.sf.json.JSONObject jsonRequest, OA2ClientKeys keys)TL;DR: we support the grant types for the authorization_code flow so only code and id_token.protected longlifetimeFromParameter(Object raw)So clients can send strings of values with units, e.g. "1 month".protected longlifetimeFromSec(long lifetime)protected longlifetimeToSec(long lifetime)Used in serializing the client to JSON. lifetime that are positive are divided by 1000 to convert from milliseconds to seconds.
If they are non-positive, however, they are returned as is since negative values are overloaded.protected OA2ClientprocessRegistrationRequest(net.sf.json.JSONObject jsonRequest, AdminClient adminClient, boolean isAnonymous, OA2Client client, String version)static voidsetDefaultAPIVersion(String defaultAPIVersion)voidsetJwkUtil(edu.uiuc.ncsa.security.util.jwk.JWKUtil2 jwkUtil)voidstoreUpdates()protected net.sf.json.JSONArraytoJA(net.sf.json.JSONObject obj, String key)Some attribute scan come over the wire as either arrays of string or as blank delimited strings, e.g. scopes and grant types.protected net.sf.json.JSONArraytoJSONArray(net.sf.json.JSONObject jsonRequest, String key, OA2Client client)protected net.sf.json.JSONObjecttoJSONObject(OA2Client client, String version, boolean isGet)Take a client and turn it in to a response object.protected net.sf.json.JSONObjecttoJSONObject5_4(OA2Client client, boolean isGet)protected net.sf.json.JSONObjecttoJSONObject5_5(OA2Client client, boolean isGet)protected OA2ClientupdateClient(OA2Client client, AdminClient adminClient, boolean isAnonymous, net.sf.json.JSONObject jsonRequest, boolean newClient, String version)-
Methods inherited from class org.oa4mp.server.api.storage.servlet.EnvServlet
addNotificationListener, loadEnvironment, loadProperties2, processStoreCheck, removeNotificationListener
-
Methods inherited from class edu.uiuc.ncsa.security.servlet.AbstractServlet
checkContentType, CONST, debug, doPing, error, error, getConfigurationLoader, getEnvironment, getExceptionHandler, getInitialization, getMyLogger, getRequestIPAddress, handleException, info, init, isDebugOn, logOK, logOK, printAllParameters, printAllParameters, resetState, setConfigurationLoader, setDebugOn, setEnvironment, setExceptionHandler, setInitialization, warn
-
Methods inherited from class javax.servlet.http.HttpServlet
doHead, doOptions, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
PROXY_CLAIMS_LIST
public static final String PROXY_CLAIMS_LIST
- See Also:
- Constant Field Values
-
FORWARD_REQUEST_SCOPES_TO_PROXY
public static final String FORWARD_REQUEST_SCOPES_TO_PROXY
- See Also:
- Constant Field Values
-
PROXY_REQUEST_SCOPES
public static final String PROXY_REQUEST_SCOPES
- See Also:
- Constant Field Values
-
IS_SERVICE_CLIENT
public static final String IS_SERVICE_CLIENT
- See Also:
- Constant Field Values
-
SERVICE_CLIENT_USERS
public static final String SERVICE_CLIENT_USERS
- See Also:
- Constant Field Values
-
ERSATZ_CLIENT_PROVISIONERS
public static final String ERSATZ_CLIENT_PROVISIONERS
- See Also:
- Constant Field Values
-
APPROVAL_STATUS
public static final String APPROVAL_STATUS
- See Also:
- Constant Field Values
-
API_VERSION_LATEST
public static final String API_VERSION_LATEST
- See Also:
- Constant Field Values
-
API_VERSION_NONE
public static final String API_VERSION_NONE
They sent nothing explicit.- See Also:
- Constant Field Values
-
API_VERSION_5_4
public static final String API_VERSION_5_4
- See Also:
- Constant Field Values
-
API_VERSION_5_5
public static final String API_VERSION_5_5
- See Also:
- Constant Field Values
-
API_VERSION_KEY
public static final String API_VERSION_KEY
- See Also:
- Constant Field Values
-
QUERY_PARAMETER
public static final String QUERY_PARAMETER
- See Also:
- Constant Field Values
-
secureRandom
protected SecureRandom secureRandom
-
-
Method Detail
-
storeUpdates
public void storeUpdates() throws IOException, SQLException- Specified by:
storeUpdatesin classEnvServlet- Throws:
IOExceptionSQLException
-
getOA2SE
protected OA2SE getOA2SE()
-
doGet
public void doGet(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws javax.servlet.ServletException, IOExceptionReturn information about the client. Note that we do not return the client secret in this call, since among other reasons, we do not have it.- Overrides:
doGetin classedu.uiuc.ncsa.security.servlet.AbstractServlet- Parameters:
httpServletRequest-httpServletResponse-- Throws:
javax.servlet.ServletExceptionIOException
-
formatIdentifiable
protected String formatIdentifiable(edu.uiuc.ncsa.security.core.Store store, edu.uiuc.ncsa.security.core.Identifiable identifiable)
-
defaultReplacements
protected HashMap<String,String> defaultReplacements(javax.servlet.http.HttpServletRequest req, AdminClient adminClient, OA2Client client)
-
toJSONObject
protected net.sf.json.JSONObject toJSONObject(OA2Client client, String version, boolean isGet)
Take a client and turn it in to a response object. This is used by both GET do PUT (which is supposed to return the same output as GET when done with its updates)- Parameters:
client-- Returns:
-
toJSONObject5_5
protected net.sf.json.JSONObject toJSONObject5_5(OA2Client client, boolean isGet)
-
toJSONObject5_4
protected net.sf.json.JSONObject toJSONObject5_4(OA2Client client, boolean isGet)
-
getDefaultAPIVersion
public static String getDefaultAPIVersion()
-
setDefaultAPIVersion
public static void setDefaultAPIVersion(String defaultAPIVersion)
-
lifetimeToSec
protected long lifetimeToSec(long lifetime)
Used in serializing the client to JSON. lifetime that are positive are divided by 1000 to convert from milliseconds to seconds.
If they are non-positive, however, they are returned as is since negative values are overloaded.- Parameters:
lifetime-- Returns:
-
lifetimeFromSec
protected long lifetimeFromSec(long lifetime)
-
doDelete
protected void doDelete(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOExceptionRemove the given client in toto.- Overrides:
doDeletein classjavax.servlet.http.HttpServlet- Parameters:
req-resp-- Throws:
javax.servlet.ServletExceptionIOException
-
checkAdminPermission
protected void checkAdminPermission(AdminClient adminClient, OA2Client client)
Checks that this client exists on the system and that if it exists, the admin client actually owns it.- Parameters:
adminClient-client-
-
getVersion
protected String getVersion(CMConfig cmConfig, javax.servlet.http.HttpServletRequest req)
-
doPut
protected void doPut(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOExceptionUpdate a client. Note that as per the specification, all values that are sent over-write existing values and omitted values are taken to mean the stored value is unset.- Overrides:
doPutin classjavax.servlet.http.HttpServlet- Parameters:
req-resp-- Throws:
javax.servlet.ServletExceptionIOException
-
doPost
public void doPost(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws javax.servlet.ServletException, IOException- Overrides:
doPostin classedu.uiuc.ncsa.security.servlet.AbstractServlet- Throws:
javax.servlet.ServletExceptionIOException
-
getPermissionServer
public PermissionServer getPermissionServer()
We want to be able to manage the permissions associated with a standard client and an admin client.- Returns:
-
getAndCheckAdminClient
protected AdminClient getAndCheckAdminClient(javax.servlet.http.HttpServletRequest request) throws Throwable
Pulls the id and secret from the header then verifies the secret and if it passes, returns the client.- Parameters:
request-- Returns:
- Throws:
Throwable
-
getAndCheckOA2Client
protected OA2Client getAndCheckOA2Client(javax.servlet.http.HttpServletRequest request) throws Throwable
- Throws:
Throwable
-
doIt
protected void doIt(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws Throwable- Specified by:
doItin classedu.uiuc.ncsa.security.servlet.AbstractServlet- Throws:
Throwable
-
doIt2
protected void doIt2(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws ThrowableThe workhorse method for POST.- Parameters:
httpServletRequest-httpServletResponse-- Throws:
Throwable
-
getPayload
protected net.sf.json.JSON getPayload(javax.servlet.http.HttpServletRequest httpServletRequest, edu.uiuc.ncsa.security.core.util.MetaDebugUtil adminDebugger) throws IOException- Throws:
IOException
-
getClient
protected OA2Client getClient(javax.servlet.http.HttpServletRequest req)
Get the client from the request. Note that this may return null if no such client exists and it is up to the calling method to decide if this is ok.- Parameters:
req-- Returns:
-
updateClient
protected OA2Client updateClient(OA2Client client, AdminClient adminClient, boolean isAnonymous, net.sf.json.JSONObject jsonRequest, boolean newClient, String version)
-
lifetimeFromParameter
protected long lifetimeFromParameter(Object raw)
So clients can send strings of values with units, e.g. "1 month". OA4MP supports this for its own values.- Parameters:
raw-- Returns:
-
toJSONArray
protected net.sf.json.JSONArray toJSONArray(net.sf.json.JSONObject jsonRequest, String key, OA2Client client)
-
handleResponseTypes
protected void handleResponseTypes(OA2Client client, net.sf.json.JSONObject jsonRequest, OA2ClientKeys keys)
TL;DR: we support the grant types for the authorization_code flow so only code and id_token. We explicitly reject every other response_type at this point, in particular, we reject the value of "token" which is only for the implicit flow.- Parameters:
client-jsonRequest-keys-
-
checkJAEntry
protected boolean checkJAEntry(net.sf.json.JSONArray jsonArray, String entry)JSONArray does not check its contains sanely against strings at times.- Parameters:
jsonArray-entry-- Returns:
-
areAllGrantsSupported
protected boolean areAllGrantsSupported(net.sf.json.JSONArray proposedGrants, String[] supportedGrants)
-
handleGrants
protected void handleGrants(OA2Client client, net.sf.json.JSONObject jsonRequest, OA2ClientKeys keys)
-
toJA
protected net.sf.json.JSONArray toJA(net.sf.json.JSONObject obj, String key)Some attribute scan come over the wire as either arrays of string or as blank delimited strings, e.g. scopes and grant types. Just figure it out and hand back the array. Note this will remove duplicates.- Parameters:
obj-key-- Returns:
-
processRegistrationRequest
protected OA2Client processRegistrationRequest(net.sf.json.JSONObject jsonRequest, AdminClient adminClient, boolean isAnonymous, OA2Client client, String version)
-
fireMessage
protected void fireMessage(boolean isAnonymous, OA2SE oa2SE, HashMap<String,String> replacements)
-
getJwkUtil
public edu.uiuc.ncsa.security.util.jwk.JWKUtil2 getJwkUtil()
-
setJwkUtil
public void setJwkUtil(edu.uiuc.ncsa.security.util.jwk.JWKUtil2 jwkUtil)
-
-