Search in sources :

Example 6 with PushCertificate

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");
    }
}
Also used : PushCertificate(org.eclipse.jgit.transport.PushCertificate)

Example 7 with PushCertificate

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);
}
Also used : PushCertificate(org.eclipse.jgit.transport.PushCertificate) Test(org.junit.Test)

Example 8 with PushCertificate

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()));
}
Also used : TestKey(com.google.gerrit.gpg.testutil.TestKey) PushCertificate(org.eclipse.jgit.transport.PushCertificate) Test(org.junit.Test)

Aggregations

PushCertificate (org.eclipse.jgit.transport.PushCertificate)8 Test (org.junit.Test)6 TestKey (com.google.gerrit.gpg.testutil.TestKey)3 PushCertificateInfo (com.google.gerrit.extensions.common.PushCertificateInfo)1 GerritPushCertificateChecker (com.google.gerrit.gpg.GerritPushCertificateChecker)1 PushCertificateChecker (com.google.gerrit.gpg.PushCertificateChecker)1 GpgException (com.google.gerrit.server.GpgException)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1