use of org.eclipse.jgit.transport.CredentialsProviderUserInfo in project Android-Password-Store by zeapo.
the class SshConfigSessionFactory method configure.
@Override
protected void configure(OpenSshConfig.Host hc, Session session) {
session.setConfig("StrictHostKeyChecking", "no");
session.setConfig("PreferredAuthentications", "publickey,password");
CredentialsProvider provider = new CredentialsProvider() {
@Override
public boolean isInteractive() {
return false;
}
@Override
public boolean supports(CredentialItem... items) {
return true;
}
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
for (CredentialItem item : items) {
if (item instanceof CredentialItem.Username) {
((CredentialItem.Username) item).setValue(username);
continue;
}
if (item instanceof CredentialItem.StringType) {
((CredentialItem.StringType) item).setValue(passphrase);
}
}
return true;
}
};
UserInfo userInfo = new CredentialsProviderUserInfo(session, provider);
session.setUserInfo(userInfo);
}
use of org.eclipse.jgit.transport.CredentialsProviderUserInfo in project MGit by maks.
the class SGitSessionFactory method configure.
@Override
protected void configure(Host host, Session session) {
session.setConfig("StrictHostKeyChecking", "no");
session.setConfig("PreferredAuthentications", "publickey,password");
// Awful use of App singleton but not really any other way to get hold of a provider that needs
// to have been initialised with an Android context
UserInfo userInfo = new CredentialsProviderUserInfo(session, SGitApplication.getJschCredentialsProvider());
session.setUserInfo(userInfo);
}
use of org.eclipse.jgit.transport.CredentialsProviderUserInfo in project egit by eclipse.
the class EclipseSshSessionFactory method configure.
@Override
protected void configure(final OpenSshConfig.Host hc, final Session session) {
UserInfo userInfo = session.getUserInfo();
if (!hc.isBatchMode() && userInfo == null) {
final CredentialsProvider cp = CredentialsProvider.getDefault();
session.setUserInfo(new CredentialsProviderUserInfo(session, cp));
}
}
use of org.eclipse.jgit.transport.CredentialsProviderUserInfo in project fabric8 by fabric8io.
the class GitUtils method configureCommand.
/**
* Configures the transport of the command to deal with things like SSH
*/
public static <C extends GitCommand> void configureCommand(TransportCommand<C, ?> command, CredentialsProvider credentialsProvider, final File sshPrivateKey, final File sshPublicKey) {
LOG.info("Using " + credentialsProvider);
if (sshPrivateKey != null) {
final CredentialsProvider provider = credentialsProvider;
command.setTransportConfigCallback(new TransportConfigCallback() {
@Override
public void configure(Transport transport) {
if (transport instanceof SshTransport) {
SshTransport sshTransport = (SshTransport) transport;
SshSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
@Override
protected void configure(OpenSshConfig.Host host, Session session) {
session.setConfig("StrictHostKeyChecking", "no");
UserInfo userInfo = new CredentialsProviderUserInfo(session, provider);
session.setUserInfo(userInfo);
}
@Override
protected JSch createDefaultJSch(FS fs) throws JSchException {
JSch jsch = super.createDefaultJSch(fs);
jsch.removeAllIdentity();
String absolutePath = sshPrivateKey.getAbsolutePath();
if (LOG.isDebugEnabled()) {
LOG.debug("Adding identity privateKey: " + sshPrivateKey + " publicKey: " + sshPublicKey);
}
if (sshPublicKey != null) {
jsch.addIdentity(absolutePath, sshPublicKey.getAbsolutePath(), null);
} else {
jsch.addIdentity(absolutePath);
}
return jsch;
}
};
sshTransport.setSshSessionFactory(sshSessionFactory);
}
}
});
}
}
Aggregations