Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.signing.ssh

public Class SshSigner

extends Object
implements Signer
Class Inheritance
All Implemented Interfaces
org.eclipse.jgit.lib.Signer
Imports
java.io.BufferedReader, .ByteArrayOutputStream, .File, .IOException, .InputStreamReader, .StreamCorruptedException, .StringReader, java.nio.file.Files, .Path, java.security.GeneralSecurityException, .KeyPair, .MessageDigest, .NoSuchAlgorithmException, .PrivateKey, .PublicKey, java.text.MessageFormat, java.util.AbstractMap.SimpleImmutableEntry, .Collection, .List, .Map, .Map.Entry, org.apache.sshd.client.auth.pubkey.PublicKeyIdentity, org.apache.sshd.common.config.keys.AuthorizedKeyEntry, .KeyUtils, .OpenSshCertificate, .PublicKeyEntryResolver, org.apache.sshd.common.config.keys.loader.KeyPairResourceParser, org.apache.sshd.common.keyprovider.KeyPairProvider, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.signature.BuiltinSignatures, .Signature, org.apache.sshd.common.util.buffer.Buffer, .ByteArrayBuffer, org.apache.sshd.common.util.security.SecurityUtils, org.eclipse.jgit.annotations.NonNull, org.eclipse.jgit.api.errors.CanceledException, .UnsupportedSigningFormatException, org.eclipse.jgit.internal.transport.sshd.AuthenticationCanceledException, .PasswordProviderWrapper, .SshdText, org.eclipse.jgit.internal.transport.sshd.agent.SshAgentClient, org.eclipse.jgit.lib.GpgConfig, .GpgSignature, .PersonIdent, .Repository, .Signer, org.eclipse.jgit.transport.CredentialsProvider, org.eclipse.jgit.transport.sshd.KeyPasswordProviderFactory, org.eclipse.jgit.transport.sshd.agent.Connector, .ConnectorFactory, org.eclipse.jgit.util.Base64, .FS, .FS.ExecutionResult, .StringUtils, .SystemReader, .TemporaryBuffer, org.slf4j.Logger, .LoggerFactory

A Signer to create SSH signatures.
See Also
PROTOCOL.sshsig

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final int
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static GpgSignature
armor(byte[] data)

public boolean
canLocateSigningKey(Repository
the current Repository
repository
,
GpgConfig
GPG settings from the git config
config
,
PersonIdent
the signing identity (to help with key lookup in case signing key is not specified)
committer
,
String
if non-null overrides the signing key from the config
signingKey
,
CredentialsProvider
provider to use when querying for signing key credentials (eg. passphrase)
credentialsProvider
)

Implements org.eclipse.jgit.lib.Signer.canLocateSigningKey.

Indicates if a signing key is available for the specified committer and/or signing key.

private static String
private static PublicKey
private static PublicKeyIdentity
getIdentity(String signingKey, PersonIdent committer, CredentialsProvider credentials)

private static File
getPrivateKeyFile(File directory, String publicKeyName)

private static KeyPair
public GpgSignature
sign(Repository
Repository the signature is created in
repository
,
GpgConfig
GPG settings from the git config
config
,
byte[]
the data to sign
data
,
PersonIdent
the signing identity (to help with key lookup in case signing key is not specified)
committer
,
String
if non-null overrides the signing key from the config
signingKey
,
CredentialsProvider
provider to use when querying for signing key credentials (eg. passphrase)
credentialsProvider
)

Implements org.eclipse.jgit.lib.Signer.sign.

Signs arbitrary data.

private static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

GIT_KEY_PREFIXback to summary
private static final String GIT_KEY_PREFIX
LINE_LENGTHback to summary
private static final int LINE_LENGTH
LOGback to summary
private static final Logger LOG

Constructor Detail

SshSignerback to summary
public SshSigner()

Method Detail

armorback to summary
private static GpgSignature armor(byte[] data) throws IOException
canLocateSigningKeyback to summary
public boolean canLocateSigningKey(Repository repository, GpgConfig config, PersonIdent committer, String signingKey, CredentialsProvider credentialsProvider) throws CanceledException

Implements org.eclipse.jgit.lib.Signer.canLocateSigningKey.

Doc from org.eclipse.jgit.lib.Signer.canLocateSigningKey.

Indicates if a signing key is available for the specified committer and/or signing key.

Parameters
repository:Repository

the current Repository

config:GpgConfig

GPG settings from the git config

committer:PersonIdent

the signing identity (to help with key lookup in case signing key is not specified)

signingKey:String

if non-null overrides the signing key from the config

credentialsProvider:CredentialsProvider

provider to use when querying for signing key credentials (eg. passphrase)

Returns:boolean

true if a signing key is available, false otherwise

Annotations
@Override
Exceptions
CanceledException:
when signing was canceled (eg., user aborted when entering passphrase)
defaultKeyCommandback to summary
private static String defaultKeyCommand(Repository repository, GpgConfig config) throws IOException
fromEntryback to summary
private static PublicKey fromEntry(List<AuthorizedKeyEntry> entries) throws GeneralSecurityException, IOException
getIdentityback to summary
private static PublicKeyIdentity getIdentity(String signingKey, PersonIdent committer, CredentialsProvider credentials) throws CanceledException, GeneralSecurityException, IOException
getPrivateKeyFileback to summary
private static File getPrivateKeyFile(File directory, String publicKeyName)
loadPrivateKeyback to summary
private static KeyPair loadPrivateKey(Path path, CredentialsProvider credentials) throws CanceledException, GeneralSecurityException, IOException
signback to summary
public GpgSignature sign(Repository repository, GpgConfig config, byte[] data, PersonIdent committer, String signingKey, CredentialsProvider credentialsProvider) throws CanceledException, IOException, UnsupportedSigningFormatException

