Search in sources :

Example 1 with BaseClient

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());
}
Also used : ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) BaseClient(edu.uiuc.ncsa.security.delegation.storage.BaseClient) Identifiable(edu.uiuc.ncsa.security.core.Identifiable)

Example 2 with BaseClient

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;
}
Also used : ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) BaseClient(edu.uiuc.ncsa.security.delegation.storage.BaseClient) Identifiable(edu.uiuc.ncsa.security.core.Identifiable)

Example 3 with BaseClient

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());
    }
}
Also used : ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) BaseClient(edu.uiuc.ncsa.security.delegation.storage.BaseClient)

Example 4 with BaseClient

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;
}
Also used : GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) BaseClient(edu.uiuc.ncsa.security.delegation.storage.BaseClient)

Example 5 with BaseClient

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;
}
Also used : BasicIdentifier(edu.uiuc.ncsa.security.core.util.BasicIdentifier) Identifier(edu.uiuc.ncsa.security.core.Identifier) BaseClient(edu.uiuc.ncsa.security.delegation.storage.BaseClient)

Aggregations

BaseClient (edu.uiuc.ncsa.security.delegation.storage.BaseClient)7 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)3 Identifiable (edu.uiuc.ncsa.security.core.Identifiable)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 Identifier (edu.uiuc.ncsa.security.core.Identifier)1 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)1 BasicIdentifier (edu.uiuc.ncsa.security.core.util.BasicIdentifier)1