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);
}
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());
}
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);
}
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;
}
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;
}
Aggregations