Jgitjava apigit Storehouse of warehouse, by eclipse company maintenance. he provided apiapi is a direct role in the low-level warehouse objects, high-level api
jgit mainly through ssh and http (S)
(1)HTTPS- https://example.com/repo.git
Clonecommand Clonecommand = git.clonereposity ();
Clonecommand through the Setcredentialsprovider () method, by assigning a Usernamepasswordcredentialsprovider object, To provide user name and password login.
(It is not recommended to use HTTP, but it is also possible)
(2) SSH with public Key-
Links that are actually accessed through the public key:
[Email Protected]***.***.***/user/***.git
SSH uses the public key to access the authentication information through the Jsch library. In Jgit, the abstract class of jschconfigsessionfactory is provided, and the code is as follows:
New jschconfigsessionfactory () {@Override protectedvoid/* release hos TKey check, also means that can accept unknown remote host files, this is not safe, this mode is only used for testing purposes. use SSH-KEYSCAN-T RSA hostname to collect host data. */session.setconfig ("stricthostkeychecking", "no");} ;
The following is the registration of the authentication information in the command:
New Transportconfigcall Back () {publicvoid Configure (Transporttransport) { Sshtransport Sshtransport=(sshtransport) transport;sshtransport.setsshsessionfactory (sshSessionFactory) ;}}
3) SSH with Password-ssh://[email Protected]/repo.git
Using the Jschconfigsessionfactory overridden in the Configure method above, set password, specifically not detailed.
Jgit two authentication methods used with remote warehouse links (SSH and HTTPS)