Java 类com.jcraft.jsch.IdentityRepository 实例源码

项目:incubator-netbeans    文件:JGitSshSessionFactory.java   
private boolean setupJSchIdentityRepository (JSch jsch, String identityFile, boolean preferAgent) throws JSchException {
    boolean agentUsed = false;
    if (preferAgent) {
        Connector con = ConnectorFactory.getInstance().createConnector(ConnectorFactory.ConnectorKind.ANY);
        if (con != null) {
            IdentityRepository irepo = new IdentityRepositoryImpl(con);
            if (irepo.getStatus() == IdentityRepository.RUNNING) {
                jsch.setIdentityRepository(irepo);
                agentUsed = true;
            }
        }
    }
    if (!agentUsed) {
        jsch.setIdentityRepository(null);
        // remove all identity files
        jsch.removeAllIdentity();
        // and add the one specified by CredentialsProvider
        jsch.addIdentity(identityFile);
    }
    return agentUsed;
}
项目:incubator-netbeans    文件:JGitSshSessionFactory.java   
@Override
public int getStatus () {
    return connector.isAvailable() && proxy.isRunning()
            ? IdentityRepository.RUNNING : IdentityRepository.UNAVAILABLE;
}