Tabnine Logo
SSHAuthenticator
Code IndexAdd Tabnine to your IDE (free)

How to use
SSHAuthenticator
in
com.cloudbees.jenkins.plugins.sshcredentials

Best Java code snippets using com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator (Showing top 20 results out of 315)

origin: org.jenkins-ci.plugins/ssh-credentials

/**
 * Adds a collection of credentials (they will be filtered with {@link SSHAuthenticator#matcher()} implicitly).
 *
 * @param col the collection of credentials.
 * @return {@code this} for method chaining.
 * @deprecated use {@link #withMatching(CredentialsMatcher, Iterable)} or {@link #withAll(Iterable)}
 */
@Deprecated
public SSHUserListBoxModel addCollection(Collection<? extends StandardUsernameCredentials> col) {
  withMatching(SSHAuthenticator.matcher(), col);
  return this;
}
origin: jenkinsci/ssh-plugin

private Session createSession(final PrintStream logger) throws JSchException, IOException, InterruptedException {
  final StandardUsernameCredentials user = lookupCredentialsById(credentialId);
  if (user == null) {
    String message = "Credentials with id '" + credentialId + "', no longer exist!";
    logger.println(message);
    throw new InterruptedException(message);
  }
  final JSchConnector connector = new JSchConnector(user.getUsername(), getResolvedHostname(), port);
  final SSHAuthenticator<JSchConnector, StandardUsernameCredentials> authenticator = SSHAuthenticator
      .newInstance(connector, user);
  authenticator.authenticate(new StreamTaskListener(logger, Charset.defaultCharset()));
  final Session session = connector.getSession();
  session.setServerAliveInterval(serverAliveInterval);
  final Properties config = new Properties();
  //TODO put this as configuration option instead of ignoring by default
  config.put("StrictHostKeyChecking", "no");
  session.setConfig(config);
  session.connect(timeout);
  return session;
}
origin: org.jenkins-ci.plugins/ssh-credentials

/**
 * @deprecated as of 0.3
 * Use {@link #authenticate(TaskListener)} and provide a listener to receive errors.
 */
public final boolean authenticate() {
  synchronized (lock) {
    if (canAuthenticate()) {
      try {
        authenticated = doAuthenticate();
      } catch (Throwable t) {
        Logger.getLogger(getClass().getName())
            .log(Level.WARNING, "Uncaught exception escaped doAuthenticate method", t);
        authenticated = false;
      }
    }
    return isAuthenticated() || Mode.BEFORE_CONNECT.equals(getAuthenticationMode());
  }
}
origin: org.jenkins-ci.plugins/ssh-credentials

/**
 * Authenticate the bound connection using the supplied credentials.
 *
 * @return For an {@link #getAuthenticationMode()} of {@link Mode#BEFORE_CONNECT} the return value is
 * always {@code true} otherwise the return value is {@code true} if and only if authentication was
 * successful.
 */
public final boolean authenticate(TaskListener listener) {
  setListener(listener);
  return authenticate();
}
origin: org.jenkins-ci.plugins/ssh-credentials

/**
 * @deprecated Use {@link #newInstance(Object, StandardUsernameCredentials)} instead.
 */
