use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class ClientStoreTest method testBasic.
@Test
public void testBasic() throws Exception {
Client client = getClientStore().create();
System.out.println("New client ID = " + client.getIdentifier());
client.setHomeUri("urn:test:/home/uri");
client.setSecret(getRandomString(256));
client.setName("Test delegation client");
client.setEmail("test@email.foo.edu");
client.setErrorUri("uri:test:/uh/oh/uri");
client.setProxyLimited(true);
getClientStore().save(client);
Client client2 = getClientStore().get(client.getIdentifier());
assert client.equals(client2);
getClientStore().remove(client.getIdentifier());
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class NewCAStoreTest method testApprovalStore.
public void testApprovalStore(ClientStore clientStore, ClientApprovalStore caStore) throws Exception {
// put one in, get it back, make sure it matches.
Client client = (Client) clientStore.create();
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(true);
ca.setApprovalTimestamp(new Date());
ca.setIdentifier(client.getIdentifier());
caStore.save(ca);
ClientApproval ca1 = (ClientApproval) caStore.get(ca.getIdentifier());
assert ca.equals(ca1);
caStore.remove(ca.getIdentifier());
clientStore.remove(client);
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class MyProxyDelegationServlet method getClient.
public Client getClient(Identifier identifier) {
if (identifier == null) {
throw new UnknownClientException("no client id");
}
Client c = getServiceEnvironment().getClientStore().get(identifier);
if (c == null) {
DebugUtil.dbg(this, "client name is " + getServiceEnvironment().getClientStore().getClass().getSimpleName());
DebugUtil.dbg(this, "client store is a " + getServiceEnvironment().getClientStore());
if (getServiceEnvironment().getClientStore().size() == 0) {
System.err.println("NO ENTRIES IN CLIENT STORE");
} else {
System.err.println("Store contains " + getServiceEnvironment().getClientStore().size() + " entries.");
}
System.err.println("printing identifiers...");
for (Identifier x : getServiceEnvironment().getClientStore().keySet()) {
System.err.println(x);
}
System.err.println("done!");
String ww = "The client with identifier \"" + identifier.toString() + "\" cannot be found.";
warn(ww + " Client store is " + getServiceEnvironment().getClientStore());
throw new UnknownClientException(ww + " Is the value in the client config correct?", identifier);
}
checkClientApproval(c);
return c;
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class RegistrationServlet method addNewClient.
@Override
protected Client addNewClient(HttpServletRequest request, HttpServletResponse response) throws Throwable {
Client client = super.addNewClient(request, response);
client.setSecret(getRequiredParam(request, CLIENT_PUBLIC_KEY, client));
String x = getRequiredParam(request, CLIENT_ERROR_URL, client);
if (!x.toLowerCase().startsWith("https")) {
throw new RetryException("The error uri \"" + x + "\" is not secure.");
}
client.setErrorUri(x);
try {
debug("decoding public key from PEM");
KeyUtil.fromX509PEM(client.getSecret());
} catch (Throwable t) {
warn("could not decode public key for client=" + client.getIdentifierString() + ", message:" + t.getMessage());
request.setAttribute("client", client);
throw new RetryException("public key could not be parsed. " + t.getMessage());
}
fireNewClientEvent(client);
return client;
}
use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.
the class NewClientNotifier method fireNewClientEvent.
@Override
public void fireNewClientEvent(NewClientEvent notificationEvent) {
if (!mailUtil.isEnabled()) {
return;
}
Client client = notificationEvent.getClient();
Map<String, String> replacements = getReplacements(client);
boolean rc = mailUtil.sendMessage(replacements);
if (rc) {
loggingFacade.info("sending email notification for client " + client.getIdentifierString());
} else {
loggingFacade.info("failure sending email notification for client " + client.getIdentifierString());
}
}
Aggregations