本文整理汇总了Java中com.jcraft.jsch.agentproxy.Connector类的典型用法代码示例。如果您正苦于以下问题:Java Connector类的具体用法?Java Connector怎么用?Java Connector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Connector类属于com.jcraft.jsch.agentproxy包,在下文中一共展示了Connector类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setupJSchIdentityRepository
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
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;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JGitSshSessionFactory.java
示例2: initSessionSshAgent
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
private Session initSessionSshAgent(String username, String socketPath, JSch jsch) throws JSchException {
final Session session = jsch.getSession(username, myHost, myPort);
session.setConfig("PreferredAuthentications", "publickey");
try {
ConnectorFactory cf = ConnectorFactory.getDefault();
cf.setUSocketPath(socketPath);
Connector con = cf.createConnector();
IdentityRepository irepo = new RemoteIdentityRepository(con);
jsch.setIdentityRepository(irepo);
return session;
} catch (AgentProxyException e) {
throw new JSchException("Failed to connect to ssh agent.", e);
}
}
开发者ID:JetBrains,项目名称:teamcity-deployer-plugin,代码行数:16,代码来源:SSHSessionProvider.java
示例3: JschSshClient
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
public JschSshClient(HostAndPort socket, LoginCredentials loginCredentials, int timeout, Optional<Connector> agentConnector,
BackoffLimitedRetryHandler backoffLimitedRetryHandler)
{
this.host = checkNotNull(socket, "host").getHost();
this.user = checkNotNull(loginCredentials, "credentials for %s", host).getUser();
checkArgument(socket.getPort() > 0, "ssh port must be greater than zero" + socket.getPort());
checkArgument(socket.getPort() < 65535, "ssh port must be less than 65535" + socket.getPort());
this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler");
connection = SshConnection.builder()
.hostAndPort(socket)
.loginCredentials(loginCredentials)
.connectionTimeout(timeout)
.agentConnector(agentConnector)
.build();
checkNotNull(connection);
}
开发者ID:alessandroleite,项目名称:dohko,代码行数:19,代码来源:JschSshClient.java
示例4: newSession
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
private Session newSession() throws JSchException {
JSch jSch = new JSch();
try {
jSch.setConfig("PreferredAuthentications", "publickey");
if (hostInfo.isDoHostKeyChecks()) {
jSch.setKnownHosts(userInfo.sshFolderLocation() + File.separator + "known_hosts");
} else {
jSch.setHostKeyRepository(new FakeHostKeyRepository());
}
if (userInfo.isUseAgentIdentities()) {
Connector connector = ConnectorFactory.getDefault().createConnector();
if (connector != null) {
IdentityRepository identityRepository = new RemoteIdentityRepository(connector);
jSch.setIdentityRepository(identityRepository);
}
}
// add private key to the IdentityRepository. If using agent identities, this will add the private
// key to the agent, if it is not already present.
jSch.addIdentity(userInfo.privateKeyLocation().getAbsolutePath());
session = jSch.getSession(userInfo.getUserName(), hostInfo.getHostname(), hostInfo.getPort());
Long timeout = TimeUnit.SECONDS.toMillis(hostInfo.getTimeoutSeconds());
session.setTimeout(timeout.intValue());
session.setUserInfo(new PasswordlessEnabledUser(userInfo.getPassphrase()));
return session;
} catch (JSchException | AgentProxyException e) {
String msg = ExecutionFailedException.userFriendlyCause(e.getMessage(), hostInfo.getHostname(), userInfo);
throw new ExecutionFailedException(msg, e);
}
}
开发者ID:RationaleEmotions,项目名称:SimpleSSH,代码行数:34,代码来源:JSchBackedSshKnowHowImpl.java
示例5: RemoteClient
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
public RemoteClient(Environment environment, DeploymentContext context, Logger logger) throws RemoteClientException {
RemoteClient instance = this;
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
instance.tryDisconnect();
}
});
this.logger = logger;
try {
JSch shellClient = new JSch();
shellClient.setKnownHosts(new FileInputStream(new File(System.getenv("HOME") + "/.ssh/known_hosts")));
ConnectorFactory connectorFactory = ConnectorFactory.getDefault();
Connector connector = connectorFactory.createConnector();
Properties config = new java.util.Properties();
config.put("PreferredAuthentications", "publickey");
if (context.project().options().containsKey("check_host_keys")) {
String option = (boolean) context.project().options().get("check_host_keys") ? "yes" : "no";
JSch.setConfig("StrictHostKeyChecking", option);
if (option.equals("no")) {
logger.warn("WARNING: host key check is disabled!");
}
}
if (connector != null) {
IdentityRepository remoteIdentityRepository = new RemoteIdentityRepository(connector);
shellClient.setIdentityRepository(remoteIdentityRepository);
}
for (Target target : environment.targets()) {
sessions.add(new RemoteTarget(connect(shellClient, target, context, config), target, context, environment));
}
} catch (AgentProxyException | FileNotFoundException | JSchException e) {
throw new RemoteClientException(e.getMessage());
}
}
开发者ID:mobilecashout,项目名称:osprey,代码行数:39,代码来源:RemoteClient.java
示例6: createSshAgentConnector
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
@Nullable
private static Connector createSshAgentConnector() {
Connector result = null;
try {
result = ConnectorFactory.getDefault().createConnector();
}
catch (AgentProxyException e) {
LOG.info("Could not create ssh agent connector", e);
}
return result;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:SvnInteractiveAuthenticationProvider.java
示例7: attemptAgentUse
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
/**
* Attempts to connect to a local SSH agent (using either UNIX sockets or PuTTY's Pageant)
*
* @param jsch
* Connection to be attached to an available local agent
* @return true if connected to agent, false otherwise
*/
private boolean attemptAgentUse(JSch jsch) {
try {
Connector con = ConnectorFactory.getDefault().createConnector();
jsch.setIdentityRepository(new RemoteIdentityRepository(con));
return true;
} catch (Exception e) {
Message.verbose(":: SSH :: Failure connecting to agent :: " + e.toString());
return false;
}
}
开发者ID:apache,项目名称:ant-ivy,代码行数:18,代码来源:SshCache.java
示例8: defaultSshClientFactory
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
public static SshClient.Factory defaultSshClientFactory()
{
return new SshClient.Factory()
{
int timeout = SystemUtils2.getIntegerProperty("org.excalibur.ssh.default.connection.timeout.ms", 60000);
Optional<Connector> agentConnector = getAgentConnector();
@Override
public boolean isAgentAvailable()
{
return agentConnector.isPresent();
}
@Override
public SshClient create(HostAndPort socket, LoginCredentials credentials)
{
return new JschSshClient(socket, credentials, timeout, agentConnector, new BackoffLimitedRetryHandler());
}
Optional<Connector> getAgentConnector()
{
try
{
return Optional.of(ConnectorFactory.getDefault().createConnector());
}
catch (final AgentProxyException e)
{
return Optional.absent();
}
}
};
}
开发者ID:alessandroleite,项目名称:dohko,代码行数:34,代码来源:SshClientFactory.java
示例9: SshConnection
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
private SshConnection(HostAndPort hostAndPort, LoginCredentials loginCredentials, Optional<Proxy> proxy, int connectTimeout, int sessionTimeout,
Optional<Connector> agentConnector)
{
this.hostAndPort_ = checkNotNull(hostAndPort);
this.loginCredentials_ = checkNotNull(loginCredentials, " login for %s", hostAndPort);
this.proxy_ = checkNotNull(proxy, " proxy for %s", hostAndPort);
this.connectTimeout_ = checkNotNull(connectTimeout);
this.sessionTimeout_ = checkNotNull(sessionTimeout);
this.agentConnector_ = checkNotNull(agentConnector, "agent connector for %s", hostAndPort);
}
开发者ID:alessandroleite,项目名称:dohko,代码行数:11,代码来源:SshConnection.java
示例10: IdentityRepositoryImpl
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
public IdentityRepositoryImpl (Connector connector) {
this.connector = connector;
this.proxy = new AgentProxy(connector);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:JGitSshSessionFactory.java
示例11: getAgentConnector
import com.jcraft.jsch.agentproxy.Connector; //导入依赖的package包/类
/**
* @return the agentConnector
*/
public Optional<Connector> getAgentConnector()
{
return agentConnector_;
}
开发者ID:alessandroleite,项目名称:dohko,代码行数:8,代码来源:SshConnection.java
注:本文中的com.jcraft.jsch.agentproxy.Connector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论