Search in sources :

Example 21 with Identifier

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

the class PermissionServer method listClients.

public PermissionResponse listClients(ListClientsRequest request) {
    // request needs an admin client only
    // canRead(request);
    List<Identifier> clientIDs = getPermissionStore().getClients(request.getAdminClient().getIdentifier());
    List<OA2Client> clients = new LinkedList<>();
    for (Identifier id : clientIDs) {
        try {
            getPermissionStore().get(request.getAdminClient().getIdentifier(), id);
            clients.add((OA2Client) getClientStore().get(id));
        } catch (Throwable throwable) {
        // rock on if not allowed
        }
    }
    return new ListClientResponse(clients);
}
Also used : OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client) Identifier(edu.uiuc.ncsa.security.core.Identifier) LinkedList(java.util.LinkedList)

Example 22 with Identifier

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

the class OA2TestCommands method geturi.

/**
 * Constructs the URI
 *
 * @param inputLine
 * @throws Exception
 */
public void geturi(InputLine inputLine) throws Exception {
    if (showHelp(inputLine)) {
        getURIHelp();
        return;
    }
    Identifier id = AssetStoreUtil.createID();
    OA4MPResponse resp = getService().requestCert(id);
    dummyAsset = (OA2Asset) getCe().getAssetStore().get(id.toString());
    say(resp.getRedirect().toString());
}
Also used : Identifier(edu.uiuc.ncsa.security.core.Identifier) OA4MPResponse(edu.uiuc.ncsa.myproxy.oa4mp.client.OA4MPResponse)

Example 23 with Identifier

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

Example 24 with Identifier

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

Example 25 with Identifier

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

Identifier (edu.uiuc.ncsa.security.core.Identifier)33 BasicIdentifier (edu.uiuc.ncsa.security.core.util.BasicIdentifier)18 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)5 Client (edu.uiuc.ncsa.security.delegation.storage.Client)5 Asset (edu.uiuc.ncsa.myproxy.oa4mp.client.Asset)4 AdminClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)4 Permission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission)4 OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)4 URI (java.net.URI)4 SQLException (java.sql.SQLException)4 LinkedList (java.util.LinkedList)4 OA4MPResponse (edu.uiuc.ncsa.myproxy.oa4mp.client.OA4MPResponse)3 TypePermission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission)3 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)3 PrivateKey (java.security.PrivateKey)3 Date (java.util.Date)3 ActionList (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionList)2 ValidTimestampPolicy (edu.uiuc.ncsa.security.core.cache.ValidTimestampPolicy)2 UnknownClientException (edu.uiuc.ncsa.security.core.exceptions.UnknownClientException)2 MyLoggingFacade (edu.uiuc.ncsa.security.core.util.MyLoggingFacade)2