use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class AbstractInitServlet method doDelegation.
/**
* 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 void doDelegation(HttpServletRequest req, HttpServletResponse resp) throws Throwable {
Client client = getClient(req);
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, client));
agResponse.setClient(client);
ServiceTransaction transaction = verifyAndGet(agResponse);
transaction.setClient(client);
getTransactionStore().save(transaction);
info("Saved new transaction with id=" + transaction.getIdentifierString());
Map<String, String> params = agResponse.getParameters();
preprocess(new TransactionState(req, resp, params, transaction));
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, agResponse));
} catch (Throwable t) {
if (t instanceof UnapprovedClientException) {
warn("Unapproved client: " + client.getIdentifierString());
}
throw t;
}
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class AbstractRegistrationServlet method doIt.
@Override
protected void doIt(HttpServletRequest request, HttpServletResponse response) throws Throwable {
if (!request.isSecure()) {
// Tomcat docs say to explicitly check here for the right protocol if it is truly required.
throw new ServletException("Unsupported protocol");
}
int state = getState(request);
// Addresses
if (state == INITIAL_STATE) {
if (getServiceEnvironment().getMaxAllowedNewClientRequests() <= getServiceEnvironment().getClientApprovalStore().getPendingCount()) {
// throw new TooManyRequestsException("Error: Max number of new client requests reached. Request rejected.");
log("Too many client approvals pending. Max allowed unapproved count is " + getServiceEnvironment().getMaxAllowedNewClientRequests());
// Fixes CIL-414, CIL-426 (send email notification), CIL-427
getServiceEnvironment().getMailUtil().sendMessage("Too many pending approvals", request.getServerName() + " has too many pending client approval requests outstanding. " + "The server is configured for a limit of " + getServiceEnvironment().getMaxAllowedNewClientRequests() + " and" + " there are " + getServiceEnvironment().getClientApprovalStore().getPendingCount() + " pending approvals in the store.", null);
JSPUtil.fwd(request, response, "/tooManyClientRequests.jsp");
// Fixes OAUTH-90 bug.
return;
}
}
PresentationState pState = new PresentationState(state, request, response);
try {
prepare(pState);
if (state == REQUEST_STATE) {
Client client = addNewClient(request, response);
// Fix for OAUTH-157 bug. Always save any updates to the client
getServiceEnvironment().getClientStore().save(client);
pState = new ClientState(state, request, response, client);
}
present(pState);
} catch (ClientRegistrationRetryException r) {
getServiceEnvironment().getClientStore().remove(r.getClient().getIdentifier());
setRetryParameters(request, r);
if ((request.getAttribute(getValueTag(CLIENT_PROXY_LIMITED)) != null) && request.getAttribute(getValueTag(CLIENT_PROXY_LIMITED)).equals("on")) {
// so this is checked
request.setAttribute(getValueTag(CLIENT_PROXY_LIMITED), "checked");
} else {
// so this is unchecked
request.removeAttribute(getValueTag(CLIENT_PROXY_LIMITED));
}
request.setAttribute(CLIENT_NAME, CLIENT_NAME);
// Nest commands reset the state on the form so the contents are processed.
request.setAttribute(CLIENT_ACTION_KEY, CLIENT_ACTION_KEY);
request.setAttribute(CLIENT_ACTION_REQUEST_VALUE, CLIENT_ACTION_REQUEST_VALUE);
request.setAttribute("actionToTake", request.getContextPath() + "/register");
request.setAttribute("retryMessage", r.getMessage());
JSPUtil.fwd(request, response, INIT_PAGE);
} catch (Throwable t) {
if (ServletDebugUtil.isEnabled()) {
t.printStackTrace();
}
warn("Error registering a new client:" + t.getMessage());
handleError(pState, t);
}
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class ClientStoreCommands method extraUpdates.
@Override
public void extraUpdates(Identifiable identifiable) {
Client client = (Client) identifiable;
client.setErrorUri(getInput("enter error uri", client.getErrorUri()));
client.setHomeUri(getInput("enter home uri", client.getHomeUri()));
client.setProxyLimited(isOk(getInput("does this client require limited proxies?", client.isProxyLimited() ? "y" : "n")));
getPublicKeyFile((Client) identifiable);
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class ClientStoreCommands method update.
@Override
public boolean update(Identifiable identifiable) {
Client client = (Client) identifiable;
String newIdentifier = null;
info("Starting client update for id = " + client.getIdentifierString());
say("Update the values. A return accepts the existing or default value in []'s");
newIdentifier = getInput("enter the identifier", client.getIdentifierString());
boolean removeCurrentClient = false;
Identifier oldID = client.getIdentifier();
// no clean way to do this.
client.setName(getInput("enter the name", client.getName()));
client.setEmail(getInput("enter email", client.getEmail()));
client.setErrorUri(getInput("enter error uri", client.getErrorUri()));
client.setHomeUri(getInput("enter home uri", client.getHomeUri()));
client.setProxyLimited(isOk(getInput("does this client require limited proxies?", client.isProxyLimited() ? "y" : "n")));
// set file not found message.
extraUpdates(client);
sayi("here is the complete client:");
longFormat(client);
if (!newIdentifier.equals(client.getIdentifierString())) {
sayi2(" remove client with id=\"" + client.getIdentifier() + "\" [y/n]? ");
removeCurrentClient = isOk(readline());
client.setIdentifier(BasicIdentifier.newID(newIdentifier));
}
sayi2("save [y/n]?");
if (isOk(readline())) {
// getStore().save(client);
if (removeCurrentClient) {
info("removing client with id = " + oldID);
getStore().remove(client.getIdentifier());
sayi("client with id " + oldID + " removed. Be sure to save any changes.");
}
sayi("client updated.");
info("Client with id " + client.getIdentifierString() + " saving...");
return true;
}
sayi("client not updated, losing changes...");
info("User terminated updates for client with id " + client.getIdentifierString());
return false;
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class ClientLoader method createInstance.
@Override
public T createInstance() {
Provider<TokenForge> tokenForgeProvider = new Provider<TokenForge>() {
@Override
public TokenForge get() {
return new OAuthTokenForge(getId());
}
};
Provider<Client> clientProvider = new Provider<Client>() {
@Override
public Client get() {
OAClient c = new OAClient(BasicIdentifier.newID(getId()));
c.setSignatureMethod(OAuthConstants.RSA_SHA1);
c.setCreationTS(new Date());
return c;
}
};
// sets constants specific to this protocol.
HashMap<String, String> constants = new HashMap<String, String>();
constants.put(CALLBACK_URI_KEY, OAuthConstants.OAUTH_CALLBACK);
constants.put(ClientEnvironment.FORM_ENCODING, "UTF-8");
constants.put(ClientEnvironment.TOKEN, OAuth.OAUTH_TOKEN);
constants.put(ClientEnvironment.VERIFIER, OAuth.OAUTH_VERIFIER);
return createInstance(tokenForgeProvider, clientProvider, constants);
}
Aggregations