1

JGit used to rely on JSch as its transport provider, but changed because JSch does not accept certain keys, including some OpenSSH ones.

If you are using a passphrase-encrypted key with JGit, the recommended approach with JSch used to be to override a configuration callback, as shown in this blog article.

The alternative is to set a shared session factory and this also what the Apache MINA team recommends with a pointer to the cost of creating sessions on demand.

However, my issue with this is that it sets a specific provider for the whole system scope. Consequently, I would like to implement TransportConfigCallback. Ultimately, this requires to adapt SshSessionFactory to MINA's session initialization code and produce a RemoteSession.

Has anyone done this or seen any boilerplate code?

Jörn Guy Süß
  • 1,408
  • 11
  • 18

1 Answers1

0

Self answer after some research: The interface to MINA in JGit is deliberately set closed. The driver only accepts a regular Git configuration directory. And this is the key to configuring the system:

  • Provide a different git configuration directory for each user.
  • Provide regular git configuration (git config) files underneath for all special settings
  • JGit has classes to write Git configurations, so you do not need to write any parsing and serialisation code.

I will update this answer with pertinent links to the classes and source code locations involved.

From version 5.5 the factory can be configured for this usecase. See NoFilesSshTest.java for details on how to use a database to provide connection information.

Jörn Guy Süß
  • 1,408
  • 11
  • 18