use of edu.uiuc.ncsa.security.core.exceptions.GeneralException in project OA4MP by ncsa.
the class CRServlet method getX509Certificates.
/**
* Loops through the facade looking for the active connection and calls it.
*
* @param transaction
* @param localCertRequest
* @param statusString
* @return
* @throws GeneralSecurityException
*/
protected LinkedList<X509Certificate> getX509Certificates(ServiceTransaction transaction, MyPKCS10CertRequest localCertRequest, String statusString) throws GeneralSecurityException {
MyProxyConnectable mpc = getMPConnection(transaction);
mpc.setLifetime(transaction.getLifetime());
LinkedList<X509Certificate> certs = mpc.getCerts(localCertRequest);
if (certs.isEmpty()) {
info(statusString + "Error: MyProxy service returned no certs.");
throw new GeneralException("Error: MyProxy service returned no certs.");
}
info(statusString + "Got cert from MyProxy, issuing a limited proxy & storing it.");
return certs;
}
use of edu.uiuc.ncsa.security.core.exceptions.GeneralException 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.core.exceptions.GeneralException in project OA4MP by ncsa.
the class SQLPermissionStore method getClients.
@Override
public List<Identifier> getClients(Identifier adminID) {
ArrayList<Identifier> clients = new ArrayList<>();
if (adminID == null)
return clients;
Connection c = getConnection();
PermissionKeys permissionKeys = new PermissionKeys();
try {
PreparedStatement stmt = c.prepareStatement("select " + permissionKeys.clientID() + " from " + getTable().getFQTablename() + " where " + permissionKeys.adminID() + "=?");
stmt.setString(1, 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()) {
String clientID = rs.getString(permissionKeys.clientID());
clients.add(BasicIdentifier.newID(clientID));
}
rs.close();
stmt.close();
} catch (SQLException e) {
destroyConnection(c);
throw new GeneralException("Error: could not get database object", e);
} finally {
releaseConnection(c);
}
return clients;
}
use of edu.uiuc.ncsa.security.core.exceptions.GeneralException in project OA4MP by ncsa.
the class SQLClientApprovalStore method getPendingCount.
@Override
public int getPendingCount() {
int count = 0;
String query = "Select " + getTable().getPrimaryKeyColumnName() + " from " + getTable().getFQTablename() + " where " + getCAT().ca().approved() + "=false ";
Connection c = getConnection();
try {
PreparedStatement stmt = c.prepareStatement(query);
stmt.execute();
ResultSet rs = stmt.getResultSet();
while (rs.next()) {
count++;
}
rs.close();
stmt.close();
} catch (SQLException e) {
destroyConnection(c);
throw new GeneralException("Error getting the user ids", e);
} finally {
releaseConnection(c);
}
return count;
}
use of edu.uiuc.ncsa.security.core.exceptions.GeneralException in project OA4MP by ncsa.
the class SQLClientApprovalStore method getUnapprovedCount.
@Override
public int getUnapprovedCount() {
int count = 0;
String query = "Select " + getTable().getPrimaryKeyColumnName() + " from " + getTable().getFQTablename() + " where " + getCAT().ca().approved() + "=false ";
Connection c = getConnection();
try {
PreparedStatement stmt = c.prepareStatement(query);
stmt.execute();
ResultSet rs = stmt.getResultSet();
while (rs.next()) {
count++;
}
rs.close();
stmt.close();
} catch (SQLException e) {
destroyConnection(c);
throw new GeneralException("Error getting the user ids", e);
} finally {
releaseConnection(c);
}
return count;
}
Aggregations