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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations