Class DIService
- 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.api.storage.servlet.OA4MPServlet
-
- org.oa4mp.di.DIService
-
- All Implemented Interfaces:
edu.uiuc.ncsa.security.core.Logable,Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig,org.oa4mp.delegation.common.servlet.TransactionFilter
public class DIService extends OA4MPServlet
The detached/independent (DI) service. This is the authentication case where there is a wholly standalone authentication service. It does authentication then notifies OA4MP via back channel callouts to OA4MP to start and finish flows.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringACTION_PARAMETERstatic StringAPPROVE_USER_CODEstatic StringAPPROVED_PARAMETERstatic StringCHECK_USER_CODEstatic StringDI_PASSWORD_PARAMETERstatic StringDI_USER_PARAMETERstatic StringFINISH_AUTH_CODE_FLOWstatic StringGRANT_PARAMETERstatic StringMYPROXY_USERNAME_PARAMETERprotected DIServiceSerializerserializerstatic StringSTART_AUTH_CODE_FLOWstatic intSTATUS_CREATE_TRANSACTION_FAILEDstatic intSTATUS_EXPIRED_TOKENstatic StringSTATUS_KEYstatic intSTATUS_MALFORMED_SCOPEstatic intSTATUS_MISSING_CLIENT_IDstatic intSTATUS_NO_SCOPESstatic intSTATUS_QDL_ERRORstatic intSTATUS_QDL_RUNTIME_ERRORstatic intSTATUS_SERVICE_UNAVAILABLEstatic intSTATUS_TRANSACTION_NOT_FOUNDstatic intSTATUS_UNAPPROVED_CLIENTstatic intSTATUS_UNKNOWN_CLIENTstatic StringUSER_CODE_PARAMETERstatic StringUSER_NAME_PARAMETER-
Fields inherited from class org.oa4mp.server.api.storage.servlet.OA4MPServlet
caThread, kpt, lastAccessedThread, transactionCleanup
-
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 DIService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapproveUserCode(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)action: userCodeApproved param(s):protected voidcheckUserCode(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Taken from CIL-934 action: checkUserCode param: user_code (required, but can be empty)protected voiddoAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String action)protected voiddoError(String message, int errorCode, javax.servlet.http.HttpServletResponse resp)protected voiddoIt(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected voiddoUserClaims(OA2ServiceTransaction t, javax.servlet.http.HttpServletRequest request, edu.uiuc.ncsa.security.core.util.MetaDebugUtil debugger)This will run the QDL scripts for the client in the auth phase If there are specialized claims for all users, override and do them here, then call super.protected voidfinishAuthCodeFlow(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)protected OA2SEgetOA2SE()Convenience to get the service environment.protected StringgetParam(javax.servlet.http.HttpServletRequest request, String key)Gets a single parameter, throwing the appropriate exception if there are multiples or noneprotected StringgetParam(javax.servlet.http.HttpServletRequest request, String key, boolean nullOK)Gets the parameter for the given key, decoding it as needed.voidinit(javax.servlet.ServletConfig config)protected voidstartAuthCodeFlow(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)This accepts the following parametersprotected voidstartWrite(javax.servlet.http.HttpServletResponse response)Sets up the response with the right encoding and status.protected voidstopWrite(javax.servlet.http.HttpServletResponse response)Stop writing to the response.ServiceTransactionverifyAndGet(IssuerResponse iResponse)protected voidwriteMessage(javax.servlet.http.HttpServletResponse response, Err errResponse)protected voidwriteTransaction(OA2ServiceTransaction oa2ServiceTransaction, int status, javax.servlet.http.HttpServletResponse response)protected voidwriteTransaction(OA2ServiceTransaction oa2ServiceTransaction, Err errResponse, javax.servlet.http.HttpServletResponse response)-
Methods inherited from class org.oa4mp.server.api.storage.servlet.OA4MPServlet
checkAdminClientStatus, checkClientApproval, createDebugger, destroy, getAGI, getATI, getClient, getClient, getClient, getFirstParameters, getFirstParameterValue, getGrantIDFromRequest, getServiceEnvironment, getTransaction, getTransactionByGrantID, getTransactionStore, isEmpty, loadProperties2, newTransaction, postprocess, preprocess, realStoreUpdates, say, shutdownCleanup, storeUpdates
-
Methods inherited from class org.oa4mp.server.api.storage.servlet.EnvServlet
addNotificationListener, loadEnvironment, processStoreCheck, removeNotificationListener
-
Methods inherited from class edu.uiuc.ncsa.security.servlet.AbstractServlet
checkContentType, CONST, debug, doGet, doPing, doPost, 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
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
FINISH_AUTH_CODE_FLOW
public static final String FINISH_AUTH_CODE_FLOW
- See Also:
- Constant Field Values
-
START_AUTH_CODE_FLOW
public static final String START_AUTH_CODE_FLOW
- See Also:
- Constant Field Values
-
STATUS_TRANSACTION_NOT_FOUND
public static final int STATUS_TRANSACTION_NOT_FOUND
- See Also:
- Constant Field Values
-
STATUS_EXPIRED_TOKEN
public static final int STATUS_EXPIRED_TOKEN
- See Also:
- Constant Field Values
-
STATUS_CREATE_TRANSACTION_FAILED
public static final int STATUS_CREATE_TRANSACTION_FAILED
- See Also:
- Constant Field Values
-
STATUS_MISSING_CLIENT_ID
public static final int STATUS_MISSING_CLIENT_ID
- See Also:
- Constant Field Values
-
STATUS_UNKNOWN_CLIENT
public static final int STATUS_UNKNOWN_CLIENT
- See Also:
- Constant Field Values
-
STATUS_UNAPPROVED_CLIENT
public static final int STATUS_UNAPPROVED_CLIENT
- See Also:
- Constant Field Values
-
STATUS_NO_SCOPES
public static final int STATUS_NO_SCOPES
- See Also:
- Constant Field Values
-
STATUS_MALFORMED_SCOPE
public static final int STATUS_MALFORMED_SCOPE
- See Also:
- Constant Field Values
-
STATUS_SERVICE_UNAVAILABLE
public static final int STATUS_SERVICE_UNAVAILABLE
- See Also:
- Constant Field Values
-
STATUS_QDL_ERROR
public static final int STATUS_QDL_ERROR
- See Also:
- Constant Field Values
-
STATUS_QDL_RUNTIME_ERROR
public static final int STATUS_QDL_RUNTIME_ERROR
- See Also:
- Constant Field Values
-
STATUS_KEY
public static final String STATUS_KEY
- See Also:
- Constant Field Values
-
ACTION_PARAMETER
public static final String ACTION_PARAMETER
- See Also:
- Constant Field Values
-
serializer
protected DIServiceSerializer serializer
-
CHECK_USER_CODE
public static final String CHECK_USER_CODE
- See Also:
- Constant Field Values
-
APPROVE_USER_CODE
public static final String APPROVE_USER_CODE
- See Also:
- Constant Field Values
-
GRANT_PARAMETER
public static final String GRANT_PARAMETER
- See Also:
- Constant Field Values
-
USER_CODE_PARAMETER
public static final String USER_CODE_PARAMETER
- See Also:
- Constant Field Values
-
USER_NAME_PARAMETER
public static final String USER_NAME_PARAMETER
- See Also:
- Constant Field Values
-
MYPROXY_USERNAME_PARAMETER
public static final String MYPROXY_USERNAME_PARAMETER
- See Also:
- Constant Field Values
-
APPROVED_PARAMETER
public static final String APPROVED_PARAMETER
- See Also:
- Constant Field Values
-
DI_USER_PARAMETER
public static final String DI_USER_PARAMETER
- See Also:
- Constant Field Values
-
DI_PASSWORD_PARAMETER
public static final String DI_PASSWORD_PARAMETER
- See Also:
- Constant Field Values
-
-
Method Detail
-
doIt
protected void doIt(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Throwable- Specified by:
doItin classedu.uiuc.ncsa.security.servlet.AbstractServlet- Throws:
Throwable
-
doAction
protected void doAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String action) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
getParam
protected String getParam(javax.servlet.http.HttpServletRequest request, String key) throws UnsupportedEncodingException
Gets a single parameter, throwing the appropriate exception if there are multiples or none- Parameters:
key-- Returns:
- Throws:
UnsupportedEncodingException
-
getParam
protected String getParam(javax.servlet.http.HttpServletRequest request, String key, boolean nullOK) throws UnsupportedEncodingException
Gets the parameter for the given key, decoding it as needed.- Parameters:
request-key-nullOK-- Returns:
- Throws:
UnsupportedEncodingException
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException- Specified by:
initin interfacejavax.servlet.Servlet- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException
-
checkUserCode
protected void checkUserCode(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOExceptionTaken from CIL-934 action: checkUserCode param: user_code (required, but can be empty)Purpose: This is an "internal" diService method used by the PHP web front end to (1) verify that a user_code input by the user is valid and (2) return the client_id associated with this transaction in order to display client information to the end user. The user_code parameter is required, but it can be empty. The user_code parameter can contain extra "user-friendly" characters such as dash '-', space ' ', underscore '_', etc. These extra characters will be stripped out/ignored by the diService. The user_code can contain lower-case and/or upper-case characters which will be transformed to upper-case characters by the diService. Returns: HTTP 200 response, body is basic text, one line per returned value:
status=INTEGER 0 = Success 1048569 = missing parameter 65537 = transaction not found 65539 = expired user_code (token) client_id=The OIDC client_id matching the user_code user_code=The original user_code to be displayed to the end user. The purpose of this is that the returned user_code should visually match the one that was returned to the device so the user can easily verify a match (i.e., ignore any transformations done by the user when inputting the user_code). scope=A (possibly empty/absent) space-separated list of scopes that were requested by the client. This is needed when displaying the list of attributes to be delegated since the scopes requested by the device client may differ from those registered.
- Parameters:
request-response-- Throws:
IOException
-
approveUserCode
protected void approveUserCode(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOExceptionaction: userCodeApproved param(s):user_code (required) approved (optional; defaults to 1; 1=approved; 0=denied)
Purpose: This is an "internal" diService method used by the PHP web front end to let the diService know that the user has logged on to their chosen Identity Provider and approved the transaction OR that the user has clicked a "Cancel" button and denied the transaction. If the user has approved the transaction (approved=1 or 'approved' is absent, the default), the OA4MP server can proceed with the rest of the Device authz grant flow. If the user has denied the transaction (approved=0), the OA4MP server should inform the device that the user has canceled the transaction. Returns: HTTP 200 response, body is basic text, one line per returned value:
status=INTEGER 0 = Success 1048569 = missing parameter 65537 = transaction not found
- Throws:
IOException
-
startAuthCodeFlow
protected void startAuthCodeFlow(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOExceptionThis accepts the following parametersclient_id response_type redirect_uri scope state code_challenge (RFC 7636) code_challenge_method " "
and the response- Parameters:
req-resp-- Throws:
IOException
-
finishAuthCodeFlow
protected void finishAuthCodeFlow(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException- Throws:
IOException
-
doUserClaims
protected void doUserClaims(OA2ServiceTransaction t, javax.servlet.http.HttpServletRequest request, edu.uiuc.ncsa.security.core.util.MetaDebugUtil debugger) throws Throwable
This will run the QDL scripts for the client in the auth phase If there are specialized claims for all users, override and do them here, then call super. In that case, it should get and setOA2ServiceTransaction.getUserMetaData(). This call will save the transaction. .- Parameters:
t-request-debugger-- Throws:
Throwable
-
writeTransaction
protected void writeTransaction(OA2ServiceTransaction oa2ServiceTransaction, int status, javax.servlet.http.HttpServletResponse response) throws IOException
- Throws:
IOException
-
writeTransaction
protected void writeTransaction(OA2ServiceTransaction oa2ServiceTransaction, Err errResponse, javax.servlet.http.HttpServletResponse response) throws IOException
- Throws:
IOException
-
doError
protected void doError(String message, int errorCode, javax.servlet.http.HttpServletResponse resp) throws IOException
- Throws:
IOException
-
startWrite
protected void startWrite(javax.servlet.http.HttpServletResponse response)
Sets up the response with the right encoding and status.- Parameters:
response-
-
stopWrite
protected void stopWrite(javax.servlet.http.HttpServletResponse response) throws IOExceptionStop writing to the response. This flushes and closes the writer. No writes should work after this.- Parameters:
response-- Throws:
IOException
-
writeMessage
protected void writeMessage(javax.servlet.http.HttpServletResponse response, Err errResponse) throws IOException- Throws:
IOException
-
getOA2SE
protected OA2SE getOA2SE()
Convenience to get the service environment.- Returns:
-
verifyAndGet
public ServiceTransaction verifyAndGet(IssuerResponse iResponse) throws IOException
- Specified by:
verifyAndGetin classOA4MPServlet- Throws:
IOException
-
-