use of org.eclipse.jgit.transport.PushCertificate in project gerrit by GerritCodeReview.
the class SignedPushPreReceiveHook method onPreReceive.
@Override
public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
PushCertificate cert = rp.getPushCertificate();
if (cert == null) {
return;
}
CheckResult result = checkerFactory.create(user.get()).setCheckNonce(true).check(cert).getCheckResult();
if (!isAllowed(result, commands)) {
for (String problem : result.getProblems()) {
rp.sendMessage(problem);
}
reject(commands, "invalid push cert");
}
}
use of org.eclipse.jgit.transport.PushCertificate in project gerrit by GerritCodeReview.
the class PushCertificateCheckerTest method validCert.
@Test
public void validCert() throws Exception {
PushCertificate cert = newSignedCert(validNonce(), validKeyWithoutExpiration());
assertNoProblems(cert);
}
use of org.eclipse.jgit.transport.PushCertificate in project gerrit by GerritCodeReview.
the class PushCertificateCheckerTest method missingKey.
@Test
public void missingKey() throws Exception {
TestKey key2 = validKeyWithExpiration();
PushCertificate cert = newSignedCert(validNonce(), key2);
assertProblems(cert, "No public keys found for key ID " + keyIdToString(key2.getKeyId()));
}
Aggregations