本文整理汇总了Java中com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator类的典型用法代码示例。如果您正苦于以下问题:Java SSHAuthenticator类的具体用法?Java SSHAuthenticator怎么用?Java SSHAuthenticator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SSHAuthenticator类属于com.cloudbees.jenkins.plugins.sshcredentials包,在下文中一共展示了SSHAuthenticator类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFillCredentialsIdItems
import com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator; //导入依赖的package包/类
public static ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) {
AccessControlled ac = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
if (!ac.hasPermission(Jenkins.ADMINISTER)) {
return new ListBoxModel();
}
return new SSHUserListBoxModel().withMatching(
SSHAuthenticator.matcher(Connection.class),
CredentialsProvider.lookupCredentials(
StandardUsernameCredentials.class,
context,
ACL.SYSTEM,
SSHLauncher.SSH_SCHEME)
);
}
示例2: doFillCredentialsIdItems
import com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator; //导入依赖的package包/类
public static ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) {
return new SSHUserListBoxModel().withMatching(
SSHAuthenticator.matcher(Connection.class),
CredentialsProvider.lookupCredentials(
StandardUsernameCredentials.class,
context,
ACL.SYSTEM,
SSHLauncher.SSH_SCHEME)
);
}
示例3: doFillCredentialsIdItems
import com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) {
AccessControlled ac = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
if (!ac.hasPermission(Jenkins.ADMINISTER)) {
return new ListBoxModel();
}
return new SSHUserListBoxModel().withMatching(SSHAuthenticator.matcher(Connection.class),
CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, context,
ACL.SYSTEM, SSHLauncher.SSH_SCHEME));
}
示例4: getSession
import com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public RemoteSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException {
try {
int p = uri.getPort();
if (p<0) p = 22;
Connection con = new Connection(uri.getHost(), p);
con.setTCPNoDelay(true);
con.connect(); // TODO: host key check
boolean authenticated;
if (credentialsProvider instanceof SmartCredentialsProvider) {
final SmartCredentialsProvider smart = (SmartCredentialsProvider) credentialsProvider;
StandardUsernameCredentialsCredentialItem
item = new StandardUsernameCredentialsCredentialItem("Credentials for " + uri, false);
authenticated = smart.supports(item)
&& smart.get(uri, item)
&& SSHAuthenticator.newInstance(con, item.getValue(), uri.getUser())
.authenticate(smart.listener);
} else if (credentialsProvider instanceof CredentialsProviderImpl) {
CredentialsProviderImpl sshcp = (CredentialsProviderImpl) credentialsProvider;
authenticated = SSHAuthenticator.newInstance(con, sshcp.cred).authenticate(sshcp.listener);
} else {
authenticated = false;
}
if (!authenticated && con.isAuthenticationComplete())
throw new TransportException("Authentication failure");
return wrap(con);
} catch (UnsupportedCredentialItem | IOException | InterruptedException e) {
throw new TransportException(uri,"Failed to connect",e);
}
}