選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

GpgObjectSigner.java 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.api.errors.UnsupportedSigningFormatException;
  15. import org.eclipse.jgit.transport.CredentialsProvider;
  16. /**
  17. * Creates GPG signatures for Git objects.
  18. *
  19. * @since 5.11
  20. */
  21. public interface GpgObjectSigner {
  22. /**
  23. * Signs the specified object.
  24. *
  25. * <p>
  26. * Implementors should obtain the payload for signing from the specified
  27. * object via {@link ObjectBuilder#build()} and create a proper
  28. * {@link GpgSignature}. The generated signature must be set on the
  29. * specified {@code object} (see
  30. * {@link ObjectBuilder#setGpgSignature(GpgSignature)}).
  31. * </p>
  32. * <p>
  33. * Any existing signature on the object must be discarded prior obtaining
  34. * the payload via {@link ObjectBuilder#build()}.
  35. * </p>
  36. *
  37. * @param object
  38. * the object to sign (must not be {@code null} and must be
  39. * complete to allow proper calculation of payload)
  40. * @param gpgSigningKey
  41. * the signing key to locate (passed as is to the GPG signing
  42. * tool as is; eg., value of <code>user.signingkey</code>)
  43. * @param committer
  44. * the signing identity (to help with key lookup in case signing
  45. * key is not specified)
  46. * @param credentialsProvider
  47. * provider to use when querying for signing key credentials (eg.
  48. * passphrase)
  49. * @param config
  50. * GPG settings from the git config
  51. * @throws CanceledException
  52. * when signing was canceled (eg., user aborted when entering
  53. * passphrase)
  54. * @throws UnsupportedSigningFormatException
  55. * if a config is given and the wanted key format is not
  56. * supported
  57. */
  58. void signObject(@NonNull ObjectBuilder object,
  59. @Nullable String gpgSigningKey, @NonNull PersonIdent committer,
  60. CredentialsProvider credentialsProvider, GpgConfig config)
  61. throws CanceledException, UnsupportedSigningFormatException;
  62. /**
  63. * Indicates if a signing key is available for the specified committer
  64. * and/or signing key.
  65. *
  66. * @param gpgSigningKey
  67. * the signing key to locate (passed as is to the GPG signing
  68. * tool as is; eg., value of <code>user.signingkey</code>)
  69. * @param committer
  70. * the signing identity (to help with key lookup in case signing
  71. * key is not specified)
  72. * @param credentialsProvider
  73. * provider to use when querying for signing key credentials (eg.
  74. * passphrase)
  75. * @param config
  76. * GPG settings from the git config
  77. * @return <code>true</code> if a signing key is available,
  78. * <code>false</code> otherwise
  79. * @throws CanceledException
  80. * when signing was canceled (eg., user aborted when entering
  81. * passphrase)
  82. * @throws UnsupportedSigningFormatException
  83. * if a config is given and the wanted key format is not
  84. * supported
  85. */
  86. public abstract boolean canLocateSigningKey(@Nullable String gpgSigningKey,
  87. @NonNull PersonIdent committer,
  88. CredentialsProvider credentialsProvider, GpgConfig config)
  89. throws CanceledException, UnsupportedSigningFormatException;
  90. }