@Deprecated
public static SSHAuthenticator<Object, StandardUsernameCredentials> newInstance(Object connection, SSHUser user)
    throws InterruptedException, IOException {
  return newInstance(connection, (StandardUsernameCredentials) user, null);
}
origin: org.jenkins-ci.plugins/ssh-credentials

  factories = lookupFactories();
} catch (LinkageError e) {
  if (result != null && result.canAuthenticate()) {
    return result;
origin: org.jenkins-ci.plugins/ssh-credentials

/**
 * Creates an authenticator that may be able to authenticate the supplied connection with the supplied user.
 *
 * @param connection the connection to authenticate on.
 * @param user       the user to authenticate with.
 * @param <C>        the type of connection.
 * @param <U>        the type of user.
 * @return a {@link SSHAuthenticator} that may or may not be able to successfully authenticate.
 */
@NonNull
public static <C, U extends StandardUsernameCredentials> SSHAuthenticator<C, U> newInstance(@NonNull C connection,
                                              @NonNull U user)
    throws InterruptedException, IOException {
  return newInstance(connection, user, null);
}
origin: org.jenkins-ci.plugins/ssh-credentials

/**
 * Adds all the system-scoped credentials (they will be filtered with {@link SSHAuthenticator#matcher()}
 * implicitly).
 * <p>
 * These credentials are meant to be used for system configuration and other things scoped to the {@link Jenkins}
 * object,
 * such as slaves.
 * </p>
 *
 * @param domainRequirements the domain requirements
 * @return {@code this} for method chaining.
 */
public SSHUserListBoxModel withSystemScopeCredentials(DomainRequirement... domainRequirements) {
  return withSystemScopeCredentials(SSHAuthenticator.matcher(), domainRequirements);
}
origin: org.jenkins-ci.plugins/ssh-slaves

  throw new AbortException("Cannot find SSH User credentials with id: " + credentialsId);
if (SSHAuthenticator.newInstance(connection, credentials).authenticate(listener)
    && connection.isAuthenticationComplete()) {
  logger.println(Messages.SSHLauncher_AuthenticationSuccessful(getTimestamp()));
origin: org.jenkins-ci.plugins/ssh-credentials

/**
 * Adds all the system-scoped credentials (they will be filtered with {@link SSHAuthenticator#matcher()}
 * implicitly).
 * <p>
 * These credentials are meant to be used for system configuration and other things scoped to the {@link Jenkins}
 * object,
 * such as slaves.
 * </p>
 *
 * @param domainRequirements the domain requirements
 * @return {@code this} for method chaining.
 */
public SSHUserListBoxModel withSystemScopeCredentials(List<DomainRequirement> domainRequirements) {
  return withSystemScopeCredentials(SSHAuthenticator.matcher(), domainRequirements);
}
origin: jenkinsci/git-client-plugin

  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;
origin: org.jenkins-ci.plugins/ssh-credentials

/**
 * Filters {@link Credentials} returning only those which are supported with the specified type of connection.
 *
 * @param credentials     the credentials to filter.
 * @param connectionClass the type of connection to filter for.
 * @return a list of {@link SSHUser} credentials appropriate for use with the supplied type of connection.
 * @deprecated Use
 * {@link CredentialsMatchers#filter(List, CredentialsMatcher)}
 * and {@link #matcher(Class)}
 */
public static List<? extends StandardUsernameCredentials> filter(Iterable<? extends Credentials> credentials,
                                 Class<?> connectionClass) {
  List<StandardUsernameCredentials> result = new ArrayList<StandardUsernameCredentials>();
  CredentialsMatcher matcher = matcher(connectionClass);
  for (Credentials credential : credentials) {
    if (credential instanceof StandardUsernameCredentials && matcher.matches(credential)) {
      result.add((StandardUsernameCredentials) credential);
    }
  }
  return result;
}
origin: jenkinsci/ssh-slaves-plugin

  throw new AbortException("Cannot find SSH User credentials with id: " + credentialsId);
if (SSHAuthenticator.newInstance(connection, credentials).authenticate(listener)
    && connection.isAuthenticationComplete()) {
  logger.println(Messages.SSHLauncher_AuthenticationSuccessful(getTimestamp()));
origin: org.jenkins-ci.plugins/ssh-slaves

public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,
                      @QueryParameter String value) {
  AccessControlled _context =
      (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
  if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) {
    return FormValidation.ok(); // no need to alarm a user that cannot configure
  }
  for (ListBoxModel.Option o : CredentialsProvider.listCredentials(StandardUsernameCredentials.class, context, ACL.SYSTEM,
      Collections.<DomainRequirement>singletonList(SSHLauncher.SSH_SCHEME),
      SSHAuthenticator.matcher(Connection.class))) {
    if (StringUtils.equals(value, o.value)) {
      return FormValidation.ok();
    }
  }
  return FormValidation.error(Messages.SSHLauncher_SelectedCredentialsMissing());
}
origin: jenkinsci/ssh-slaves-plugin

public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,
                      @QueryParameter String value) {
  AccessControlled _context =
      (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
  if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) {
    return FormValidation.ok(); // no need to alarm a user that cannot configure
  }
  for (ListBoxModel.Option o : CredentialsProvider.listCredentials(StandardUsernameCredentials.class, context, ACL.SYSTEM,
      Collections.singletonList(SSHLauncher.SSH_SCHEME),
      SSHAuthenticator.matcher(Connection.class))) {
    if (StringUtils.equals(value, o.value)) {
      return FormValidation.ok();
    }
  }
  return FormValidation.error(Messages.SSHLauncher_SelectedCredentialsMissing());
}
origin: org.jenkins-ci.plugins/ssh-slaves

public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,
                      @QueryParameter String host,
                      @QueryParameter String port,
                      @QueryParameter String value) {
  AccessControlled _context =
      (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
  if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) {
    return FormValidation.ok(); // no need to alarm a user that cannot configure
  }
  try {
    int portValue = Integer.parseInt(port);
    for (ListBoxModel.Option o : CredentialsProvider
        .listCredentials(StandardUsernameCredentials.class, context, ACL.SYSTEM,
            Collections.<DomainRequirement>singletonList(
                new HostnamePortRequirement(host, portValue)
            ),
            SSHAuthenticator.matcher(Connection.class))) {
      if (StringUtils.equals(value, o.value)) {
        return FormValidation.ok();
      }
    }
  } catch (NumberFormatException e) {
    return FormValidation.warning(e, Messages.SSHLauncher_PortNotANumber());
  }
  return FormValidation.error(Messages.SSHLauncher_SelectedCredentialsMissing());
}
origin: jenkinsci/ssh-slaves-plugin

public FormValidation doCheckCredentialsId(@AncestorInPath ItemGroup context,
                      @AncestorInPath AccessControlled _context,
                      @QueryParameter String host,
                      @QueryParameter String port,
                      @QueryParameter String value) {
  Jenkins jenkins = Jenkins.getInstance();
  if ((_context == jenkins && !jenkins.hasPermission(Computer.CREATE)) || (_context != jenkins && !_context.hasPermission(Computer.CONFIGURE))) {
    return FormValidation.ok(); // no need to alarm a user that cannot configure
  }
  try {
    int portValue = Integer.parseInt(port);
    for (ListBoxModel.Option o : CredentialsProvider
        .listCredentials(StandardUsernameCredentials.class, context, ACL.SYSTEM,
            Collections.singletonList(
                new HostnamePortRequirement(host, portValue)
            ),
            SSHAuthenticator.matcher(Connection.class))) {
      if (StringUtils.equals(value, o.value)) {
        return FormValidation.ok();
      }
    }
  } catch (NumberFormatException e) {
    return FormValidation.warning(e, Messages.SSHLauncher_PortNotANumber());
  }
  return FormValidation.error(Messages.SSHLauncher_SelectedCredentialsMissing());
}
origin: jenkinsci/jclouds-plugin

public ListBoxModel doFillAdminCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String currentValue) {
  if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()).hasPermission(Computer.CONFIGURE)) {
    return new StandardUsernameListBoxModel().includeCurrentValue(currentValue);
  }
  return new StandardUsernameListBoxModel().includeMatchingAs(
      ACL.SYSTEM, context, StandardUsernameCredentials.class,
      Collections.<DomainRequirement>singletonList(SSHLauncher.SSH_SCHEME),
      SSHAuthenticator.matcher(Connection.class)).includeCurrentValue(currentValue);
}
origin: jenkinsci/jclouds-plugin

