Search in sources :

Example 1 with ClientApproverConverter

use of edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter in project OA4MP by ncsa.

the class AbstractConfigurationLoader method getCASP.

protected MultiDSClientApprovalStoreProvider getCASP() {
    if (casp == null) {
        casp = new MultiDSClientApprovalStoreProvider(cn, isDefaultStoreDisabled(), loggerProvider.get());
        final ClientApprovalProvider caProvider = new ClientApprovalProvider();
        ClientApproverConverter cp = new ClientApproverConverter(caProvider);
        casp.addListener(new DSFSClientApprovalStoreProvider(cn, cp));
        casp.addListener(new DSSQLClientApprovalStoreProvider(cn, getMySQLConnectionPoolProvider(), OA4MPConfigTags.MYSQL_STORE, cp));
        casp.addListener(new DSSQLClientApprovalStoreProvider(cn, getMariaDBConnectionPoolProvider(), OA4MPConfigTags.MARIADB_STORE, cp));
        casp.addListener(new DSSQLClientApprovalStoreProvider(cn, getPgConnectionPoolProvider(), OA4MPConfigTags.POSTGRESQL_STORE, cp));
        casp.addListener(new TypedProvider<ClientApprovalStore>(cn, OA4MPConfigTags.MEMORY_STORE, OA4MPConfigTags.CLIENT_APPROVAL_STORE) {

            @Override
            public Object componentFound(CfgEvent configurationEvent) {
                if (checkEvent(configurationEvent)) {
                    return get();
                }
                return null;
            }

            @Override
            public ClientApprovalStore get() {
                return new ClientApprovalMemoryStore(caProvider);
            }
        });
    }
    return casp;
}
Also used : MultiDSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientApprovalStoreProvider) DSFSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStoreProvider) CfgEvent(edu.uiuc.ncsa.security.core.configuration.provider.CfgEvent) ClientApprovalMemoryStore(edu.uiuc.ncsa.security.delegation.server.storage.impl.ClientApprovalMemoryStore) ClientApproverConverter(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter) ClientApprovalStore(edu.uiuc.ncsa.security.delegation.server.storage.ClientApprovalStore) ClientApprovalProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider) DSSQLClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.sql.provider.DSSQLClientApprovalStoreProvider)

Example 2 with ClientApproverConverter

use of edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter in project OA4MP by ncsa.

the class OA2ConfigurationLoader method getCASP.

@Override
protected MultiDSClientApprovalStoreProvider getCASP() {
    if (casp == null) {
        casp = new MultiDSClientApprovalStoreProvider(cn, isDefaultStoreDisabled(), loggerProvider.get());
        final ClientApprovalProvider caProvider = new ClientApprovalProvider();
        ClientApprovalKeys caKeys = new ClientApprovalKeys();
        caKeys.identifier("client_id");
        ClientApproverConverter cp = new ClientApproverConverter(caKeys, caProvider);
        casp.addListener(new DSFSClientApprovalStoreProvider(cn, cp));
        casp.addListener(new DSSQLClientApprovalStoreProvider(cn, getMySQLConnectionPoolProvider(), OA4MPConfigTags.MYSQL_STORE, cp));
        casp.addListener(new DSSQLClientApprovalStoreProvider(cn, getMariaDBConnectionPoolProvider(), OA4MPConfigTags.MARIADB_STORE, cp));
        casp.addListener(new DSSQLClientApprovalStoreProvider(cn, getPgConnectionPoolProvider(), OA4MPConfigTags.POSTGRESQL_STORE, cp));
        casp.addListener(new TypedProvider<ClientApprovalStore>(cn, OA4MPConfigTags.MEMORY_STORE, OA4MPConfigTags.CLIENT_APPROVAL_STORE) {

            @Override
            public Object componentFound(CfgEvent configurationEvent) {
                if (checkEvent(configurationEvent)) {
                    return get();
                }
                return null;
            }

            @Override
            public ClientApprovalStore get() {
                return new ClientApprovalMemoryStore(caProvider);
            }
        });
    }
    return casp;
}
Also used : MultiDSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientApprovalStoreProvider) DSFSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStoreProvider) CfgEvent(edu.uiuc.ncsa.security.core.configuration.provider.CfgEvent) ClientApprovalMemoryStore(edu.uiuc.ncsa.security.delegation.server.storage.impl.ClientApprovalMemoryStore) ClientApprovalKeys(edu.uiuc.ncsa.security.delegation.storage.ClientApprovalKeys) ClientApproverConverter(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter) ClientApprovalStore(edu.uiuc.ncsa.security.delegation.server.storage.ClientApprovalStore) ClientApprovalProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider) DSSQLClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.sql.provider.DSSQLClientApprovalStoreProvider)

