resp.setStatus(500);
PrintWriter wr = resp.getWriter();
e.formatPlain(wr);
- } catch (InterruptedException e) {
- resp.sendError(500, "Interrupted");
}
}
}
resp.sendError(500, "Error, POST required.");
return;
}
+
if (req.getQueryString() != null) {
resp.sendError(500, "Error, no query String allowed.");
return;
}
+
String tserial = req.getParameter("serial");
if (tserial == null) {
resp.sendError(500, "Error, no Serial found");
return;
}
- try {
- Certificate c = Certificate.getBySerial(tserial);
- if (c == null || c.getOwner() != u) {
- resp.sendError(403, "Access Denied");
- return;
- }
- Job job = c.revoke();
- job.waitFor(60000);
- if (c.getStatus() != CertificateStatus.REVOKED) {
- resp.sendError(510, "Error, issuing timed out");
- return;
- }
- resp.getWriter().println("OK");
+
+ Certificate c = Certificate.getBySerial(tserial);
+ if (c == null || c.getOwner() != u) {
+ resp.sendError(403, "Access Denied");
+ return;
+ }
+
+ Job job = c.revoke();
+ job.waitFor(60000);
+ if (c.getStatus() != CertificateStatus.REVOKED) {
+ resp.sendError(510, "Error, issuing timed out");
return;
- } catch (InterruptedException e) {
- e.printStackTrace();
}
+
+ resp.getWriter().println("OK");
+
}
}
CertificateFactory xf = CertificateFactory.getInstance("X509");
HashMap<X500Principal, X509Certificate> map = new HashMap<>();
HashMap<X500Principal, String> names = new HashMap<>();
- for (File f : scandir.listFiles()) {
+ File[] scandirfiles = scandir.listFiles();
+ if (null == scandirfiles) {
+ scandirfiles = new File[0];
+ }
+ for (File f : scandirfiles) {
X509Certificate cert = (X509Certificate) xf.generateCertificate(new FileInputStream(f));
X500Principal princip = cert.getSubjectX500Principal();
map.put(princip, cert);
final HashMap<String, CertificateProfile> myName = new HashMap<String, CertificateProfile>();
final HashMap<Integer, CertificateProfile> myId = new HashMap<Integer, CertificateProfile>();
- for (File f : new File("config/profiles").listFiles()) {
+ File profiledir = new File("config/profiles");
+ File[] profilelist = profiledir.listFiles();
+ if (null == profilelist) {
+ throw new Error("Unable to list available profiles from " + profiledir.getName());
+ }
+
+ for (File f : profilelist) {
Properties p = new Properties();
try (FileInputStream inStream = new FileInputStream(f)) {
p.load(inStream);
BLOCKEDLOGIN("blockedlogin", "may not login"), BLOCKEDCERT("blockedcert", "may not issue certificates"), //
TTP_ASSURER("ttp-assurer", "may verify via TTP"), TTP_APPLICANT("ttp-applicant", "requests to be verified via ttp"), //
CODESIGNING("codesigning", "may issue codesigning certificates"), ORGASSURER("orgassurer", "may verify organisations"), //
- NUCLEUS_ASSURER("nucleus-assurer", "may issue nucleus assurances"), LOCATE_AGENT("locate-agent", "wants access to the locate agent system");
+ NUCLEUS_ASSURER("nucleus-assurer", "may enter nucleus verifications"), LOCATE_AGENT("locate-agent", "wants access to the locate agent system");
private final String dbName;
}
}
- public synchronized boolean waitFor(int max) throws InterruptedException {
+ public synchronized boolean waitFor(int max) {
long start = System.currentTimeMillis();
try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT 1 FROM `jobs` WHERE id=? AND state='open'")) {
ps.setInt(1, id);
if (max != 0 && System.currentTimeMillis() - start > max) {
return false;
}
- Thread.sleep((long) (2000 + Math.random() * 2000));
+ try {
+ this.wait((long) (2000 + Math.random() * 2000));
+ } catch (InterruptedException ie) {
+ // Ignore the interruption
+ ie.printStackTrace();
+ }
rs = ps.executeQuery();
}
}
public void setDoB(DayDate dob) throws GigiApiException {
synchronized (Notary.class) {
if (getReceivedAssurances().length != 0) {
- throw new GigiApiException("No change after assurance allowed.");
+ throw new GigiApiException("No change after verification allowed.");
}
if ( !CalendarUtil.isOfAge(dob, User.MINIMUM_AGE)) {
*
* @return the maximal points @
*/
+ @SuppressWarnings("unused")
public int getMaxAssurePoints() {
if ( !CalendarUtil.isOfAge(dob, ADULT_AGE) && POJAM_ENABLED) {
return 10; // PoJAM
}
- public Name getPreferredName() {
+ public synchronized Name getPreferredName() {
return preferredName;
}
* @throws CSRFException
* if no CSRF-token is found or the token is wrong.
*/
+ @SuppressWarnings("unchecked")
public static <T extends Form> T getForm(HttpServletRequest req, Class<T> target) throws CSRFException {
String csrf = req.getParameter(CSRF_FIELD);
if (csrf == null) {
if (hs == null) {
throw new CSRFException();
}
- Form f = (Form) hs.getAttribute("form/" + target.getName() + "/" + csrf);
+ Object f = hs.getAttribute("form/" + target.getName() + "/" + csrf);
if (f == null) {
throw new CSRFException();
}
+ if ( !(f instanceof Form)) {
+ throw new CSRFException();
+ }
+ if ( !target.isInstance(f)) {
+ throw new CSRFException();
+ }
+ // Dynamic Cast checked by previous if statement
return (T) f;
}
package org.cacert.gigi.output.template;
import java.io.PrintWriter;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
/**
* Wraps a String that needs to be translated before it is printed to the user.
*/
-public final class TranslateCommand implements Translatable {
+public final class TranslateCommand implements Translatable, Serializable {
+
+ private static final long serialVersionUID = 1L;
private final String raw;
} catch (GeneralSecurityException e) {
e.printStackTrace();
throw new GigiApiException("Certificate Request format is invalid.");
- } catch (InterruptedException e) {
- e.printStackTrace();
}
} catch (GigiApiException e) {
e.format(out, Page.getLanguage(req));
</td>
<td align="left">
<label for="login"><?=_Enable certificate login with this certificate?><br />
- <?=_By allowing certificate login, this certificate can be used to login into this account at https://secure.cacert.org/ .?></label>
+ <?=_By allowing certificate login, this certificate can be used to log into this account at !'<code>https://secure.cacert.org/</code>'.?></label>
</td>
</tr>
<tr>
}
long start = System.currentTimeMillis();
for (Job job : revokes) {
- try {
- int toWait = (int) (60000 + start - System.currentTimeMillis());
- if (toWait > 0) {
- job.waitFor(toWait);
- } else {
- break; // canceled... waited too log
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
+ int toWait = (int) (60000 + start - System.currentTimeMillis());
+ if (toWait > 0) {
+ job.waitFor(toWait);
+ } else {
+ break; // canceled... waited too log
}
}
</thead>
<tbody>
<tr>
- <td><?=_I have a CSR! Paste it here:?><br/>Don't know, what as CSR is and how to create one? Take a look in the <a href="https://wiki.cacert.org/FAQ/CSR">Wiki</a>!</td>
+ <td><?=_I have a CSR! Paste it here:?><br/><?=_Don't know what a CSR is or how to create one? Take a look at the !'<a href="https://wiki.cacert.org/FAQ/CSR">'Wiki!'</a>'!?></td>
<td>
<textarea class="form-control" name="CSR" class="csr"></textarea>
</td>
try {
type = AssuranceType.valueOf(val);
} catch (IllegalArgumentException e) {
- gae.mergeInto(new GigiApiException("Assurance Type wrong."));
+ gae.mergeInto(new GigiApiException("Verification Type wrong."));
}
}
int pointsI = 0;
String points = req.getParameter("points");
if (points == null || "".equals(points)) {
- gae.mergeInto(new GigiApiException("For an assurance, you need to enter points."));
+ gae.mergeInto(new GigiApiException("For a verification, you need to enter points."));
} else {
try {
pointsI = Integer.parseInt(points);
if (aword != null && !aword.equals("")) {
Language langApplicant = Language.getInstance(assuree.getPreferredLocale());
- String method = langApplicant.getTranslation("A password reset was triggered. If you did a password reset by assurance, please enter your secret password using this form:");
- String subject = langApplicant.getTranslation("Password reset by assurance");
+ String method = langApplicant.getTranslation("A password reset was triggered. If you did a password reset by verification, please enter your secret password using this form:");
+ String subject = langApplicant.getTranslation("Password reset by verification");
PasswordResetPage.initPasswordResetProcess(out, assuree, req, aword, langApplicant, method, subject);
}
return true;
private static final Template t = new Template(AssuranceForm.class.getResource("AssureeSearch.templ"));
public AssurePage() {
- super("Assure someone");
+ super("Verify someone");
}
AssuranceForm form = Form.getForm(req, AssuranceForm.class);
try {
if (form.submit(out, req)) {
- out.println(translate(req, "Assurance complete."));
+ out.println(translate(req, "Verification complete."));
return;
}
} catch (GigiApiException e) {
import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.IDN;
import java.util.HashSet;
public class PublicSuffixes {
- HashSet<String> suffixes = new HashSet<>();
+ private HashSet<String> suffixes = new HashSet<>();
- HashSet<String> wildcards = new HashSet<>();
+ private HashSet<String> wildcards = new HashSet<>();
- HashSet<String> exceptions = new HashSet<>();
+ private HashSet<String> exceptions = new HashSet<>();
- private static final String url = "https://publicsuffix.org/list/effective_tld_names.dat";
+ static final String url = "https://publicsuffix.org/list/effective_tld_names.dat";
private static PublicSuffixes instance;
private static PublicSuffixes generateDefault() throws IOException {
- try (BufferedReader br = new BufferedReader(new InputStreamReader(PublicSuffixes.class.getResourceAsStream("effective_tld_names.dat"), "UTF-8"))) {
+ InputStream res = PublicSuffixes.class.getResourceAsStream("effective_tld_names.dat");
+
+ if (null == res) {
+ throw new Error("Public Suffix List could not be loaded.");
+ }
+
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(res, "UTF-8"))) {
return new PublicSuffixes(br);
}
}
}
return false;
}
+
}
// Check if we got a proper map (as much as we can tell)
Object pagesObj = pageF.get(gigi);
+ if ( !(pagesObj instanceof Map)) {
+ throw new Error("Invalid state when initializing page structure");
+ }
+
@SuppressWarnings("unchecked")
- HashMap<String, Page> pages = pagesObj instanceof Map ? new HashMap<>((Map<String, Page>) pagesObj) : null;
+ HashMap<String, Page> pages = new HashMap<>((Map<String, Page>) pagesObj);
pages.put("/manage", new Page("Page-manager") {
resp.getWriter().println("error");
} catch (GigiApiException e) {
e.format(resp.getWriter(), Language.getInstance(Locale.ENGLISH));
- } catch (InterruptedException e) {
- e.printStackTrace();
- resp.getWriter().println("interrupted");
}
} else if (req.getParameter("addExDom") != null) {