use of edu.uiuc.ncsa.security.delegation.storage.BaseClient in project OA4MP by ncsa.
the class ClientSorter method sortByID.
protected ArrayList<Identifiable> sortByID(List<Identifiable> arg) {
TreeMap<String, Identifiable> tm = new TreeMap<>();
for (int i = 0; i < arg.size(); i++) {
BaseClient client = (BaseClient) arg.get(i);
tm.put(client.getIdentifierString(), client);
}
return new ArrayList(tm.values());
}
use of edu.uiuc.ncsa.security.delegation.storage.BaseClient in project OA4MP by ncsa.
the class ClientSorter method sortByDate.
protected ArrayList<Identifiable> sortByDate(List<Identifiable> arg) {
TreeMap<String, ArrayList<Identifiable>> tm = new TreeMap<>();
// allows for multiple values for each key and then returns everything.
for (int i = 0; i < arg.size(); i++) {
BaseClient client = (BaseClient) arg.get(i);
String key = Iso8601.date2String(client.getCreationTS());
if (tm.containsKey(key)) {
tm.get(key).add(client);
} else {
ArrayList<Identifiable> x = new ArrayList<>();
x.add(client);
tm.put(key, x);
}
}
// now we have to unpack any lists.
ArrayList<Identifiable> outList = new ArrayList<>();
for (String key : tm.keySet()) {
outList.addAll(tm.get(key));
}
return outList;
}
use of edu.uiuc.ncsa.security.delegation.storage.BaseClient in project OA4MP by ncsa.
the class BaseClientStoreCommands method longFormat.
@Override
protected void longFormat(Identifiable identifiable) {
BaseClient client = (BaseClient) identifiable;
say("Client name=" + (client.getName() == null ? "(no name)" : client.getName()));
sayi("identifier=" + client.getIdentifier());
sayi("email=" + client.getEmail());
sayi("creation timestamp=" + client.getCreationTS());
if (getClientApprovalStore() != null) {
ClientApproval clientApproval = (ClientApproval) getClientApprovalStore().get(client.getIdentifier());
if (clientApproval == null) {
sayi("no approval record exists.");
} else {
if (clientApproval.isApproved()) {
String approver = "(unknown)";
if (clientApproval.getApprover() != null) {
approver = clientApproval.getApprover();
}
sayi("approved by " + approver);
} else {
sayi("not approved");
}
}
}
if (client.getSecret() == null) {
sayi("public key: (none)");
} else {
sayi("public key:");
say(client.getSecret());
}
}
use of edu.uiuc.ncsa.security.delegation.storage.BaseClient in project OA4MP by ncsa.
the class RequestFactory method convertToRequest.
public static AbstractDDRequest convertToRequest(JSONObject json) {
AbstractDDRequest req = null;
BaseClient client = SATFactory.getSubject(json);
Action action = SATFactory.getMethod(json);
if (action instanceof MissingAction) {
throw new GeneralException("Error: no valid method found");
}
Type type = SATFactory.getType(json);
BaseClient target = SATFactory.getTarget(json);
switch(SATFactory.getSubjectValue(json)) {
case SUBJECT_ADMIN_VALUE:
// return createSubjectAdminRequest(json);
case SUBJECT_CLIENT_VALUE:
break;
case SUBJECT_UNKNOWN_VALUE:
default:
throw new GeneralException("Unknown subject type");
}
return req;
}
use of edu.uiuc.ncsa.security.delegation.storage.BaseClient in project OA4MP by ncsa.
the class BaseClientStoreCommands method update.
@Override
public boolean update(Identifiable identifiable) {
BaseClient client = (BaseClient) 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()));
// 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;
}
Aggregations