/** * 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(); }
/** * Creates a {@link CredentialsMatcher} for the specific type of connection. * * @param connectionClass the type of connection. * @return a {@link CredentialsMatcher} * @since 0.5 */ public static CredentialsMatcher matcher(Class<?> connectionClass) { return new Matcher(connectionClass); }
/** * 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); }
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)); } }
public ListBoxModel doFillCredentialIdItems(final @AncestorInPath ItemGroup<?> context) { final List<StandardUsernameCredentials> credentials = CredentialsProvider.lookupCredentials( StandardUsernameCredentials.class, context, ACL.SYSTEM, CredentialsSSHSite.NO_REQUIREMENTS); return new SSHUserListBoxModel().withEmptySelection().withMatching( SSHAuthenticator.matcher(JSchConnector.class), 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; }
/** * Same as {@link SSHUserPrivateKey#getPrivateKeys} but backward compatible for old implementations. * * @since 1.3 */ @SuppressWarnings("deprecation") public static List<String> getPrivateKeys(SSHUserPrivateKey user) { try { return user.getPrivateKeys(); } catch (AbstractMethodError x) { return Collections.singletonList(user.getPrivateKey()); } }
public boolean matches(Credentials item) { for (String key : SSHUserPrivateKey.class.cast(item).getPrivateKeys()) { if (pemKeyEquals(key, privkey)) { return true; } } return false; } }));
/** * @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); }
public synchronized Session getSession() { if (!hasSession()) { try { session = jsch.getSession(username, host, port); } catch (JSchException e) { throw new SSHAuthenticatorException(e); } } return session; }
public synchronized Session getSession() { if (!hasSession()) { try { session = jsch.getSession(username, host, port); } catch (JSchException e) { throw new SSHAuthenticatorException(e); } } return session; }
/** * 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> * * @return {@code this} for method chaining. */ public SSHUserListBoxModel withSystemScopeCredentials() { return withSystemScopeCredentials(Collections.<DomainRequirement>emptyList()); }
/** * @deprecated use {@link #with(com.cloudbees.plugins.credentials.common.IdCredentials)} */ @Deprecated public SSHUserListBoxModel add(StandardUsernameCredentials u) { with(u); return this; }
/** * Returns the username to authenticate as. * * @return the username to authenticate as. * @since 1.4 */ public String getUsername() { return username == null ? getUser().getUsername() : username; }
/** * Adds all the system-scoped credentials. * <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 matcher a matcher to filter the credentials * @param domainRequirements the domain requirements * @return {@code this} for method chaining. */ public SSHUserListBoxModel withSystemScopeCredentials(CredentialsMatcher matcher, List<DomainRequirement> domainRequirements) { includeMatchingAs(ACL.SYSTEM, Jenkins.getActiveInstance(), StandardUsernameCredentials.class, domainRequirements, matcher); return this; }
/** * 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); }
public static String getPrivateKey(final SSHUserPrivateKey supk) { if (null == supk) { return ""; } List<String> privateKeys = supk.getPrivateKeys(); return privateKeys.isEmpty() ? "" : privateKeys.get(0); }
/** * 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); }
/** * 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> * * @return {@code this} for method chaining. * @deprecated use {@link #withSystemScopeCredentials()} */ @Deprecated public SSHUserListBoxModel addSystemScopeCredentials() { return withSystemScopeCredentials(); }
/** * Adds all the system-scoped credentials. * <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 matcher a matcher to filter the credentials * @param domainRequirements the domain requirements * @return {@code this} for method chaining. */ public SSHUserListBoxModel withSystemScopeCredentials(CredentialsMatcher matcher, DomainRequirement... domainRequirements) { return withSystemScopeCredentials(matcher, Arrays.asList(domainRequirements)); }