Search in sources :

Example 1 with CSPRequestCredentials

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());
}
Also used : ConfigRoot(org.collectionspace.chain.csp.config.ConfigRoot) CSPManager(org.collectionspace.csp.api.container.CSPManager) CSPRequestCache(org.collectionspace.csp.api.core.CSPRequestCache) RequestCache(org.collectionspace.csp.helper.core.RequestCache) Record(org.collectionspace.chain.csp.schema.Record) CSPRequestCredentials(org.collectionspace.csp.api.core.CSPRequestCredentials) Spec(org.collectionspace.chain.csp.schema.Spec) StorageGenerator(org.collectionspace.csp.api.persistence.StorageGenerator)

Example 2 with CSPRequestCredentials

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;
}
Also used : CSPRequestCredentials(org.collectionspace.csp.api.core.CSPRequestCredentials)

Example 3 with CSPRequestCredentials

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();
    }
}
Also used : AdminData(org.collectionspace.chain.csp.schema.AdminData) WebReset(org.collectionspace.chain.csp.webui.misc.WebReset) CSPRequestCache(org.collectionspace.csp.api.core.CSPRequestCache) RequestCache(org.collectionspace.csp.helper.core.RequestCache) UIException(org.collectionspace.csp.api.ui.UIException) CSPRequestCredentials(org.collectionspace.csp.api.core.CSPRequestCredentials)

Example 4 with CSPRequestCredentials

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;
}
Also used : CSPRequestCredentials(org.collectionspace.csp.api.core.CSPRequestCredentials)

Aggregations

CSPRequestCredentials (org.collectionspace.csp.api.core.CSPRequestCredentials)4 CSPRequestCache (org.collectionspace.csp.api.core.CSPRequestCache)2 RequestCache (org.collectionspace.csp.helper.core.RequestCache)2 ConfigRoot (org.collectionspace.chain.csp.config.ConfigRoot)1 AdminData (org.collectionspace.chain.csp.schema.AdminData)1 Record (org.collectionspace.chain.csp.schema.Record)1 Spec (org.collectionspace.chain.csp.schema.Spec)1 WebReset (org.collectionspace.chain.csp.webui.misc.WebReset)1 CSPManager (org.collectionspace.csp.api.container.CSPManager)1 StorageGenerator (org.collectionspace.csp.api.persistence.StorageGenerator)1 UIException (org.collectionspace.csp.api.ui.UIException)1