Search in sources :

Example 1 with Identifiable

use of edu.uiuc.ncsa.security.core.Identifiable 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 Identifiable

use of edu.uiuc.ncsa.security.core.Identifiable 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 Identifiable

use of edu.uiuc.ncsa.security.core.Identifiable in project OA4MP by ncsa.

the class ClientStoreUtil method listAll.

@Override
protected LinkedList<Identifiable> listAll() throws Exception {
    say("select the number of the item below:");
    ClientApprovalStore cas = getSE().getClientApprovalStore();
    Set keys = getStore().keySet();
    LinkedList<Identifiable> linkedList = new LinkedList<Identifiable>();
    int i = 0;
    for (Object key : keys) {
        boolean isApproved = false;
        ClientApproval ca = (ClientApproval) cas.get(key);
        if (ca == null) {
            // create a new one
            ca = (ClientApproval) cas.create();
            ca.setStatus(ClientApproval.Status.NONE);
            ca.setApproved(false);
            cas.save(ca);
        } else {
            isApproved = ca.isApproved();
            if (isApproved && ca.getStatus() != ClientApproval.Status.APPROVED) {
                ca.setStatus(ClientApproval.Status.APPROVED);
            }
        }
        ClientApproval.Status status = ca.getStatus();
        String printableStatus = "?";
        if (status.equals(ClientApproval.Status.NONE)) {
        }
        Identifiable x = (Identifiable) getStore().get(key);
        linkedList.add(x);
        say((i++) + "." + "(" + (isApproved ? "A" : "D") + ") " + x.getIdentifierString());
    }
    if (linkedList.isEmpty()) {
        say("(no entries found)");
    }
    return linkedList;
}
Also used : Set(java.util.Set) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) ClientApprovalStore(edu.uiuc.ncsa.security.delegation.server.storage.ClientApprovalStore) LinkedList(java.util.LinkedList) Identifiable(edu.uiuc.ncsa.security.core.Identifiable)

Example 4 with Identifiable

use of edu.uiuc.ncsa.security.core.Identifiable in project OA4MP by ncsa.

the class BaseClientStoreCommands method rm.

@Override
public void rm(InputLine inputLine) {
    sayi("Removing approval record");
    Identifiable x = findItem(inputLine);
    info("Removing approval record for id=" + x.getIdentifierString());
    getClientApprovalStore().remove(x.getIdentifier());
    sayi("Done. Client approval with id = " + x.getIdentifierString() + " has been removed from the store");
    info("Client record removed for id=" + x.getIdentifierString());
    super.rm(inputLine);
}
Also used : Identifiable(edu.uiuc.ncsa.security.core.Identifiable)

Example 5 with Identifiable

use of edu.uiuc.ncsa.security.core.Identifiable in project OA4MP by ncsa.

the class CopyToolVerifier method verifyStore.

public boolean verifyStore(String storeName, Store<? extends Identifiable> source, Store<? extends Identifiable> target) {
    long srcSize = source.size();
    if (srcSize != target.size()) {
        say("Error: Source \"" + source + "\"(" + srcSize + ") and target \"" + target + "\"(" + target.size() + ") are not the same");
        return false;
    }
    saynoCR("Checking store " + storeName + " with " + srcSize + " elements... ");
    for (Identifier identifier : source.keySet()) {
        if (!target.containsKey(identifier)) {
            say("Error: Source store contains key " + "\"" + identifier + "\" and target store does not.");
            return false;
        }
        Identifiable src = source.get(identifier);
        if (src == null) {
            say("Error: Failed getting source object with identifier \"" + identifier + "\"");
            return false;
        }
        Identifiable trgt = target.get(identifier);
        if (trgt == null) {
            say("Error: Failed getting target object with identifier \"" + identifier + "\"");
            return false;
        }
        if (!src.equals(trgt)) {
            say("Error: source and target objects do not match!");
            say("Source object:\n\n" + src.toString());
            say("\nTarget object:\n\n" + trgt.toString());
            return false;
        }
    }
    say("ok!");
    return true;
}
Also used : Identifier(edu.uiuc.ncsa.security.core.Identifier) Identifiable(edu.uiuc.ncsa.security.core.Identifiable)

Aggregations

Identifiable (edu.uiuc.ncsa.security.core.Identifiable)5 BaseClient (edu.uiuc.ncsa.security.delegation.storage.BaseClient)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 Identifier (edu.uiuc.ncsa.security.core.Identifier)1 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)1 ClientApprovalStore (edu.uiuc.ncsa.security.delegation.server.storage.ClientApprovalStore)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1