You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GpgObjectSigner.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (C) 2020 Thomas Wolf <thomas.wolf@paranor.ch> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.lib;
  11. import org.eclipse.jgit.annotations.NonNull;
  12. import org.eclipse.jgit.annotations.Nullable;
  13. import org.eclipse.jgit.api.errors.CanceledException;
  14. import org.eclipse.jgit.transport.CredentialsProvider;
  15. /**
  16. * Creates GPG signatures for Git objects.
  17. *
  18. * @since 5.11
  19. */
  20. public interface GpgObjectSigner {
  21. /**
  22. * Signs the specified object.
  23. *
  24. * <p>
  25. * Implementors should obtain the payload for signing from the specified
  26. * object via {@link ObjectBuilder#build()} and create a proper
  27. * {@link GpgSignature}. The generated signature must be set on the
  28. * specified {@code object} (see
  29. * {@link ObjectBuilder#setGpgSignature(GpgSignature)}).
  30. * </p>
  31. * <p>
  32. * Any existing signature on the object must be discarded prior obtaining
  33. * the payload via {@link ObjectBuilder#build()}.
  34. * </p>
  35. *
  36. * @param object
  37. * the object to sign (must not be {@code null} and must be
  38. * complete to allow proper calculation of payload)
  39. * @param gpgSigningKey
  40. * the signing key to locate (passed as is to the GPG signing
  41. * tool as is; eg., value of <code>user.signingkey</code>)
  42. * @param committer
  43. * the signing identity (to help with key lookup in case signing
  44. * key is not specified)
  45. * @param credentialsProvider
  46. * provider to use when querying for signing key credentials (eg.
  47. * passphrase)
  48. * @throws CanceledException
  49. * when signing was canceled (eg., user aborted when entering
  50. * passphrase)
  51. */
  52. void signObject(@NonNull ObjectBuilder object,
  53. @Nullable String gpgSigningKey, @NonNull PersonIdent committer,
  54. CredentialsProvider credentialsProvider) throws CanceledException;
  55. }