You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2016/01/19 09:58:54 UTC
[2/4] mina-sshd git commit: [SSHD-607] Provide PasswordAuthenticator
that uses LDAP
[SSHD-607] Provide PasswordAuthenticator that uses LDAP
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/f374e72c
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/f374e72c
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/f374e72c
Branch: refs/heads/master
Commit: f374e72c59a63de8a65537111c3c10b487ed62c6
Parents: 458c38f
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Tue Jan 19 10:50:20 2016 +0200
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Tue Jan 19 10:50:20 2016 +0200
----------------------------------------------------------------------
pom.xml | 12 +-
.../java/org/apache/sshd/client/SshClient.java | 2 +-
.../java/org/apache/sshd/client/SshKeyScan.java | 2 +-
.../auth/hostbased/UserAuthHostBased.java | 2 +-
.../sshd/client/channel/ChannelDirectTcpip.java | 2 +-
.../client/session/AbstractClientSession.java | 2 +-
.../sshd/client/session/ClientSession.java | 2 +-
.../apache/sshd/common/SshdSocketAddress.java | 415 ----------------
.../sshd/common/config/SshConfigFileReader.java | 2 +-
.../common/forward/DefaultTcpipForwarder.java | 2 +-
.../common/forward/LocalForwardingEntry.java | 2 +-
.../apache/sshd/common/forward/SocksProxy.java | 2 +-
.../sshd/common/forward/TcpipClientChannel.java | 2 +-
.../sshd/common/forward/TcpipForwarder.java | 2 +-
.../sshd/common/util/net/NetworkConnector.java | 90 ++++
.../sshd/common/util/net/SshdSocketAddress.java | 415 ++++++++++++++++
.../sshd/server/forward/ForwardingFilter.java | 2 +-
.../forward/StaticDecisionForwardingFilter.java | 2 +-
.../sshd/server/forward/TcpipServerChannel.java | 2 +-
.../global/CancelTcpipForwardHandler.java | 2 +-
.../sshd/server/global/TcpipForwardHandler.java | 2 +-
.../sshd/server/x11/X11ForwardSupport.java | 2 +-
.../test/java/org/apache/sshd/ProxyTest.java | 2 +-
.../hosts/HostConfigEntryResolverTest.java | 2 +-
.../sshd/common/ForwardingFilterTest.java | 1 +
.../sshd/common/auth/AuthenticationTest.java | 2 +-
.../sshd/common/forward/PortForwardingTest.java | 2 +-
.../apache/sshd/util/test/BaseTestSupport.java | 2 +-
.../java/org/apache/sshd/util/test/Utils.java | 19 +
.../apache/sshd/git/pgm/GitPgmCommandTest.java | 2 +-
sshd-ldap/pom.xml | 139 ++++++
.../common/util/net/LdapNetworkConnector.java | 494 +++++++++++++++++++
.../password/LdapPasswordAuthenticator.java | 71 +++
sshd-ldap/src/main/resources/.gitignore | 0
.../sshd/server/auth/BaseAuthenticatorTest.java | 233 +++++++++
.../password/LdapPasswordAuthenticatorTest.java | 74 +++
sshd-ldap/src/test/resources/auth-users.ldif | 31 ++
sshd-ldap/src/test/resources/hostkey.pem | 30 ++
sshd-ldap/src/test/resources/log4j.properties | 38 ++
39 files changed, 1660 insertions(+), 450 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c883bfc..bf0d8db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -961,20 +961,10 @@
</repository>
</distributionManagement>
- <profiles>
- <profile>
- <id>experimental</id>
- <modules>
- <module>sshd-pam</module>
- <module>sshd-sftp</module>
- </modules>
- </profile>
- </profiles>
-
<modules>
<module>sshd-core</module>
+ <module>sshd-ldap</module>
<module>sshd-git</module>
<module>assembly</module>
</modules>
-
</project>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index f5f50b0..8c31468 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -85,7 +85,6 @@ import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.ServiceFactory;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.config.SshConfigFileReader;
import org.apache.sshd.common.config.keys.FilePasswordProvider;
@@ -105,6 +104,7 @@ import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.io.IoUtils;
import org.apache.sshd.common.util.io.NoCloseInputStream;
import org.apache.sshd.common.util.io.NoCloseOutputStream;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* <P>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java b/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java
index ca9e4e2..27ba3ce 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java
@@ -58,7 +58,6 @@ import org.apache.sshd.client.future.ConnectFuture;
import org.apache.sshd.client.keyverifier.ServerKeyVerifier;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.cipher.ECCurves;
import org.apache.sshd.common.config.SshConfigFileReader;
import org.apache.sshd.common.config.keys.BuiltinIdentities;
@@ -78,6 +77,7 @@ import org.apache.sshd.common.util.io.IoUtils;
import org.apache.sshd.common.util.io.NoCloseInputStream;
import org.apache.sshd.common.util.logging.AbstractSimplifiedLog;
import org.apache.sshd.common.util.logging.LoggingUtils;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* A naive implementation of <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh-keyscan&sektion=1">ssh-keyscan(1)</A>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java
index a8313f3..28f2781 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java
@@ -30,7 +30,6 @@ import org.apache.sshd.client.auth.AbstractUserAuth;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.SshConstants;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.signature.Signature;
import org.apache.sshd.common.signature.SignatureFactoriesManager;
@@ -41,6 +40,7 @@ import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.BufferUtils;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
index 4f1aa99..945d431 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java
@@ -26,7 +26,6 @@ import org.apache.sshd.client.future.DefaultOpenFuture;
import org.apache.sshd.client.future.OpenFuture;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.channel.ChannelAsyncInputStream;
import org.apache.sshd.common.channel.ChannelAsyncOutputStream;
import org.apache.sshd.common.channel.ChannelOutputStream;
@@ -34,6 +33,7 @@ import org.apache.sshd.common.channel.ChannelPipedInputStream;
import org.apache.sshd.common.channel.ChannelPipedOutputStream;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* TODO Add javadoc
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
index 3976971..936866f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
@@ -45,7 +45,6 @@ import org.apache.sshd.client.subsystem.sftp.SftpVersionSelector;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.NamedResource;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.forward.TcpipForwarder;
@@ -55,6 +54,7 @@ import org.apache.sshd.common.session.AbstractSession;
import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
index bcb95ee..9d7acbd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
@@ -35,10 +35,10 @@ import org.apache.sshd.client.future.AuthFuture;
import org.apache.sshd.client.scp.ScpClient;
import org.apache.sshd.client.subsystem.sftp.SftpClient;
import org.apache.sshd.client.subsystem.sftp.SftpVersionSelector;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.future.KeyExchangeFuture;
import org.apache.sshd.common.scp.ScpTransferEventListener;
import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* <P>An authenticated session to a given SSH server</P>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/common/SshdSocketAddress.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/SshdSocketAddress.java b/sshd-core/src/main/java/org/apache/sshd/common/SshdSocketAddress.java
deleted file mode 100644
index 8b8a507..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/SshdSocketAddress.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.NetworkInterface;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Objects;
-
-import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.NumberUtils;
-import org.apache.sshd.common.util.ValidateUtils;
-
-/**
- * <P>A simple socket address holding the host name and port number. The reason
- * it does not extend {@link InetSocketAddress} is twofold:</P>
- * <OL>
- * <LI><P>
- * The {@link InetSocketAddress} performs a DNS resolution on the
- * provided host name - which we don't want do use until we want to
- * create a connection using this address (thus the {@link #toInetSocketAddress()}
- * call which executes this query
- * </P></LI>
- *
- * <LI><P>
- * If empty host name is provided we replace it with the <I>any</I>
- * address of 0.0.0.0
- * </P></LI>
- * </OL>
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class SshdSocketAddress extends SocketAddress {
- public static final String LOCALHOST_NAME = "localhost";
- public static final String LOCALHOST_IP = "127.0.0.1";
- public static final String IP_ANYADDR = "0.0.0.0";
-
- // 10.0.0.0 - 10.255.255.255
- public static final String PRIVATE_CLASS_A_PREFIX = "10.";
- // 172.16.0.0 - 172.31.255.255
- public static final String PRIVATE_CLASS_B_PREFIX = "172.";
- // 192.168.0.0 - 192.168.255.255
- public static final String PRIVATE_CLASS_C_PREFIX = "192.168.";
- // 100.64.0.0 - 100.127.255.255
- public static final String CARRIER_GRADE_NAT_PREFIX = "100.";
- // The IPv4 broadcast address
- public static final String BROADCAST_ADDRESS = "255.255.255.255";
-
- /**
- * A dummy placeholder that can be used instead of {@code null}s
- */
- public static final SshdSocketAddress LOCALHOST_ADDRESS = new SshdSocketAddress(LOCALHOST_IP, 0);
-
- /**
- * Compares {@link InetAddress}-es according to their {@link InetAddress#getHostAddress()}
- * value case <U>insensitive</U>
- */
- public static final Comparator<InetAddress> BY_HOST_ADDRESS = new Comparator<InetAddress>() {
- @Override
- public int compare(InetAddress a1, InetAddress a2) {
- String n1 = GenericUtils.trimToEmpty(toAddressString(a1));
- String n2 = GenericUtils.trimToEmpty(toAddressString(a2));
- return String.CASE_INSENSITIVE_ORDER.compare(n1, n2);
- }
- };
-
- private static final long serialVersionUID = 6461645947151952729L;
-
- private final String hostName;
- private final int port;
-
- public SshdSocketAddress(int port) {
- this(IP_ANYADDR, port);
- }
-
- public SshdSocketAddress(String hostName, int port) {
- ValidateUtils.checkNotNull(hostName, "Host name may not be null");
- this.hostName = GenericUtils.isEmpty(hostName) ? IP_ANYADDR : hostName;
-
- ValidateUtils.checkTrue(port >= 0, "Port must be >= 0: %d", port);
- this.port = port;
- }
-
- public String getHostName() {
- return hostName;
- }
-
- public int getPort() {
- return port;
- }
-
- public InetSocketAddress toInetSocketAddress() {
- return new InetSocketAddress(getHostName(), getPort());
- }
-
- @Override
- public String toString() {
- return getHostName() + ":" + getPort();
- }
-
- protected boolean isEquivalent(SshdSocketAddress that) {
- if (that == null) {
- return false;
- } else if (that == this) {
- return true;
- } else {
- return (this.getPort() == that.getPort())
- && Objects.equals(this.getHostName(), that.getHostName());
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == null) {
- return false;
- }
- if (getClass() != o.getClass()) {
- return false;
- }
- return isEquivalent((SshdSocketAddress) o);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(getHostName()) + getPort();
- }
-
-
- /**
- * Returns the first external network address assigned to this
- * machine or null if one is not found.
- * @return Inet4Address associated with an external interface
- * DevNote: We actually return InetAddress here, as Inet4Addresses are final and cannot be mocked.
- */
- public static InetAddress getFirstExternalNetwork4Address() {
- List<? extends InetAddress> addresses = getExternalNetwork4Addresses();
- return (GenericUtils.size(addresses) > 0) ? addresses.get(0) : null;
- }
-
- /**
- * @return a {@link List} of local network addresses which are not multicast
- * or localhost sorted according to {@link #BY_HOST_ADDRESS}
- */
- public static List<InetAddress> getExternalNetwork4Addresses() {
- List<InetAddress> addresses = new ArrayList<InetAddress>();
- try {
- for (Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); (nets != null) && nets.hasMoreElements();) {
- NetworkInterface netint = nets.nextElement();
- /* TODO - uncomment when 1.5 compatibility no longer required
- if (!netint.isUp()) {
- continue; // ignore non-running interfaces
- }
- */
-
- for (Enumeration<InetAddress> inetAddresses = netint.getInetAddresses(); (inetAddresses != null) && inetAddresses.hasMoreElements();) {
- InetAddress inetAddress = inetAddresses.nextElement();
- if (isValidHostAddress(inetAddress)) {
- addresses.add(inetAddress);
- }
- }
- }
- } catch (SocketException e) {
- // swallow
- }
-
- if (GenericUtils.size(addresses) > 1) {
- Collections.sort(addresses, BY_HOST_ADDRESS);
- }
-
- return addresses;
- }
-
- /**
- * @param addr The {@link InetAddress} to be verified
- * @return <P><code>true</code> if the address is:</P></BR>
- * <UL>
- * <LI>Not <code>null</code></LI>
- * <LI>An {@link Inet4Address}</LI>
- * <LI>Not link local</LI>
- * <LI>Not a multicast</LI>
- * <LI>Not a loopback</LI>
- * </UL>
- * @see InetAddress#isLinkLocalAddress()
- * @see InetAddress#isMulticastAddress()
- * @see InetAddress#isMulticastAddress()
- */
- public static boolean isValidHostAddress(InetAddress addr) {
- if (addr == null) {
- return false;
- }
-
- if (addr.isLinkLocalAddress()) {
- return false;
- }
-
- if (addr.isMulticastAddress()) {
- return false;
- }
-
- if (!(addr instanceof Inet4Address)) {
- return false;
- }
-
- if (isLoopback(addr)) {
- return false;
- }
-
- return true;
- }
-
- /**
- * @param addr The {@link InetAddress} to be considered
- * @return <code>true</code> if the address is a loopback one.
- * <B>Note:</B> if {@link InetAddress#isLoopbackAddress()}
- * returns <code>false</code> the address <U>string</U> is checked
- * @see #toAddressString(InetAddress)
- * @see #isLoopback(String)
- */
- public static boolean isLoopback(InetAddress addr) {
- if (addr == null) {
- return false;
- }
-
- if (addr.isLoopbackAddress()) {
- return true;
- }
-
- String ip = toAddressString(addr);
- return isLoopback(ip);
- }
-
- /**
- * @param ip IP value to be tested
- * @return <code>true</code> if the IP is "localhost" or
- * "127.x.x.x".
- */
- public static boolean isLoopback(String ip) {
- if (GenericUtils.isEmpty(ip)) {
- return false;
- }
-
- if (LOCALHOST_NAME.equals(ip) || LOCALHOST_IP.equals(ip)) {
- return true;
- }
-
- String[] values = GenericUtils.split(ip, '.');
- if (GenericUtils.length(values) != 4) {
- return false;
- }
-
- for (int index = 0; index < values.length; index++) {
- String val = values[index];
- if (!isValidIPv4AddressComponent(val)) {
- return false;
- }
-
- if (index == 0) {
- int number = Integer.parseInt(val);
- if (number != 127) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- public static String toAddressString(InetAddress addr) {
- String ip = (addr == null) ? null : addr.toString();
- if (GenericUtils.isEmpty(ip)) {
- return null;
- } else {
- return ip.replaceAll(".*/", "");
- }
- }
-
- public static final boolean isIPv4Address(String addr) {
- if (GenericUtils.isEmpty(addr)) {
- return false;
- }
-
- String[] comps = GenericUtils.split(addr, '.');
- if (GenericUtils.length(comps) != 4) {
- return false;
- }
-
- for (String c : comps) {
- if (!isValidIPv4AddressComponent(c)) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Checks if the address is one of the allocated private blocks
- * @param addr The address string
- * @return {@code true} if this is one of the allocated private
- * blocks. <B>Note:</B> it assumes that the address string is
- * indeed an IPv4 address
- * @see #isIPv4Address(String)
- * @see #PRIVATE_CLASS_A_PREFIX
- * @see #PRIVATE_CLASS_B_PREFIX
- * @see #PRIVATE_CLASS_C_PREFIX
- * @see <A HREF="http://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces">Wiki page</A>
- */
- public static final boolean isPrivateIPv4Address(String addr) {
- if (GenericUtils.isEmpty(addr)) {
- return false;
- }
-
- if (addr.startsWith(PRIVATE_CLASS_A_PREFIX) || addr.startsWith(PRIVATE_CLASS_C_PREFIX)) {
- return true;
- }
-
- // for 172.x.x.x we need further checks
- if (!addr.startsWith(PRIVATE_CLASS_B_PREFIX)) {
- return false;
- }
-
- int nextCompPos = addr.indexOf('.', PRIVATE_CLASS_B_PREFIX.length());
- if (nextCompPos <= PRIVATE_CLASS_B_PREFIX.length()) {
- return false;
- }
-
- String value = addr.substring(PRIVATE_CLASS_B_PREFIX.length(), nextCompPos);
- if (!isValidIPv4AddressComponent(value)) {
- return false;
- }
-
- int v = Integer.parseInt(value);
- return (v >= 16) && (v <= 31);
- }
-
- /**
- * @param addr The address to be checked
- * @return {@code true} if the address is in the 100.64.0.0/10 range
- * @see <A HREF="http://tools.ietf.org/html/rfc6598">RFC6598</A>
- */
- public static final boolean isCarrierGradeNatIPv4Address(String addr) {
- if (GenericUtils.isEmpty(addr)) {
- return false;
- }
-
- if (!addr.startsWith(CARRIER_GRADE_NAT_PREFIX)) {
- return false;
- }
-
- int nextCompPos = addr.indexOf('.', CARRIER_GRADE_NAT_PREFIX.length());
- if (nextCompPos <= CARRIER_GRADE_NAT_PREFIX.length()) {
- return false;
- }
-
- String value = addr.substring(CARRIER_GRADE_NAT_PREFIX.length(), nextCompPos);
- if (!isValidIPv4AddressComponent(value)) {
- return false;
- }
-
- int v = Integer.parseInt(value);
- return (v >= 64) && (v <= 127);
- }
-
- /**
- * <P>Checks if the provided argument is a valid IPv4 address component:</P></BR>
- * <UL>
- * <LI>Not {@code null}/empty</LI>
- * <LI>Has at most 3 <U>digits</U></LI>
- * <LI>Its value is ≤ 255</LI>
- * </UL>
- * @param c The {@link CharSequence} to be validate
- * @return {@code true} if valid IPv4 address component
- */
- public static final boolean isValidIPv4AddressComponent(CharSequence c) {
- if (GenericUtils.isEmpty(c) || (c.length() > 3)) {
- return false;
- }
-
- char ch = c.charAt(0);
- if ((ch < '0') || (ch > '9')) {
- return false;
- }
-
- if (!NumberUtils.isIntegerNumber(c)) {
- return false;
- }
-
- int v = Integer.parseInt(c.toString());
- return (v >= 0) && (v <= 255);
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java b/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
index dc31ad6..b89a4ec 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
@@ -43,7 +43,6 @@ import org.apache.sshd.client.SshClient;
import org.apache.sshd.common.AbstractFactoryManager;
import org.apache.sshd.common.BuiltinFactory;
import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.cipher.Cipher;
import org.apache.sshd.common.compression.BuiltinCompressions;
@@ -63,6 +62,7 @@ import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.io.IoUtils;
import org.apache.sshd.common.util.io.NoCloseInputStream;
import org.apache.sshd.common.util.io.NoCloseReader;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.ServerBuilder;
import org.apache.sshd.server.SshServer;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
index 3115e80..69dc6db 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
@@ -37,7 +37,6 @@ import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.future.SshFutureListener;
import org.apache.sshd.common.io.IoAcceptor;
import org.apache.sshd.common.io.IoHandler;
@@ -53,6 +52,7 @@ import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.forward.ForwardingFilter;
/**
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java
index 6be6fab..b45562e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/LocalForwardingEntry.java
@@ -22,9 +22,9 @@ package org.apache.sshd.common.forward;
import java.util.Collection;
import java.util.Objects;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
index 36b664b..9ab9c10 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
@@ -25,7 +25,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.sshd.client.future.OpenFuture;
import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.future.SshFutureListener;
import org.apache.sshd.common.io.IoHandler;
import org.apache.sshd.common.io.IoSession;
@@ -33,6 +32,7 @@ import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.common.util.closeable.AbstractCloseable;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* SOCKS proxy server, supporting simple socks4/5 protocols.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
index 06c7f88..44856bd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
@@ -28,12 +28,12 @@ import org.apache.sshd.client.future.OpenFuture;
import org.apache.sshd.common.Closeable;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.channel.ChannelOutputStream;
import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* TODO Add javadoc
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java
index e19da1e..1eb8c8d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipForwarder.java
@@ -22,7 +22,7 @@ package org.apache.sshd.common.forward;
import java.io.IOException;
import org.apache.sshd.common.Closeable;
-import org.apache.sshd.common.SshdSocketAddress;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
public interface TcpipForwarder extends Closeable {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/common/util/net/NetworkConnector.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/net/NetworkConnector.java b/sshd-core/src/main/java/org/apache/sshd/common/util/net/NetworkConnector.java
new file mode 100644
index 0000000..4d9e547
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/net/NetworkConnector.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.util.net;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class NetworkConnector extends AbstractLoggingBean {
+ public static final String DEFAULT_HOST = SshdSocketAddress.LOCALHOST_IP;
+ public static final long DEFAULT_CONNECT_TIMEOUT = TimeUnit.SECONDS.toMillis(5L);
+ public static final long DEFAULT_READ_TIMEOUT = TimeUnit.SECONDS.toMillis(15L);
+
+ private String protocol;
+ private String host = DEFAULT_HOST;
+ private int port;
+ private long connectTimeout = DEFAULT_CONNECT_TIMEOUT;
+ private long readTimeout = DEFAULT_READ_TIMEOUT;
+
+ public NetworkConnector() {
+ super();
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public long getConnectTimeout() {
+ return connectTimeout;
+ }
+
+ public void setConnectTimeout(long connectTimeout) {
+ this.connectTimeout = connectTimeout;
+ }
+
+ public long getReadTimeout() {
+ return readTimeout;
+ }
+
+ public void setReadTimeout(long readTimeout) {
+ this.readTimeout = readTimeout;
+ }
+
+ @Override
+ public String toString() {
+ return getProtocol() + "://" + getHost() + ":" + getPort()
+ + ";connect=" + getConnectTimeout()
+ + ";read=" + getReadTimeout();
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java b/sshd-core/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
new file mode 100644
index 0000000..7ea3806
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
@@ -0,0 +1,415 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.util.net;
+
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Objects;
+
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.NumberUtils;
+import org.apache.sshd.common.util.ValidateUtils;
+
+/**
+ * <P>A simple socket address holding the host name and port number. The reason
+ * it does not extend {@link InetSocketAddress} is twofold:</P>
+ * <OL>
+ * <LI><P>
+ * The {@link InetSocketAddress} performs a DNS resolution on the
+ * provided host name - which we don't want do use until we want to
+ * create a connection using this address (thus the {@link #toInetSocketAddress()}
+ * call which executes this query
+ * </P></LI>
+ *
+ * <LI><P>
+ * If empty host name is provided we replace it with the <I>any</I>
+ * address of 0.0.0.0
+ * </P></LI>
+ * </OL>
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class SshdSocketAddress extends SocketAddress {
+ public static final String LOCALHOST_NAME = "localhost";
+ public static final String LOCALHOST_IP = "127.0.0.1";
+ public static final String IP_ANYADDR = "0.0.0.0";
+
+ // 10.0.0.0 - 10.255.255.255
+ public static final String PRIVATE_CLASS_A_PREFIX = "10.";
+ // 172.16.0.0 - 172.31.255.255
+ public static final String PRIVATE_CLASS_B_PREFIX = "172.";
+ // 192.168.0.0 - 192.168.255.255
+ public static final String PRIVATE_CLASS_C_PREFIX = "192.168.";
+ // 100.64.0.0 - 100.127.255.255
+ public static final String CARRIER_GRADE_NAT_PREFIX = "100.";
+ // The IPv4 broadcast address
+ public static final String BROADCAST_ADDRESS = "255.255.255.255";
+
+ /**
+ * A dummy placeholder that can be used instead of {@code null}s
+ */
+ public static final SshdSocketAddress LOCALHOST_ADDRESS = new SshdSocketAddress(LOCALHOST_IP, 0);
+
+ /**
+ * Compares {@link InetAddress}-es according to their {@link InetAddress#getHostAddress()}
+ * value case <U>insensitive</U>
+ */
+ public static final Comparator<InetAddress> BY_HOST_ADDRESS = new Comparator<InetAddress>() {
+ @Override
+ public int compare(InetAddress a1, InetAddress a2) {
+ String n1 = GenericUtils.trimToEmpty(toAddressString(a1));
+ String n2 = GenericUtils.trimToEmpty(toAddressString(a2));
+ return String.CASE_INSENSITIVE_ORDER.compare(n1, n2);
+ }
+ };
+
+ private static final long serialVersionUID = 6461645947151952729L;
+
+ private final String hostName;
+ private final int port;
+
+ public SshdSocketAddress(int port) {
+ this(IP_ANYADDR, port);
+ }
+
+ public SshdSocketAddress(String hostName, int port) {
+ ValidateUtils.checkNotNull(hostName, "Host name may not be null");
+ this.hostName = GenericUtils.isEmpty(hostName) ? IP_ANYADDR : hostName;
+
+ ValidateUtils.checkTrue(port >= 0, "Port must be >= 0: %d", port);
+ this.port = port;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public InetSocketAddress toInetSocketAddress() {
+ return new InetSocketAddress(getHostName(), getPort());
+ }
+
+ @Override
+ public String toString() {
+ return getHostName() + ":" + getPort();
+ }
+
+ protected boolean isEquivalent(SshdSocketAddress that) {
+ if (that == null) {
+ return false;
+ } else if (that == this) {
+ return true;
+ } else {
+ return (this.getPort() == that.getPort())
+ && Objects.equals(this.getHostName(), that.getHostName());
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null) {
+ return false;
+ }
+ if (getClass() != o.getClass()) {
+ return false;
+ }
+ return isEquivalent((SshdSocketAddress) o);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(getHostName()) + getPort();
+ }
+
+
+ /**
+ * Returns the first external network address assigned to this
+ * machine or null if one is not found.
+ * @return Inet4Address associated with an external interface
+ * DevNote: We actually return InetAddress here, as Inet4Addresses are final and cannot be mocked.
+ */
+ public static InetAddress getFirstExternalNetwork4Address() {
+ List<? extends InetAddress> addresses = getExternalNetwork4Addresses();
+ return (GenericUtils.size(addresses) > 0) ? addresses.get(0) : null;
+ }
+
+ /**
+ * @return a {@link List} of local network addresses which are not multicast
+ * or localhost sorted according to {@link #BY_HOST_ADDRESS}
+ */
+ public static List<InetAddress> getExternalNetwork4Addresses() {
+ List<InetAddress> addresses = new ArrayList<InetAddress>();
+ try {
+ for (Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces(); (nets != null) && nets.hasMoreElements();) {
+ NetworkInterface netint = nets.nextElement();
+ /* TODO - uncomment when 1.5 compatibility no longer required
+ if (!netint.isUp()) {
+ continue; // ignore non-running interfaces
+ }
+ */
+
+ for (Enumeration<InetAddress> inetAddresses = netint.getInetAddresses(); (inetAddresses != null) && inetAddresses.hasMoreElements();) {
+ InetAddress inetAddress = inetAddresses.nextElement();
+ if (isValidHostAddress(inetAddress)) {
+ addresses.add(inetAddress);
+ }
+ }
+ }
+ } catch (SocketException e) {
+ // swallow
+ }
+
+ if (GenericUtils.size(addresses) > 1) {
+ Collections.sort(addresses, BY_HOST_ADDRESS);
+ }
+
+ return addresses;
+ }
+
+ /**
+ * @param addr The {@link InetAddress} to be verified
+ * @return <P><code>true</code> if the address is:</P></BR>
+ * <UL>
+ * <LI>Not <code>null</code></LI>
+ * <LI>An {@link Inet4Address}</LI>
+ * <LI>Not link local</LI>
+ * <LI>Not a multicast</LI>
+ * <LI>Not a loopback</LI>
+ * </UL>
+ * @see InetAddress#isLinkLocalAddress()
+ * @see InetAddress#isMulticastAddress()
+ * @see InetAddress#isMulticastAddress()
+ */
+ public static boolean isValidHostAddress(InetAddress addr) {
+ if (addr == null) {
+ return false;
+ }
+
+ if (addr.isLinkLocalAddress()) {
+ return false;
+ }
+
+ if (addr.isMulticastAddress()) {
+ return false;
+ }
+
+ if (!(addr instanceof Inet4Address)) {
+ return false;
+ }
+
+ if (isLoopback(addr)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * @param addr The {@link InetAddress} to be considered
+ * @return <code>true</code> if the address is a loopback one.
+ * <B>Note:</B> if {@link InetAddress#isLoopbackAddress()}
+ * returns <code>false</code> the address <U>string</U> is checked
+ * @see #toAddressString(InetAddress)
+ * @see #isLoopback(String)
+ */
+ public static boolean isLoopback(InetAddress addr) {
+ if (addr == null) {
+ return false;
+ }
+
+ if (addr.isLoopbackAddress()) {
+ return true;
+ }
+
+ String ip = toAddressString(addr);
+ return isLoopback(ip);
+ }
+
+ /**
+ * @param ip IP value to be tested
+ * @return <code>true</code> if the IP is "localhost" or
+ * "127.x.x.x".
+ */
+ public static boolean isLoopback(String ip) {
+ if (GenericUtils.isEmpty(ip)) {
+ return false;
+ }
+
+ if (LOCALHOST_NAME.equals(ip) || LOCALHOST_IP.equals(ip)) {
+ return true;
+ }
+
+ String[] values = GenericUtils.split(ip, '.');
+ if (GenericUtils.length(values) != 4) {
+ return false;
+ }
+
+ for (int index = 0; index < values.length; index++) {
+ String val = values[index];
+ if (!isValidIPv4AddressComponent(val)) {
+ return false;
+ }
+
+ if (index == 0) {
+ int number = Integer.parseInt(val);
+ if (number != 127) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public static String toAddressString(InetAddress addr) {
+ String ip = (addr == null) ? null : addr.toString();
+ if (GenericUtils.isEmpty(ip)) {
+ return null;
+ } else {
+ return ip.replaceAll(".*/", "");
+ }
+ }
+
+ public static final boolean isIPv4Address(String addr) {
+ if (GenericUtils.isEmpty(addr)) {
+ return false;
+ }
+
+ String[] comps = GenericUtils.split(addr, '.');
+ if (GenericUtils.length(comps) != 4) {
+ return false;
+ }
+
+ for (String c : comps) {
+ if (!isValidIPv4AddressComponent(c)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks if the address is one of the allocated private blocks
+ * @param addr The address string
+ * @return {@code true} if this is one of the allocated private
+ * blocks. <B>Note:</B> it assumes that the address string is
+ * indeed an IPv4 address
+ * @see #isIPv4Address(String)
+ * @see #PRIVATE_CLASS_A_PREFIX
+ * @see #PRIVATE_CLASS_B_PREFIX
+ * @see #PRIVATE_CLASS_C_PREFIX
+ * @see <A HREF="http://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces">Wiki page</A>
+ */
+ public static final boolean isPrivateIPv4Address(String addr) {
+ if (GenericUtils.isEmpty(addr)) {
+ return false;
+ }
+
+ if (addr.startsWith(PRIVATE_CLASS_A_PREFIX) || addr.startsWith(PRIVATE_CLASS_C_PREFIX)) {
+ return true;
+ }
+
+ // for 172.x.x.x we need further checks
+ if (!addr.startsWith(PRIVATE_CLASS_B_PREFIX)) {
+ return false;
+ }
+
+ int nextCompPos = addr.indexOf('.', PRIVATE_CLASS_B_PREFIX.length());
+ if (nextCompPos <= PRIVATE_CLASS_B_PREFIX.length()) {
+ return false;
+ }
+
+ String value = addr.substring(PRIVATE_CLASS_B_PREFIX.length(), nextCompPos);
+ if (!isValidIPv4AddressComponent(value)) {
+ return false;
+ }
+
+ int v = Integer.parseInt(value);
+ return (v >= 16) && (v <= 31);
+ }
+
+ /**
+ * @param addr The address to be checked
+ * @return {@code true} if the address is in the 100.64.0.0/10 range
+ * @see <A HREF="http://tools.ietf.org/html/rfc6598">RFC6598</A>
+ */
+ public static final boolean isCarrierGradeNatIPv4Address(String addr) {
+ if (GenericUtils.isEmpty(addr)) {
+ return false;
+ }
+
+ if (!addr.startsWith(CARRIER_GRADE_NAT_PREFIX)) {
+ return false;
+ }
+
+ int nextCompPos = addr.indexOf('.', CARRIER_GRADE_NAT_PREFIX.length());
+ if (nextCompPos <= CARRIER_GRADE_NAT_PREFIX.length()) {
+ return false;
+ }
+
+ String value = addr.substring(CARRIER_GRADE_NAT_PREFIX.length(), nextCompPos);
+ if (!isValidIPv4AddressComponent(value)) {
+ return false;
+ }
+
+ int v = Integer.parseInt(value);
+ return (v >= 64) && (v <= 127);
+ }
+
+ /**
+ * <P>Checks if the provided argument is a valid IPv4 address component:</P></BR>
+ * <UL>
+ * <LI>Not {@code null}/empty</LI>
+ * <LI>Has at most 3 <U>digits</U></LI>
+ * <LI>Its value is ≤ 255</LI>
+ * </UL>
+ * @param c The {@link CharSequence} to be validate
+ * @return {@code true} if valid IPv4 address component
+ */
+ public static final boolean isValidIPv4AddressComponent(CharSequence c) {
+ if (GenericUtils.isEmpty(c) || (c.length() > 3)) {
+ return false;
+ }
+
+ char ch = c.charAt(0);
+ if ((ch < '0') || (ch > '9')) {
+ return false;
+ }
+
+ if (!NumberUtils.isIntegerNumber(c)) {
+ return false;
+ }
+
+ int v = Integer.parseInt(c.toString());
+ return (v >= 0) && (v <= 255);
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java
index 0a9f0a4..23e2f14 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/ForwardingFilter.java
@@ -23,9 +23,9 @@ import java.util.EnumSet;
import java.util.Set;
import org.apache.sshd.common.NamedResource;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* Determines if a forwarding request will be permitted.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
index 6b82b70..a4a46fb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/StaticDecisionForwardingFilter.java
@@ -18,9 +18,9 @@
*/
package org.apache.sshd.server.forward;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* A {@link ForwardingFilter} implementation that returns the same "static"
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index bf97181..ced89cb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -28,7 +28,6 @@ import org.apache.sshd.client.future.DefaultOpenFuture;
import org.apache.sshd.client.future.OpenFuture;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.SshConstants;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.channel.ChannelFactory;
import org.apache.sshd.common.channel.ChannelListener;
@@ -45,6 +44,7 @@ import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.Readable;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.common.util.threads.ExecutorServiceCarrier;
import org.apache.sshd.common.util.threads.ThreadUtils;
import org.apache.sshd.server.channel.AbstractServerChannel;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
index 23724b5..bba75e4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java
@@ -19,7 +19,6 @@
package org.apache.sshd.server.global;
import org.apache.sshd.common.SshConstants;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.forward.TcpipForwarder;
import org.apache.sshd.common.session.AbstractConnectionServiceRequestHandler;
import org.apache.sshd.common.session.ConnectionService;
@@ -27,6 +26,7 @@ import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.Int2IntFunction;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.BufferUtils;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* Handler for cancel-tcpip-forward global request.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
index 3b4618b..b9a44e8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java
@@ -19,7 +19,6 @@
package org.apache.sshd.server.global;
import org.apache.sshd.common.SshConstants;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.forward.TcpipForwarder;
import org.apache.sshd.common.session.AbstractConnectionServiceRequestHandler;
import org.apache.sshd.common.session.ConnectionService;
@@ -27,6 +26,7 @@ import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.Int2IntFunction;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.BufferUtils;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* Handler for tcpip-forward global request.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java b/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
index d44e589..a73bb71 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/x11/X11ForwardSupport.java
@@ -33,7 +33,6 @@ import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.channel.ChannelOutputStream;
import org.apache.sshd.common.io.IoAcceptor;
import org.apache.sshd.common.io.IoHandler;
@@ -46,6 +45,7 @@ import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.common.util.closeable.AbstractInnerCloseable;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java b/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
index 31befd4..92e4965 100644
--- a/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
@@ -36,7 +36,7 @@ import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.PropertyResolverUtils;
-import org.apache.sshd.common.SshdSocketAddress;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.forward.AcceptAllForwardingFilter;
import org.apache.sshd.util.test.BaseTestSupport;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java
index 5c1e160..9ff1dc1 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java
@@ -38,7 +38,6 @@ import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.config.keys.ClientIdentityLoader;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.PropertyResolverUtils;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.config.keys.FilePasswordProvider;
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.io.IoSession;
@@ -46,6 +45,7 @@ import org.apache.sshd.common.keyprovider.AbstractKeyPairProvider;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.password.RejectAllPasswordAuthenticator;
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/test/java/org/apache/sshd/common/ForwardingFilterTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/ForwardingFilterTest.java b/sshd-core/src/test/java/org/apache/sshd/common/ForwardingFilterTest.java
index 1403ba1..2c3531a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/ForwardingFilterTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/ForwardingFilterTest.java
@@ -20,6 +20,7 @@
package org.apache.sshd.common;
import org.apache.sshd.common.session.Session;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.forward.AcceptAllForwardingFilter;
import org.apache.sshd.server.forward.ForwardingFilter;
import org.apache.sshd.server.forward.RejectAllForwardingFilter;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java
index afaa8a5..b58072a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java
@@ -44,7 +44,6 @@ import org.apache.sshd.client.keyverifier.ServerKeyVerifier;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.PropertyResolverUtils;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
@@ -55,6 +54,7 @@ import org.apache.sshd.common.signature.Signature;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.ServerFactoryManager;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.hostbased.HostBasedAuthenticator;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java b/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java
index 0cd71e0..7d6cf8d 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java
@@ -46,12 +46,12 @@ import org.apache.sshd.client.channel.ChannelDirectTcpip;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.PropertyResolverUtils;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.forward.TcpipForwarder;
import org.apache.sshd.common.forward.TcpipForwarderFactory;
import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.forward.AcceptAllForwardingFilter;
import org.apache.sshd.server.global.CancelTcpipForwardHandler;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
index 410f2d1..d1478e8 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
@@ -47,10 +47,10 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.sshd.client.SshClient;
-import org.apache.sshd.common.SshdSocketAddress;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.SshServer;
import org.junit.Assert;
import org.junit.Rule;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java b/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
index 4bb8584..1dcfd12 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
@@ -203,6 +203,25 @@ public class Utils {
return path;
}
+ public static File resolve(File root, String... children) {
+ if (GenericUtils.isEmpty(children)) {
+ return root;
+ } else {
+ return resolve(root, Arrays.asList(children));
+ }
+ }
+
+ public static File resolve(File root, Collection<String> children) {
+ File path = root;
+ if (!GenericUtils.isEmpty(children)) {
+ for (String child : children) {
+ path = new File(path, child);
+ }
+ }
+
+ return path;
+ }
+
/**
* Removes the specified file - if it is a directory, then its children
* are deleted recursively and then the directory itself. <B>Note:</B>
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java
----------------------------------------------------------------------
diff --git a/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java b/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java
index 6d0f308..33e6f61 100644
--- a/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java
+++ b/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java
@@ -30,7 +30,7 @@ import org.apache.sshd.client.channel.ChannelExec;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.SshdSocketAddress;
+import org.apache.sshd.common.util.net.SshdSocketAddress;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/f374e72c/sshd-ldap/pom.xml
----------------------------------------------------------------------
diff --git a/sshd-ldap/pom.xml b/sshd-ldap/pom.xml
new file mode 100644
index 0000000..b692860
--- /dev/null
+++ b/sshd-ldap/pom.xml
@@ -0,0 +1,139 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+
+ <!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>sshd-ldap</artifactId>
+ <name>Apache Mina SSHD :: Git</name>
+ <packaging>jar</packaging>
+ <inceptionYear>2008</inceptionYear>
+
+ <properties>
+ <projectRoot>${basedir}/..</projectRoot>
+ <apacheds.version>1.5.7</apacheds.version>
+ <apache.shared.version>0.9.19</apache.shared.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.directory.shared</groupId>
+ <artifactId>shared-dsml-parser</artifactId>
+ <version>${apache.shared.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-test-framework</artifactId>
+ <version>${apacheds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-server-integ</artifactId>
+ <version>${apacheds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-core-integ</artifactId>
+ <version>${apacheds.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <additionalparam>-Xdoclint:none</additionalparam>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>