Search in sources :

Example 1 with ColumnMap

use of edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap in project OA4MP by ncsa.

the class SQLPermissionStore method get.

@Override
public PermissionList get(Identifier adminID, Identifier clientID) {
    PermissionList allOfThem = new PermissionList();
    Connection c = getConnection();
    PermissionKeys permissionKeys = new PermissionKeys();
    try {
        PreparedStatement stmt = c.prepareStatement("select * from " + getTable().getFQTablename() + " where " + permissionKeys.clientID() + "=? AND " + permissionKeys.adminID() + "=?");
        stmt.setString(1, clientID.toString());
        stmt.setString(2, adminID.toString());
        // just execute() since executeQuery(x) would throw an exception regardless of content per JDBC spec.
        stmt.execute();
        ResultSet rs = stmt.getResultSet();
        while (rs.next()) {
            V newOne = create();
            ColumnMap map = rsToMap(rs);
            populate(map, newOne);
            allOfThem.add(newOne);
        }
        rs.close();
        stmt.close();
    } catch (SQLException e) {
        destroyConnection(c);
        throw new GeneralException("Error: could not get database object", e);
    } finally {
        releaseConnection(c);
    }
    return allOfThem;
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 2 with ColumnMap

use of edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap in project OA4MP by ncsa.

the class AbstractDDServer method subset.

protected AdminClient subset(AdminClient client, List<String> attributes) {
    ColumnMap map = new ColumnMap();
    cose.getAdminClientStore().getACConverter().toMap(client, map);
    ColumnMap reducedMap = new ColumnMap();
    for (String key : attributes) {
        reducedMap.put(key, map.get(key));
    }
    // Have to always include the identifier.
    reducedMap.put(cose.getClientStore().getACConverter().getKeys().identifier(), client.getIdentifierString());
    AdminClient x = (AdminClient) cose.getAdminClientStore().getACConverter().fromMap(reducedMap, null);
    return x;
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 3 with ColumnMap

use of edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap in project OA4MP by ncsa.

the class AbstractDDServer method subset.

/**
 * This will take a client and a list of attributes and return the requested subset.
 *
 * @param client
 * @param attributes
 * @return
 */
protected OA2Client subset(OA2Client client, List<String> attributes) {
    ColumnMap map = new ColumnMap();
    cose.getClientStore().getACConverter().toMap(client, map);
    ColumnMap reducedMap = new ColumnMap();
    for (String key : attributes) {
        reducedMap.put(key, map.get(key));
    }
    // Have to always include the identifier.
    reducedMap.put(cose.getClientStore().getACConverter().getKeys().identifier(), client.getIdentifierString());
    OA2Client x = (OA2Client) cose.getClientStore().getACConverter().fromMap(reducedMap, null);
    return x;
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client)

Example 4 with ColumnMap

use of edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap in project OA4MP by ncsa.

the class AttributeServer method removeAdminClient.

/**
 * Remove a subset of attributes for an admin client.
 *
 * @param request
 * @return
 */
protected AttributeAdminClientResponse removeAdminClient(AttributeRemoveRequest request) {
    AdminClient client = getAdminClientStore().get(request.getAdminClient().getIdentifier());
    ColumnMap map = new ColumnMap();
    getACConverter().toMap(client, map);
    for (String key : request.getAttributes()) {
        // don't let anyone change the identifier.
        if (!key.equals(getACConverter().getKeys().identifier())) {
            map.remove(key);
        }
    }
    AdminClient updatedClient = getACConverter().fromMap(map, null);
    getAdminClientStore().save(updatedClient);
    AttributeAdminClientResponse attributeClientResponse = new AttributeAdminClientResponse(updatedClient);
    return attributeClientResponse;
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 5 with ColumnMap

use of edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap in project OA4MP by ncsa.

the class AttributeServer method removeClient.

/**
 * Remove a subset of attributes for client.
 *
 * @param request
 * @return
 */
protected AttributeClientResponse removeClient(AttributeRemoveRequest request) {
    canWrite(request);
    OA2Client client = (OA2Client) getClientStore().get(request.getClient().getIdentifier());
    ColumnMap map = new ColumnMap();
    getClientConverter().toMap(client, map);
    for (String key : request.getAttributes()) {
        // don't let anyone change the identifier.
        if (!key.equals(getClientConverter().getKeys().identifier())) {
            map.remove(key);
        }
    }
    OA2Client updatedClient = getClientConverter().fromMap(map, null);
    getClientStore().save(updatedClient);
    AttributeClientResponse attributeClientResponse = new AttributeClientResponse(updatedClient);
    return attributeClientResponse;
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client)

Aggregations

ColumnMap (edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap)12 OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)6 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)4 AdminClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)3 OA2ClientConverter (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientConverter)3 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 TypeClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient)2 OA2ClientKeys (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientKeys)2 JSONObject (net.sf.json.JSONObject)2 Asset (edu.uiuc.ncsa.myproxy.oa4mp.client.Asset)1 PermissionServer (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.util.permissions.PermissionServer)1 ActionAdd (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionAdd)1 TypePermission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission)1 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)1 ClientKeys (edu.uiuc.ncsa.security.delegation.storage.ClientKeys)1