use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class NewCAStoreTest method testApprovalCycle.
public void testApprovalCycle(ClientStore clientStore, ClientApprovalStore caStore) throws Exception {
assert !caStore.isApproved(BasicIdentifier.newID("foo:bar:baz://" + getRandomString(32)));
Client client = (Client) clientStore.create();
Identifier identifier = client.getIdentifier();
client.setHomeUri("urn:test:/home/uri/" + getRandomString(32));
client.setSecret(getRandomString(256));
client.setName("Test client" + getRandomString(32));
client.setEmail(getRandomString(32) + "@email.foo.edu");
client.setErrorUri("uri:test:/uh/oh/uri/" + getRandomString(32));
clientStore.save(client);
ClientApproval ca = (ClientApproval) caStore.create();
ca.setApprover("test-approver");
ca.setApproved(false);
ca.setApprovalTimestamp(new Date());
ca.setIdentifier(identifier);
caStore.save(ca);
assert !((ClientApproval) caStore.get(client.getIdentifier())).isApproved();
assert !caStore.isApproved(identifier);
ca.setApproved(true);
caStore.save(ca);
// Regression test to be sure that identifiers are never changed.
assert identifier.equals(ca.getIdentifier());
assert identifier.equals(client.getIdentifier());
assert ((ClientApproval) caStore.get(client.getIdentifier())).isApproved();
assert caStore.isApproved(identifier);
caStore.remove(client.getIdentifier());
clientStore.remove(client.getIdentifier());
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class ClientStoreCommands method longFormat.
@Override
protected void longFormat(Identifiable identifiable) {
super.longFormat(identifiable);
Client client = (Client) identifiable;
sayi("home uri=" + client.getHomeUri());
sayi("error uri=" + client.getErrorUri());
sayi("limited proxies? " + client.isProxyLimited());
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class ClientStoreUtil method create.
@Override
public void create() throws Exception {
boolean tryAgain = true;
Identifier id = null;
Client c = null;
while (tryAgain) {
say2("enter the id of the object you want to create or return for a random one");
String inLine = readline();
if (!(inLine == null || inLine.length() == 0)) {
try {
id = BasicIdentifier.newID(inLine);
} catch (Throwable t) {
say2("That is not a valid uri. Try again (y/n)?");
inLine = readline().trim().toLowerCase();
tryAgain = inLine.equals("y");
}
} else {
tryAgain = false;
}
}
// end input loop.
c = (Client) getSE().getClientStore().create();
if (id == null) {
// use random one
} else {
if (getSE().getClientStore().containsKey(id)) {
// something should happen since this exists.
}
c.setIdentifier(id);
}
// now invoke updater on the new item.
update(c);
getSE().getClientStore().save(c);
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class AbstractRegistrationServlet method addNewClient.
protected Client addNewClient(HttpServletRequest request, HttpServletResponse response) throws Throwable {
// Assumption is that the request is in good order and we just have to pull stuff off it.
Client client = getServiceEnvironment().getClientStore().create();
info("creating entry for client=" + client.getIdentifierString());
// Fill in as much info as we can before parsing public key.
// We always store exactly what was given to us, though later we html escape it to
// prevent against HTML injection attacks (fixes bug OAUTH-87).
client.setName(getRequiredParam(request, CLIENT_NAME, client));
client.setHomeUri(getRequiredParam(request, CLIENT_HOME_URL, client));
String x = getRequiredParam(request, CLIENT_EMAIL, client);
java.util.regex.Pattern p = java.util.regex.Pattern.compile(emailPattern);
java.util.regex.Matcher m = p.matcher(x);
if (!m.matches()) {
throw new ClientRegistrationRetryException("The email address \"" + x + "\" is not valid.", null, client);
}
client.setEmail(x);
client.setProxyLimited(getBooleanParam(request, CLIENT_PROXY_LIMITED));
getServiceEnvironment().getClientStore().save(client);
info("Adding approval record for client=" + client.getIdentifierString());
ClientApproval clientApproval = new ClientApproval(client.getIdentifier());
clientApproval.setApproved(false);
info("done with client registration, client=" + client.getIdentifierString());
// Failure to do so will turn off the ability to email new client registrations!
return client;
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class AutoRegistrationServlet method addNewClient.
@Override
protected Client addNewClient(HttpServletRequest request, HttpServletResponse response) throws Throwable {
Client client = super.addNewClient(request, response);
if (client != null) {
approveClient(client.getIdentifier(), "auto-approver");
}
fireNewClientEvent(client);
return client;
}
Aggregations