@Override public ConnectFuture connect( HostConfigEntry hostConfig, AttributeRepository context, SocketAddress localAddress) throws IOException { Objects.requireNonNull(hostConfig, "No host configuration"); String host = ValidateUtils.checkNotNullAndNotEmpty(hostConfig.getHostName(), "No target host"); int port = hostConfig.getPort(); ValidateUtils.checkTrue(port > 0, "Invalid port: %d", port); Collection<String> hostIds = hostConfig.getIdentities(); Collection<PathResource> idFiles = GenericUtils.isEmpty(hostIds) ? Collections.emptyList() : hostIds.stream() .map(Paths::get) .map(PathResource::new) .collect(Collectors.toCollection(() -> new ArrayList<>(hostIds.size()))); KeyIdentityProvider keys = preloadClientIdentities(idFiles); return doConnect(hostConfig.getUsername(), new InetSocketAddress(host, port), context, localAddress, keys, !hostConfig.isIdentitiesOnly()); }
/** * @param ids Global identities - ignored if {@code null}/empty or already * have configured identities * @return {@code true} if updated identities */ public boolean updateGlobalIdentities(Collection<String> ids) { if (GenericUtils.isEmpty(ids) || (GenericUtils.size(getIdentities()) > 0)) { return false; } for (String id : ids) { addIdentity(id); } return true; }
/** * @param ids Global identities - ignored if {@code null}/empty or already * have configured identities * @return {@code true} if updated identities */ public boolean updateGlobalIdentities(Collection<String> ids) { if (GenericUtils.isEmpty(ids) || (GenericUtils.size(getIdentities()) > 0)) { return false; } for (String id : ids) { addIdentity(id); } return true; }
@Override public ConnectFuture connect(HostConfigEntry hostConfig, SocketAddress localAddress) throws IOException { Objects.requireNonNull(hostConfig, "No host configuration"); String host = ValidateUtils.checkNotNullAndNotEmpty(hostConfig.getHostName(), "No target host"); int port = hostConfig.getPort(); ValidateUtils.checkTrue(port > 0, "Invalid port: %d", port); Collection<KeyPair> keys = loadClientIdentities(hostConfig.getIdentities(), IoUtils.EMPTY_LINK_OPTIONS); return doConnect(hostConfig.getUsername(), new InetSocketAddress(host, port), localAddress, keys, !hostConfig.isIdentitiesOnly()); }
public <A extends Appendable> A append(A sb) throws IOException { sb.append(HOST_CONFIG_PROP).append(' ').append(ValidateUtils.checkNotNullAndNotEmpty(getHost(), "No host pattern")).append(IoUtils.EOL); appendNonEmptyProperty(sb, HOST_NAME_CONFIG_PROP, getHostName()); appendNonEmptyPort(sb, PORT_CONFIG_PROP, getPort()); appendNonEmptyProperty(sb, USER_CONFIG_PROP, getUsername()); appendNonEmptyValues(sb, IDENTITY_FILE_CONFIG_PROP, getIdentities()); if (exclusiveIdentites != null) { appendNonEmptyProperty(sb, EXCLUSIVE_IDENTITIES_CONFIG_PROP, ConfigFileReaderSupport.yesNoValueOf(exclusiveIdentites)); } appendNonEmptyProperties(sb, getProperties()); return sb; }
public <A extends Appendable> A append(A sb) throws IOException { sb.append(HOST_CONFIG_PROP).append(' ').append(ValidateUtils.checkNotNullAndNotEmpty(getHost(), "No host pattern")).append(IoUtils.EOL); appendNonEmptyProperty(sb, HOST_NAME_CONFIG_PROP, getHostName()); appendNonEmptyPort(sb, PORT_CONFIG_PROP, getPort()); appendNonEmptyProperty(sb, USER_CONFIG_PROP, getUsername()); appendNonEmptyValues(sb, IDENTITY_FILE_CONFIG_PROP, getIdentities()); if (exclusiveIdentites != null) { appendNonEmptyProperty(sb, EXCLUSIVE_IDENTITIES_CONFIG_PROP, ConfigFileReaderSupport.yesNoValueOf(exclusiveIdentites)); } appendNonEmptyProperties(sb, getProperties()); return sb; }
List<Path> identities = hostConfig.getIdentities().stream() .map(s -> { try {
Collection<String> ids = entry.getIdentities(); if (GenericUtils.isEmpty(ids)) { return normal;
/** * Updates the values that are <U>not</U> already configured with those * from the global entry * * @param globalEntry The global entry - ignored if {@code null} or * same reference as this entry * @return {@code true} if anything updated */ public boolean processGlobalValues(HostConfigEntry globalEntry) { if ((globalEntry == null) || (this == globalEntry)) { return false; } boolean modified = false; /* * NOTE !!! DO NOT TRY TO CHANGE THE ORDER OF THE OR-ing AS IT * WOULD CAUSE INVALID CODE EXECUTION */ modified = updateGlobalPort(globalEntry.getPort()) || modified; modified = updateGlobalHostName(globalEntry.getHostName()) || modified; modified = updateGlobalUserName(globalEntry.getUsername()) || modified; modified = updateGlobalIdentities(globalEntry.getIdentities()) || modified; modified = updateGlobalIdentityOnly(globalEntry.isIdentitiesOnly()) || modified; Map<String, String> updated = updateGlobalProperties(globalEntry.getProperties()); modified = (GenericUtils.size(updated) > 0) || modified; return modified; }
/** * Updates the values that are <U>not</U> already configured with those * from the global entry * * @param globalEntry The global entry - ignored if {@code null} or * same reference as this entry * @return {@code true} if anything updated */ public boolean processGlobalValues(HostConfigEntry globalEntry) { if ((globalEntry == null) || (this == globalEntry)) { return false; } boolean modified = false; /* * NOTE !!! DO NOT TRY TO CHANGE THE ORDER OF THE OR-ing AS IT * WOULD CAUSE INVALID CODE EXECUTION */ modified = updateGlobalPort(globalEntry.getPort()) || modified; modified = updateGlobalHostName(globalEntry.getHostName()) || modified; modified = updateGlobalUserName(globalEntry.getUsername()) || modified; modified = updateGlobalIdentities(globalEntry.getIdentities()) || modified; modified = updateGlobalIdentityOnly(globalEntry.isIdentitiesOnly()) || modified; Map<String, String> updated = updateGlobalProperties(globalEntry.getProperties()); modified = (GenericUtils.size(updated) > 0) || modified; return modified; }
Collection<String> ids = entry.getIdentities(); if (GenericUtils.isEmpty(ids)) { return normal;