List of usage examples for org.eclipse.jgit.transport PushCertificate getNonceStatus
public NonceStatus getNonceStatus()
From source file:com.google.gerrit.gpg.PushCertificateChecker.java
License:Apache License
/** * Check a push certificate.//from w w w. ja v a 2 s . c o m * * @return result of the check. */ public final CheckResult check(PushCertificate cert) { if (cert.getNonceStatus() != NonceStatus.OK) { return new CheckResult("Invalid nonce"); } List<String> problems = new ArrayList<>(); try { PGPSignature sig = readSignature(cert); if (sig != null) { @SuppressWarnings("resource") Repository repo = getRepository(); try (PublicKeyStore store = new PublicKeyStore(repo)) { checkSignature(sig, cert, store, problems); checkCustom(repo, problems); } finally { if (shouldClose(repo)) { repo.close(); } } } else { problems.add("Invalid signature format"); } } catch (PGPException | IOException e) { String msg = "Internal error checking push certificate"; log.error(msg, e); problems.add(msg); } return new CheckResult(problems); }
From source file:com.google.gerrit.server.git.gpg.PushCertificateChecker.java
License:Apache License
/** * Check a push certificate./*from w w w .j a v a 2 s. co m*/ * * @return result of the check. * @throws PGPException if an error occurred during GPG checks. * @throws IOException if an error occurred reading from the repository. */ public final CheckResult check(PushCertificate cert) throws PGPException, IOException { if (cert.getNonceStatus() != NonceStatus.OK) { return new CheckResult("Invalid nonce"); } PGPSignature sig = readSignature(cert); if (sig == null) { return new CheckResult("Invalid signature format"); } Repository repo = getRepository(); List<String> problems = new ArrayList<>(); try (PublicKeyStore store = new PublicKeyStore(repo)) { checkSignature(sig, cert, store.get(sig.getKeyID()), problems); checkCustom(repo, problems); return new CheckResult(problems); } finally { if (shouldClose(repo)) { repo.close(); } } }