use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval in project OA4MP by ncsa.
the class DDServerTests method setupClients.
protected CC setupClients(CMTestStoreProvider tp2) throws Exception {
AdminClient adminClient = getAdminClient(tp2.getAdminClientStore());
ClientApproval clientApproval = tp2.getClientApprovalStore().create();
clientApproval.setIdentifier(adminClient.getIdentifier());
clientApproval.setApproved(true);
clientApproval.setApprover("junit");
tp2.getClientApprovalStore().save(clientApproval);
OA2Client client = getOa2Client(tp2.getClientStore());
PermissionList permissions = tp2.getPermissionStore().get(adminClient.getIdentifier(), client.getIdentifier());
if (permissions.isEmpty()) {
Permission p = tp2.getPermissionStore().create();
p.setAdminID(adminClient.getIdentifier());
p.setClientID(client.getIdentifier());
p.setRead(true);
p.setWrite(true);
p.setDelete(true);
p.setApprove(true);
p.setCreate(true);
tp2.getPermissionStore().save(p);
}
CC cc = new CC();
cc.adminClient = adminClient;
cc.client = client;
return cc;
}
use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval in project OA4MP by ncsa.
the class CAStoreTest method testApprovalCycle.
@Test
public void testApprovalCycle() throws Exception {
assert !getApprovalStore().isApproved(BasicIdentifier.newID("foo:bar:baz://" + getRandomString(32)));
Client client = getClientStore().create();
Identifier identifier = client.getIdentifier();
client.setHomeUri("urn:test:/home/uri/" + getRandomString(32));
client.setSecret(getRandomString(256));
client.setName("Test client" + getRandomString(32));
client.setEmail(getRandomString(32) + "@email.foo.edu");
client.setErrorUri("uri:test:/uh/oh/uri/" + getRandomString(32));
getClientStore().save(client);
ClientApproval ca = getApprovalStore().create();
ca.setApprover("test-approver");
ca.setApproved(false);
ca.setApprovalTimestamp(new Date());
ca.setIdentifier(identifier);
getApprovalStore().save(ca);
assert !getApprovalStore().get(client.getIdentifier()).isApproved();
assert !getApprovalStore().isApproved(identifier);
ca.setApproved(true);
getApprovalStore().save(ca);
// Regression test to be sure that identifiers are never changed.
assert identifier.equals(ca.getIdentifier());
assert identifier.equals(client.getIdentifier());
assert getApprovalStore().get(client.getIdentifier()).isApproved();
assert getApprovalStore().isApproved(identifier);
getApprovalStore().remove(client.getIdentifier());
getClientStore().remove(client.getIdentifier());
}
use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval in project OA4MP by ncsa.
the class CAStoreTest method testApprovalStore.
@Test
public void testApprovalStore() throws Exception {
// put one in, get it back, make sure it matches.
Client client = getClientStore().create();
client.setHomeUri("urn:test:/home/uri/" + getRandomString(32));
client.setSecret(getRandomString(256));
client.setName("Test client" + getRandomString(32));
client.setEmail(getRandomString(32) + "@email.foo.edu");
client.setErrorUri("uri:test:/uh/oh/uri/" + getRandomString(32));
getClientStore().save(client);
ClientApproval ca = getApprovalStore().create();
ca.setApprover("test-approver");
ca.setApproved(true);
ca.setApprovalTimestamp(new Date());
ca.setIdentifier(client.getIdentifier());
getApprovalStore().save(ca);
ClientApproval ca1 = getApprovalStore().get(ca.getIdentifier());
assert ca.equals(ca1);
getApprovalStore().remove(ca.getIdentifier());
}
use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval in project OA4MP by ncsa.
the class NewCAStoreTest method testApprovalCycle.
public void testApprovalCycle(ClientStore clientStore, ClientApprovalStore caStore) throws Exception {
assert !caStore.isApproved(BasicIdentifier.newID("foo:bar:baz://" + getRandomString(32)));
Client client = (Client) clientStore.create();
Identifier identifier = client.getIdentifier();
client.setHomeUri("urn:test:/home/uri/" + getRandomString(32));
client.setSecret(getRandomString(256));
client.setName("Test client" + getRandomString(32));
client.setEmail(getRandomString(32) + "@email.foo.edu");
client.setErrorUri("uri:test:/uh/oh/uri/" + getRandomString(32));
clientStore.save(client);
ClientApproval ca = (ClientApproval) caStore.create();
ca.setApprover("test-approver");
ca.setApproved(false);
ca.setApprovalTimestamp(new Date());
ca.setIdentifier(identifier);
caStore.save(ca);
assert !((ClientApproval) caStore.get(client.getIdentifier())).isApproved();
assert !caStore.isApproved(identifier);
ca.setApproved(true);
caStore.save(ca);
// Regression test to be sure that identifiers are never changed.
assert identifier.equals(ca.getIdentifier());
assert identifier.equals(client.getIdentifier());
assert ((ClientApproval) caStore.get(client.getIdentifier())).isApproved();
assert caStore.isApproved(identifier);
caStore.remove(client.getIdentifier());
clientStore.remove(client.getIdentifier());
}
use of edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval in project OA4MP by ncsa.
the class NewCAStoreTest method testPermissions.
public void testPermissions() throws Exception {
File storeDirectory = File.createTempFile("fs-store", "-tmp");
File indexDirectory = File.createTempFile("fs-index", "-tmp");
storeDirectory.setWritable(false);
indexDirectory.setWritable(false);
assert !storeDirectory.canWrite();
FSClientApprovalStore x = null;
final ClientApprovalProvider caProvider = new ClientApprovalProvider();
try {
// Make sure that if someone creates a bad one, it blows up in the constructor.
x = new FSClientApprovalStore(null, null, null, null) {
@Override
public Object put(Object key, Object value) {
return null;
}
};
assert false : "Could make a new object without being properly configured";
} catch (MyConfigurationException xx) {
assert true;
}
x = new DSFSClientApprovalStore(storeDirectory, indexDirectory, caProvider, new ClientApproverConverter(caProvider));
try {
// should bomb here.
x.create();
assert false;
} catch (FilePermissionsException xx) {
assert true;
}
// so make a new entry and then have retrieving it fail.
storeDirectory.setWritable(true);
indexDirectory.setWritable(true);
ClientApproval ca = (ClientApproval) x.create();
// fail for store directory un readable
storeDirectory.setReadable(false);
try {
x.get(ca.getIdentifier());
assert false;
} catch (FilePermissionsException xx) {
assert true;
}
}
Aggregations