use of org.eclipse.jgit.transport.PushCertificate in project gerrit by GerritCodeReview.
the class GpgApiAdapterImpl method checkPushCertificate.
@Override
public PushCertificateInfo checkPushCertificate(String certStr, IdentifiedUser expectedUser) throws GpgException {
try {
PushCertificate cert = PushCertificateParser.fromString(certStr);
PushCertificateChecker.Result result = pushCertCheckerFactory.create(expectedUser).setCheckNonce(false).check(cert);
PushCertificateInfo info = new PushCertificateInfo();
info.certificate = certStr;
info.key = GpgKeys.toJson(result.getPublicKey(), result.getCheckResult());
return info;
} catch (IOException e) {
throw new GpgException(e);
}
}
use of org.eclipse.jgit.transport.PushCertificate in project gerrit by GerritCodeReview.
the class PushCertificateCheckerTest method invalidKey.
@Test
public void invalidKey() throws Exception {
TestKey key3 = expiredKey();
PushCertificate cert = newSignedCert(validNonce(), key3);
assertProblems(cert, "Invalid public key " + keyToString(key3.getPublicKey()) + ":\n Key is expired");
}
use of org.eclipse.jgit.transport.PushCertificate in project gerrit by GerritCodeReview.
the class PushCertificateCheckerTest method invalidNonce.
@Test
public void invalidNonce() throws Exception {
PushCertificate cert = newSignedCert("invalid-nonce", validKeyWithoutExpiration());
assertProblems(cert, "Invalid nonce");
}
use of org.eclipse.jgit.transport.PushCertificate in project gerrit by GerritCodeReview.
the class PushCertificateCheckerTest method signatureByExpiredKeyBeforeExpiration.
@Test
public void signatureByExpiredKeyBeforeExpiration() throws Exception {
TestKey key3 = expiredKey();
Date now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").parse("2005-07-10 12:00:00 -0400");
PushCertificate cert = newSignedCert(validNonce(), key3, now);
assertNoProblems(cert);
}
use of org.eclipse.jgit.transport.PushCertificate in project gerrit by GerritCodeReview.
the class PushCertificateCheckerTest method invalidNonceNotChecked.
@Test
public void invalidNonceNotChecked() throws Exception {
checker = newChecker(false);
PushCertificate cert = newSignedCert("invalid-nonce", validKeyWithoutExpiration());
assertNoProblems(cert);
}
Aggregations