public static synchronized CertificateOwner getById(int id) {
CertificateOwner u = myCache.get(id);
if (u == null) {
- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT *, users.id AS uid, organisations.id AS oid FROM certOwners LEFT JOIN users ON users.id=certOwners.id LEFT JOIN organisations ON organisations.id = certOwners.id WHERE certOwners.id=?");
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT *, users.id AS uid, organisations.id AS oid FROM certOwners LEFT JOIN users ON users.id=certOwners.id LEFT JOIN organisations ON organisations.id = certOwners.id WHERE certOwners.id=? AND deleted is null");
ps.setInt(1, id);
GigiResultSet rs = ps.executeQuery();
if ( !rs.next()) {
return false;
}
+ public void delete() {
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("UPDATE certowners set deleted=NOW() WHERE id=?");
+ ps.setInt(1, getId());
+ ps.execute();
+ myCache.remove(this);
+ }
}
objectCache.hashmap.clear();
}
}
+
+ public void remove(T toRm) {
+ hashmap.remove(toRm);
+ }
}
}
public static Organisation[] getOrganisations(int offset, int count) {
- GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT id FROM organisations LIMIT ?,?");
+ GigiPreparedStatement ps = DatabaseConnection.getInstance().prepare("SELECT certOwners.id FROM organisations inner join certOwners on certOwners.id=organisations.id where certOwners.deleted is null LIMIT ?,?");
ps.setInt(1, offset);
ps.setInt(2, count);
GigiResultSet res = ps.executeQuery();
selectedDigest = Digest.valueOf(hashAlg);
}
profile = CertificateProfile.getByName(req.getParameter("profile"));
- Organisation neworg = Organisation.getById(Integer.parseInt(req.getParameter("org")));
- if (neworg == null || u.getOrganisations().contains(neworg)) {
- org = neworg;
- } else {
- outputError(out, req, "Selected Organisation is not part of your account.");
+ String newOrgStr = req.getParameter("org");
+ if (newOrgStr != null) {
+ Organisation neworg = Organisation.getById(Integer.parseInt(newOrgStr));
+ if (neworg == null || u.getOrganisations().contains(neworg)) {
+ org = neworg;
+ } else {
+ outputError(out, req, "Selected Organisation is not part of your account.");
+ }
}
ou = req.getParameter("OU");
if ( !u.canIssue(profile)) {
}
String profileKey = extractPattern(result, Pattern.compile("<option value=\"([^\"]*)\" selected>"));
- String resultingCN = extractPattern(result, Pattern.compile("<input [^>]*name='CN' [^>]*value='([^']*)'>"));
+ String resultingCN = extractPattern(result, Pattern.compile("<input [^>]*name='CN' [^>]*value='([^']*)'/>"));
String txt = extractPattern(result, Pattern.compile("<textarea [^>]*name='SANs' [^>]*>([^<]*)</textarea>"));
String md = extractPattern(result, Pattern.compile("<input type=\"radio\" [^>]*name=\"hash_alg\" value=\"([^\"]*)\" checked='checked'/>"));
return new String[] {
assertEquals(200, ((HttpURLConnection) uc).getResponseCode());
uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()).openConnection(), session);
assertEquals(200, ((HttpURLConnection) uc).getResponseCode());
+ o1.delete();
+ o2.delete();
}
}