Search in sources :

Example 1 with GpgException

use of com.google.gerrit.server.GpgException 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);
    }
}
Also used : GpgException(com.google.gerrit.server.GpgException) PushCertificate(org.eclipse.jgit.transport.PushCertificate) GerritPushCertificateChecker(com.google.gerrit.gpg.GerritPushCertificateChecker) PushCertificateChecker(com.google.gerrit.gpg.PushCertificateChecker) IOException(java.io.IOException) PushCertificateInfo(com.google.gerrit.extensions.common.PushCertificateInfo)

Example 2 with GpgException

use of com.google.gerrit.server.GpgException in project gerrit by GerritCodeReview.

the class ChangeJson method format.

private ChangeInfo format(ChangeData cd, Optional<PatchSet.Id> limitToPsId, boolean fillAccountLoader) throws OrmException {
    try {
        if (fillAccountLoader) {
            accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
            ChangeInfo res = toChangeInfo(cd, limitToPsId);
            accountLoader.fill();
            return res;
        }
        return toChangeInfo(cd, limitToPsId);
    } catch (PatchListNotAvailableException | GpgException | OrmException | IOException | PermissionBackendException | RuntimeException e) {
        if (!has(CHECK)) {
            Throwables.throwIfInstanceOf(e, OrmException.class);
            throw new OrmException(e);
        }
        return checkOnly(cd);
    }
}
Also used : GpgException(com.google.gerrit.server.GpgException) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) OrmException(com.google.gwtorm.server.OrmException) PatchListNotAvailableException(com.google.gerrit.server.patch.PatchListNotAvailableException) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) IOException(java.io.IOException)

Example 3 with GpgException

use of com.google.gerrit.server.GpgException in project gerrit by GerritCodeReview.

the class GpgApiAdapterImpl method putGpgKeys.

@Override
public Map<String, GpgKeyInfo> putGpgKeys(AccountResource account, List<String> add, List<String> delete) throws RestApiException, GpgException {
    PostGpgKeys.Input in = new PostGpgKeys.Input();
    in.add = add;
    in.delete = delete;
    try {
        return postGpgKeys.apply(account, in);
    } catch (PGPException | OrmException | IOException | ConfigInvalidException e) {
        throw new GpgException(e);
    }
}
Also used : PGPException(org.bouncycastle.openpgp.PGPException) GpgException(com.google.gerrit.server.GpgException) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) OrmException(com.google.gwtorm.server.OrmException) IOException(java.io.IOException) PostGpgKeys(com.google.gerrit.gpg.server.PostGpgKeys)

Example 4 with GpgException

use of com.google.gerrit.server.GpgException in project gerrit by GerritCodeReview.

the class ChangeJson method toChangeInfo.

private List<ChangeInfo> toChangeInfo(Map<Change.Id, ChangeInfo> out, List<ChangeData> changes) {
    List<ChangeInfo> info = Lists.newArrayListWithCapacity(changes.size());
    for (ChangeData cd : changes) {
        ChangeInfo i = out.get(cd.getId());
        if (i == null) {
            try {
                i = toChangeInfo(cd, Optional.empty());
            } catch (PatchListNotAvailableException | GpgException | OrmException | IOException | PermissionBackendException | RuntimeException e) {
                if (has(CHECK)) {
                    i = checkOnly(cd);
                } else {
                    log.warn("Omitting corrupt change " + cd.getId() + " from results", e);
                    continue;
                }
            }
            out.put(cd.getId(), i);
        }
        info.add(i);
    }
    return info;
}
Also used : GpgException(com.google.gerrit.server.GpgException) ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) OrmException(com.google.gwtorm.server.OrmException) PatchListNotAvailableException(com.google.gerrit.server.patch.PatchListNotAvailableException) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) IOException(java.io.IOException) ChangeData(com.google.gerrit.server.query.change.ChangeData)

Aggregations

GpgException (com.google.gerrit.server.GpgException)4 IOException (java.io.IOException)4 OrmException (com.google.gwtorm.server.OrmException)3 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)2 PatchListNotAvailableException (com.google.gerrit.server.patch.PatchListNotAvailableException)2 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)2 PushCertificateInfo (com.google.gerrit.extensions.common.PushCertificateInfo)1 GerritPushCertificateChecker (com.google.gerrit.gpg.GerritPushCertificateChecker)1 PushCertificateChecker (com.google.gerrit.gpg.PushCertificateChecker)1 PostGpgKeys (com.google.gerrit.gpg.server.PostGpgKeys)1 ChangeData (com.google.gerrit.server.query.change.ChangeData)1 PGPException (org.bouncycastle.openpgp.PGPException)1 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)1 PushCertificate (org.eclipse.jgit.transport.PushCertificate)1