use of org.collectionspace.csp.api.core.CSPRequestCredentials in project application by collectionspace.
the class ServicesBaseClass method makeServicesStorage.
protected Storage makeServicesStorage() throws CSPDependencyException {
CSPManager cspm = getServiceManager();
ConfigRoot root = cspm.getConfigRoot();
Spec spec = (Spec) root.getRoot(Spec.SPEC_ROOT);
assertNotNull(spec);
// XXX this is spec specific testing that will break when we rename the object in the UI
Record r_obj = spec.getRecord("collection-object");
assertNotNull(r_obj);
assertEquals("collection-object", r_obj.getID());
assertEquals("cataloging", r_obj.getWebURL());
StorageGenerator gen = cspm.getStorage("service");
CSPRequestCredentials creds = gen.createCredentials();
creds.setCredential(ServicesStorageGenerator.CRED_USERID, spec.getAdminData().getAuthUser());
creds.setCredential(ServicesStorageGenerator.CRED_PASSWORD, spec.getAdminData().getAuthPass());
return gen.getStorage(creds, new RequestCache());
}
use of org.collectionspace.csp.api.core.CSPRequestCredentials in project application by collectionspace.
the class Request method generateCredentials.
private CSPRequestCredentials generateCredentials(UISession session) {
// XXX
CSPRequestCredentials creds = storage_generator.createCredentials();
if (session != null && creds != null) {
String userId = (String) session.getValue(UISession.USERID);
if (userId == null || userId.isEmpty() || userId.trim().isEmpty()) {
userId = "<No User ID specified.>";
}
creds.setCredential(StorageGenerator.CRED_USERID, userId);
String password = (String) session.getValue(UISession.PASSWORD);
if (password == null || password.isEmpty() || password.trim().isEmpty()) {
password = "<No password specified.>";
}
creds.setCredential(StorageGenerator.CRED_PASSWORD, password);
}
return creds;
}
use of org.collectionspace.csp.api.core.CSPRequestCredentials in project application by collectionspace.
the class ServicesStorageGenerator method initializeAuthorities.
private void initializeAuthorities(CSPManager cspManager, Spec spec) {
AdminData ad = spec.getAdminData();
String adminUsername = ad.getAuthUser();
String adminPass = ad.getAuthPass();
// request.getSession().setValue(UISession.USERID,ad.getAuthUser());
// request.getSession().setValue(UISession.PASSWORD,ad.getAuthPass());
CSPRequestCredentials creds = this.createCredentials();
creds.setCredential(CRED_USERID, spec.getAdminData().getAuthUser());
creds.setCredential(CRED_PASSWORD, spec.getAdminData().getAuthPass());
WebReset webReset = new WebReset(false, false);
webReset.configure((WebUI) cspManager.getUI(""), spec);
try {
webReset.run(getStorage(creds, new RequestCache()), null, new String[0], false);
} catch (UIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.collectionspace.csp.api.core.CSPRequestCredentials in project application by collectionspace.
the class Request method getStorage.
public synchronized Storage getStorage() throws UIException {
if (storage == null) {
CSPRequestCredentials creds = generateCredentials(uir.getSession());
storage = storage_generator.getStorage(creds, cache);
}
return storage;
}
Aggregations