Search in sources :

Example 1 with NoUsableMyProxyServerFoundException

use of edu.uiuc.ncsa.myproxy.NoUsableMyProxyServerFoundException in project OA4MP by ncsa.

the class AbstractAuthorizationServlet method doIt.

@Override
protected void doIt(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    info("*** STARTING request");
    // String ag = request.getParameter(CONST(TOKEN_KEY));
    String ag = getParam(request, CONST(TOKEN_KEY));
    ServiceTransaction trans = null;
    if (ag == null) {
        throw new GeneralException("Error: Invalid request -- no token. Request rejected.");
    }
    trans = getAndCheckTransaction(ag);
    AuthorizedState pState = new AuthorizedState(getState(request), request, response, trans);
    prepare(pState);
    preprocess(new TransactionState(request, response, null, trans));
    switch(pState.getState()) {
        case AUTHORIZATION_ACTION_OK:
            // As per the spec, if the code gets to here then authentication worked.
            trans.setAuthGrantValid(true);
            getTransactionStore().save(trans);
            // get the cert and store it. Then forward user.
            try {
                createRedirect(request, response, trans);
                // at this point.
                return;
            } catch (ConnectionException ce) {
                ce.printStackTrace();
                request.setAttribute(RETRY_MESSAGE, getServiceEnvironment().getMessages().get(RETRY_MESSAGE));
                pState.setState(AUTHORIZATION_ACTION_START);
                prepare(pState);
            } catch (GeneralSecurityException | NoUsableMyProxyServerFoundException t) {
                // CIL-173 fix: process NoUsableMPSFound.
                info("Prompting user to retry");
                request.setAttribute(RETRY_MESSAGE, getServiceEnvironment().getMessages().get(RETRY_MESSAGE));
                pState.setState(AUTHORIZATION_ACTION_START);
                prepare(pState);
            }
            break;
        case AUTHORIZATION_ACTION_START:
            // no processing needed for initial request.
            break;
        default:
    }
    present(pState);
}
Also used : TransactionState(edu.uiuc.ncsa.security.delegation.servlet.TransactionState) NoUsableMyProxyServerFoundException(edu.uiuc.ncsa.myproxy.NoUsableMyProxyServerFoundException) GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) ServiceTransaction(edu.uiuc.ncsa.security.delegation.server.ServiceTransaction) GeneralSecurityException(java.security.GeneralSecurityException) ConnectionException(edu.uiuc.ncsa.security.core.exceptions.ConnectionException)

Aggregations

NoUsableMyProxyServerFoundException (edu.uiuc.ncsa.myproxy.NoUsableMyProxyServerFoundException)1 ConnectionException (edu.uiuc.ncsa.security.core.exceptions.ConnectionException)1 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)1 ServiceTransaction (edu.uiuc.ncsa.security.delegation.server.ServiceTransaction)1 TransactionState (edu.uiuc.ncsa.security.delegation.servlet.TransactionState)1 GeneralSecurityException (java.security.GeneralSecurityException)1