public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String currentValue) {
  if (!(context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()).hasPermission(Computer.CONFIGURE)) {
    return new StandardUsernameListBoxModel().includeCurrentValue(currentValue);
  }
  return new StandardUsernameListBoxModel().includeMatchingAs(
      ACL.SYSTEM, context, StandardUsernameCredentials.class,
      Collections.<DomainRequirement>singletonList(SSHLauncher.SSH_SCHEME),
      SSHAuthenticator.matcher(Connection.class)).includeCurrentValue(currentValue);
}
origin: jenkinsci/ssh-slaves-plugin

public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String credentialsId) {
  AccessControlled _context = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
  if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) {
    return new StandardUsernameListBoxModel()
        .includeCurrentValue(credentialsId);
  }
  return new StandardUsernameListBoxModel()
      .includeMatchingAs(
          ACL.SYSTEM,
          context,
          StandardUsernameCredentials.class,
          Collections.singletonList(SSHLauncher.SSH_SCHEME),
          SSHAuthenticator.matcher(Connection.class)
      )
      .includeCurrentValue(credentialsId);
}
com.cloudbees.jenkins.plugins.sshcredentialsSSHAuthenticator

Javadoc

Abstraction for something that can authenticate an SSH connection.

Most used methods

  • matcher
    Creates a CredentialsMatcher for the specific type of connection.
  • authenticate
    Authenticate the bound connection using the supplied credentials.
  • newInstance
    Creates an authenticator that may be able to authenticate the supplied connection with the supplied
  • canAuthenticate
    Returns true if the bound connection is in a state where authentication can be tried using the suppl
  • doAuthenticate
    SPI for authenticating the bound connection using the supplied credentials. As a guideline, authenti
  • getAuthenticationMode
    Returns the mode of authentication that this SSHAuthenticator supports.
  • getUser
    Gets the supplied credentials.
  • isAuthenticated
    Returns true if the bound connection has been authenticated.
  • isSupported
    Returns true if and only if the supplied connection class and user class are supported by at least o
  • lookupFactories
    This method allows a build agent to invoke #newInstance(Object,StandardUsernameCredentials,String)af
  • setListener
    Sets the TaskListener that receives errors that happen during the authentication. If you are doing t
  • setListener

Popular in Java

  • Reactive rest calls using spring rest template
  • onRequestPermissionsResult (Fragment)
  • addToBackStack (FragmentTransaction)
  • getResourceAsStream (ClassLoader)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • JFrame (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now