Example 3 with ClientApproverConverter

use of edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter in project OA4MP by ncsa.

the class ServiceConfigTest method testClientApprovalStoreProvider.

public void testClientApprovalStoreProvider() throws Exception {
    ConfigurationNode cn = getConfig("postgresql config");
    MultiDSClientApprovalStoreProvider dap = new MultiDSClientApprovalStoreProvider(cn, true, new MyLoggingFacade("test"), null, null);
    ClientApproverConverter cp = new ClientApproverConverter(new ClientApprovalProvider());
    dap.addListener(new DSFSClientApprovalStoreProvider(cn, cp));
    dap.addListener(new DSSQLClientApprovalStoreProvider(cn, new MySQLConnectionPoolProvider("oauth", "oauth"), MYSQL_STORE, cp));
    dap.addListener(new DSSQLClientApprovalStoreProvider(cn, new PGConnectionPoolProvider("oauth", "oauth"), POSTGRESQL_STORE, cp));
    ClientApprovalStore<ClientApproval> as = (ClientApprovalStore<ClientApproval>) dap.get();
}
Also used : MultiDSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientApprovalStoreProvider) MyLoggingFacade(edu.uiuc.ncsa.security.core.util.MyLoggingFacade) MySQLConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.mysql.MySQLConnectionPoolProvider) PGConnectionPoolProvider(edu.uiuc.ncsa.security.storage.sql.postgres.PGConnectionPoolProvider) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) ConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode) DSFSClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStoreProvider) ClientApproverConverter(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter) ClientApprovalStore(edu.uiuc.ncsa.security.delegation.server.storage.ClientApprovalStore) ClientApprovalProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider) DSSQLClientApprovalStoreProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.sql.provider.DSSQLClientApprovalStoreProvider)

Example 4 with ClientApproverConverter

use of edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter in project OA4MP by ncsa.

the class FSCAStoreTest 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;
    }
}
Also used : MyConfigurationException(edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException) DSFSClientApprovalStore(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStore) FSClientApprovalStore(edu.uiuc.ncsa.security.delegation.server.storage.impl.FSClientApprovalStore) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) FilePermissionsException(edu.uiuc.ncsa.security.core.exceptions.FilePermissionsException) DSFSClientApprovalStore(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStore) ClientApproverConverter(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter) ClientApprovalProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider) File(java.io.File)

Example 5 with ClientApproverConverter

use of edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter 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;
    }
}
Also used : MyConfigurationException(edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException) DSFSClientApprovalStore(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStore) FSClientApprovalStore(edu.uiuc.ncsa.security.delegation.server.storage.impl.FSClientApprovalStore) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) FilePermissionsException(edu.uiuc.ncsa.security.core.exceptions.FilePermissionsException) DSFSClientApprovalStore(edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStore) ClientApproverConverter(edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter) ClientApprovalProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider) File(java.io.File)

Aggregations

ClientApprovalProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.ClientApprovalProvider)5 ClientApproverConverter (edu.uiuc.ncsa.myproxy.oa4mp.server.util.ClientApproverConverter)5 MultiDSClientApprovalStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientApprovalStoreProvider)3 DSFSClientApprovalStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStoreProvider)3 DSSQLClientApprovalStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.sql.provider.DSSQLClientApprovalStoreProvider)3 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)3 ClientApprovalStore (edu.uiuc.ncsa.security.delegation.server.storage.ClientApprovalStore)3 DSFSClientApprovalStore (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.filestore.DSFSClientApprovalStore)2 CfgEvent (edu.uiuc.ncsa.security.core.configuration.provider.CfgEvent)2 FilePermissionsException (edu.uiuc.ncsa.security.core.exceptions.FilePermissionsException)2 MyConfigurationException (edu.uiuc.ncsa.security.core.exceptions.MyConfigurationException)2 ClientApprovalMemoryStore (edu.uiuc.ncsa.security.delegation.server.storage.impl.ClientApprovalMemoryStore)2 FSClientApprovalStore (edu.uiuc.ncsa.security.delegation.server.storage.impl.FSClientApprovalStore)2 File (java.io.File)2 MyLoggingFacade (edu.uiuc.ncsa.security.core.util.MyLoggingFacade)1 ClientApprovalKeys (edu.uiuc.ncsa.security.delegation.storage.ClientApprovalKeys)1 MySQLConnectionPoolProvider (edu.uiuc.ncsa.security.storage.sql.mysql.MySQLConnectionPoolProvider)1 PGConnectionPoolProvider (edu.uiuc.ncsa.security.storage.sql.postgres.PGConnectionPoolProvider)1 ConfigurationNode (org.apache.commons.configuration.tree.ConfigurationNode)1