Implements org.eclipse.jgit.lib.Signer.sign.

Doc from org.eclipse.jgit.lib.Signer.sign.

Signs arbitrary data.

Parameters
repository:Repository

Repository the signature is created in

config:GpgConfig

GPG settings from the git config

data:byte[]

the data to sign

committer:PersonIdent

the signing identity (to help with key lookup in case signing key is not specified)

signingKey:String

if non-null overrides the signing key from the config

credentialsProvider:CredentialsProvider

provider to use when querying for signing key credentials (eg. passphrase)

Returns:GpgSignature

the signature for data

Annotations
@Override
Exceptions
CanceledException:
when signing was canceled (eg., user aborted when entering passphrase)
IOException:
if an I/O error occurs
UnsupportedSigningFormatException:
if a config is given and the wanted key format is not supported
toStringback to summary
private static String toString(TemporaryBuffer b)
org.eclipse.jgit.internal.signing.ssh back to summary

private Class SshSigner.AgentIdentity

extends KeyPairIdentity
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Map.Entry<String, byte[]>
sign(SessionContext
The SessionContext for calling this method - may be null if not called within a session context
session
,
String
Recommended signature algorithm - if null/empty then one will be selected based on the key type and/or signature factories

Note

even if specific algorithm specified, the implementation may disregard and choose another

algo
,
byte[]
Data to sign
data
)

Overrides org.eclipse.jgit.internal.signing.ssh.SshSigner.KeyPairIdentity.sign.

Implements org.apache.sshd.client.auth.pubkey.PublicKeyIdentity.sign.

Proves the public key identity by signing the given data

Inherited from org.eclipse.jgit.internal.signing.ssh.SshSigner.KeyPairIdentity:
getKeyIdentity

Constructor Detail

AgentIdentityback to summary
pack-priv AgentIdentity(PublicKey publicKey)

Method Detail

signback to summary
public Map.Entry<String, byte[]> sign(SessionContext session, String algo, byte[] data) throws Exception

Overrides org.eclipse.jgit.internal.signing.ssh.SshSigner.KeyPairIdentity.sign.

Implements org.apache.sshd.client.auth.pubkey.PublicKeyIdentity.sign.

Doc from org.apache.sshd.client.auth.pubkey.PublicKeyIdentity.sign.

Proves the public key identity by signing the given data

Parameters
session:SessionContext

The SessionContext for calling this method - may be null if not called within a session context

algo:String

Recommended signature algorithm - if null/empty then one will be selected based on the key type and/or signature factories

Note

even if specific algorithm specified, the implementation may disregard and choose another

data:byte[]

Data to sign

Returns:Map.Entry<String, byte[]>

used algorithm + signed data - using the identity

Annotations
@Override
Exceptions
Exception:
If failed to sign the data
org.eclipse.jgit.internal.signing.ssh back to summary

private Class SshSigner.KeyPairIdentity

extends Object
implements PublicKeyIdentity
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.internal.signing.ssh.SshSigner.KeyPairIdentity
All Implemented Interfaces
org.apache.sshd.client.auth.pubkey.PublicKeyIdentity
Known Direct Subclasses
org.eclipse.jgit.internal.signing.ssh.SshSigner.AgentIdentity

Field Summary

Modifier and TypeField and Description
private final KeyPair

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public KeyPair
public Map.Entry<String, byte[]>
sign(SessionContext
The SessionContext for calling this method - may be null if not called within a session context
session
,
String
Recommended signature algorithm - if null/empty then one will be selected based on the key type and/or signature factories

Note

even if specific algorithm specified, the implementation may disregard and choose another

algo
,
byte[]
Data to sign
data
)

Implements org.apache.sshd.client.auth.pubkey.PublicKeyIdentity.sign.

Proves the public key identity by signing the given data

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

pairback to summary
private final KeyPair pair
Annotations
@NonNull

Constructor Detail

KeyPairIdentityback to summary
pack-priv KeyPairIdentity(KeyPair pair)

Method Detail

getKeyIdentityback to summary
public KeyPair getKeyIdentity()

Implements org.apache.sshd.client.auth.pubkey.PublicKeyIdentity.getKeyIdentity.

Returns:KeyPair

Doc from org.apache.sshd.client.auth.pubkey.PublicKeyIdentity.getKeyIdentity.

The KeyPair identity value

Annotations
@Override
signback to summary
public Map.Entry<String, byte[]> sign(SessionContext session, String algo, byte[] data) throws Exception

Implements org.apache.sshd.client.auth.pubkey.PublicKeyIdentity.sign.

Doc from org.apache.sshd.client.auth.pubkey.PublicKeyIdentity.sign.

Proves the public key identity by signing the given data

Parameters
session:SessionContext

The SessionContext for calling this method - may be null if not called within a session context

algo:String

Recommended signature algorithm - if null/empty then one will be selected based on the key type and/or signature factories

Note

even if specific algorithm specified, the implementation may disregard and choose another

data:byte[]

Data to sign

Returns:Map.Entry<String, byte[]>

used algorithm + signed data - using the identity

Annotations
@Override
Exceptions
Exception:
If failed to sign the data