All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.uiuc.ncsa.myproxy.oa4mp.server.servlet.AbstractInitServlet Maven / Gradle / Ivy

The newest version!
package edu.uiuc.ncsa.myproxy.oa4mp.server.servlet;

import edu.uiuc.ncsa.oa4mp.delegation.server.ServiceTransaction;
import edu.uiuc.ncsa.oa4mp.delegation.server.UnapprovedClientException;
import edu.uiuc.ncsa.oa4mp.delegation.server.request.AGRequest;
import edu.uiuc.ncsa.oa4mp.delegation.server.request.AGResponse;
import edu.uiuc.ncsa.oa4mp.delegation.common.servlet.TransactionState;
import edu.uiuc.ncsa.oa4mp.delegation.common.storage.clients.Client;
import edu.uiuc.ncsa.security.storage.GenericStoreUtils;
import edu.uiuc.ncsa.security.storage.XMLMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 

Created by Jeff Gaynor
* on 9/24/13 at 3:56 PM */ public abstract class AbstractInitServlet extends MyProxyDelegationServlet{ /** * Default is to just call {@link #doDelegation(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)} * and return. You may over-ride this to do any pre or post -processing you require. * * @param httpServletRequest * @param httpServletResponse * @throws Throwable */ @Override protected void doIt(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Throwable { doDelegation(httpServletRequest, httpServletResponse); } /** * Actual work call. This parses and returns the passed in parameters. * * @param req * @param resp * @return * @throws java.io.IOException * @throws javax.servlet.ServletException */ protected ServiceTransaction doDelegation(HttpServletRequest req, HttpServletResponse resp) throws Throwable { Client client = getClient(req); ServiceTransaction transaction = newTransaction(); transaction.setClient(client); try { String cid = "client=" + client.getIdentifier(); info("2.a. Starting a new cert request: " + cid); checkClientApproval(client); AGResponse agResponse = (AGResponse) getAGI().process(new AGRequest(req, transaction)); agResponse.setServiceTransaction(transaction); transaction = verifyAndGet(agResponse); getTransactionStore().save(transaction); info("Saved new transaction with id=" + transaction.getIdentifierString()); Map params = agResponse.getParameters(); XMLMap backup = GenericStoreUtils.toXML(getTransactionStore(), transaction); preprocess(new TransactionState(req, resp, params, transaction, backup)); debug("saved transaction for " + cid + ", trans id=" + transaction.getIdentifierString()); agResponse.write(resp); info("2.b finished initial request for token =\"" + transaction.getIdentifierString() + "\"."); postprocess(new IssuerTransactionState(req, resp, params, transaction, backup, agResponse)); return transaction; } catch (Throwable t) { if (t instanceof UnapprovedClientException ) { warn("Unapproved client: " + client.getIdentifierString()); } throw t; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy