From accd3e006a05615cf6eed9369d91fbedcc4eab16 Mon Sep 17 00:00:00 2001
From: Mat Booth <mat.booth@redhat.com>
Date: Thu, 7 Mar 2019 11:27:55 +0000
Subject: [PATCH] Avoid optional dependency on native tomcat APR library

---
 pom.xml                                          |  5 -----
 sshd-core/pom.xml                                |  6 ------
 .../sshd/agent/local/ProxyAgentFactory.java      | 16 +---------------
 sshd-osgi/pom.xml                                |  6 ------
 4 files changed, 1 insertion(+), 32 deletions(-)

diff --git a/pom.xml b/pom.xml
index 867ca88..7c29678 100644
--- a/pom.xml
+++ b/pom.xml
@@ -428,11 +428,6 @@
                 <artifactId>mina-core</artifactId>
                 <version>2.0.23</version>
             </dependency>
-            <dependency>
-                <groupId>tomcat</groupId>
-                <artifactId>tomcat-apr</artifactId>
-                <version>5.5.23</version>
-            </dependency>
 
             <dependency>
                 <groupId>net.i2p.crypto</groupId>
diff --git a/sshd-core/pom.xml b/sshd-core/pom.xml
index 6171c5c..73a43a7 100644
--- a/sshd-core/pom.xml
+++ b/sshd-core/pom.xml
@@ -43,12 +43,6 @@
         </dependency>
 
         <dependency>
-            <groupId>tomcat</groupId>
-            <artifactId>tomcat-apr</artifactId>
-            <optional>true</optional>
-        </dependency>
-
-        <dependency>
             <groupId>org.bouncycastle</groupId>
             <artifactId>bcpg-jdk15on</artifactId>
             <optional>true</optional>
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
index ab19539..5757e68 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ProxyAgentFactory.java
@@ -27,8 +27,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.sshd.agent.SshAgent;
 import org.apache.sshd.agent.SshAgentFactory;
 import org.apache.sshd.agent.SshAgentServer;
-import org.apache.sshd.agent.unix.AprLibrary;
-import org.apache.sshd.agent.unix.UnixAgentFactory;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.PropertyResolver;
 import org.apache.sshd.common.channel.ChannelFactory;
@@ -51,9 +49,7 @@ public class ProxyAgentFactory implements SshAgentFactory {
 
     @Override
     public List<ChannelFactory> getChannelForwardingFactories(FactoryManager manager) {
-        return isPreferredUnixAgent(manager)
-                ? UnixAgentFactory.DEFAULT_FORWARDING_CHANNELS
-                : LocalAgentFactory.DEFAULT_FORWARDING_CHANNELS;
+        return LocalAgentFactory.DEFAULT_FORWARDING_CHANNELS;
     }
 
     @Override
@@ -104,16 +100,6 @@ public class ProxyAgentFactory implements SshAgentFactory {
     }
 
     public static boolean isPreferredUnixAgent(PropertyResolver resolver) {
-        if (CoreModuleProperties.PREFER_UNIX_AGENT.getRequired(resolver)) {
-            try {
-                if (AprLibrary.getInstance() != null) {
-                    return true;
-                }
-            } catch (Exception ignore) {
-                // ignored
-            }
-        }
-
         return false;
     }
 }
diff --git a/sshd-osgi/pom.xml b/sshd-osgi/pom.xml
index 5395ceb..f456263 100644
--- a/sshd-osgi/pom.xml
+++ b/sshd-osgi/pom.xml
@@ -68,12 +68,6 @@
             <optional>true</optional>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>tomcat</groupId>
-            <artifactId>tomcat-apr</artifactId>
-            <optional>true</optional>
-            <scope>provided</scope>
-        </dependency>
     </dependencies>
 
     <build>
-- 
2.20.1
