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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations