• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CredentialsProviderUserInfo类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.eclipse.jgit.transport.CredentialsProviderUserInfo的典型用法代码示例。如果您正苦于以下问题:Java CredentialsProviderUserInfo类的具体用法?Java CredentialsProviderUserInfo怎么用?Java CredentialsProviderUserInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

CredentialsProviderUserInfo类属于org.eclipse.jgit.transport包,在下文中一共展示了CredentialsProviderUserInfo类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: configureCommand

点赞 2

import org.eclipse.jgit.transport.CredentialsProviderUserInfo; //导入依赖的package包/类
/**
 * 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) {
    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);
                }
            }
        });
    }
}
 

开发者ID:fabric8io,
项目名称:fabric8-devops,
代码行数:42,
代码来源:GitHelpers.java

示例2: configure

点赞 2

import org.eclipse.jgit.transport.CredentialsProviderUserInfo; //导入依赖的package包/类
@Override
protected void configure(OpenSshConfig.Host host, Session session) {
    session.setConfig("StrictHostKeyChecking", "no"); // TODO Find out how to enable strict host checking

    // TODO Delete me
    // String knownHostsLocation = "/sdcard/morg/known_hosts";
    // jSch.setKnownHosts(knownHostsLocation);

    CredentialsProvider provider = new JGitCredentialsProvider(username, password);
    session.setUserInfo(new CredentialsProviderUserInfo(session, provider));
}
 

开发者ID:hdweiss,
项目名称:mOrgAnd,
代码行数:12,
代码来源:JGitConfigSessionFactory.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)