tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject [50/50] tomee git commit: TOMEE-1974 backporting url cleanup from master to use authorization parameter instead of introducing a new authentication way less powerful
Date Sat, 03 Dec 2016 16:38:16 GMT
TOMEE-1974 backporting url cleanup from master to use authorization parameter instead of introducing
a new authentication way less powerful


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/1f4b821b
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/1f4b821b
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/1f4b821b

Branch: refs/heads/tomee-1.7.x
Commit: 1f4b821b91960f651d57792fdfe5ca2bb38d70f1
Parents: 1b222ca
Author: rmannibucau <rmannibucau@apache.org>
Authored: Sat Dec 3 17:33:07 2016 +0100
Committer: rmannibucau <rmannibucau@apache.org>
Committed: Sat Dec 3 17:33:07 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/openejb/client/Client.java  |  4 +--
 .../apache/openejb/client/ClientDataSource.java |  4 ++-
 .../openejb/client/EjbObjectInputStream.java    |  2 +-
 .../openejb/client/HttpConnectionFactory.java   | 29 ++++++++++++++++----
 .../apache/openejb/client/ResourceFinder.java   |  4 ++-
 .../apache/openejb/client/ServiceLocator.java   |  4 ++-
 .../openejb/client/proxy/Jdk13ProxyFactory.java |  2 +-
 .../openejb/client/HttpConnectionTest.java      |  4 +++
 8 files changed, 40 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/1f4b821b/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java b/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
index 837a2ea..1559e37 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/Client.java
@@ -56,7 +56,7 @@ public class Client {
     private boolean FINEST = logger.isLoggable(Level.FINEST);
     private boolean FINER = logger.isLoggable(Level.FINER);
 
-    public static final ThreadLocal<Set<URI>> failed = new ThreadLocal<>();
+    public static final ThreadLocal<Set<URI>> failed = new ThreadLocal<Set<URI>>();
     private static final ProtocolMetaData PROTOCOL_META_DATA = new ProtocolMetaData();
 
     private static Client client = new Client();
@@ -67,7 +67,7 @@ public class Client {
         COMPATIBLE_META_DATA = (null != version ? new ProtocolMetaData(version) : null);
     }
 
-    private List<Class<? extends Throwable>> retryConditions = new CopyOnWriteArrayList<>();
+    private List<Class<? extends Throwable>> retryConditions = new CopyOnWriteArrayList<Class<?
extends Throwable>>();
     private boolean retry = false;
 
     private final Observers observers = new Observers();

http://git-wip-us.apache.org/repos/asf/tomee/blob/1f4b821b/server/openejb-client/src/main/java/org/apache/openejb/client/ClientDataSource.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/ClientDataSource.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/ClientDataSource.java
index 3f28b34..ab44500 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/ClientDataSource.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/ClientDataSource.java
@@ -69,8 +69,10 @@ public class ClientDataSource implements DataSource {
         final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
         try {
             Class.forName(jdbcDriver, true, classLoader);
-        } catch (ClassNotFoundException | NoClassDefFoundError e) {
+        } catch (final NoClassDefFoundError e) {
             throw new IllegalStateException("Cannot use DataSource in client VM without the
JDBC Driver in classpath: " + jdbcDriver, e);
+        } catch (final ClassNotFoundException cnfe) {
+            throw new IllegalStateException("Cannot use DataSource in client VM without the
JDBC Driver in classpath: " + jdbcDriver, cnfe);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/1f4b821b/server/openejb-client/src/main/java/org/apache/openejb/client/EjbObjectInputStream.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/EjbObjectInputStream.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/EjbObjectInputStream.java
index 59b48df..66d0570 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/EjbObjectInputStream.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/EjbObjectInputStream.java
@@ -29,7 +29,7 @@ import java.util.regex.Pattern;
  */
 public class EjbObjectInputStream extends ObjectInputStream {
     private static final AtomicReference<BlacklistClassResolver> RESOLVER_ATOMIC_REFERENCE
=
-        new AtomicReference<>(new BlacklistClassResolver());
+        new AtomicReference<BlacklistClassResolver>(new BlacklistClassResolver());
 
     public static void reloadResolverConfig() {
         RESOLVER_ATOMIC_REFERENCE.set(new BlacklistClassResolver());

http://git-wip-us.apache.org/repos/asf/tomee/blob/1f4b821b/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
index 7344864..a93fdcb 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/HttpConnectionFactory.java
@@ -38,8 +38,8 @@ import java.util.concurrent.ConcurrentMap;
  */
 public class HttpConnectionFactory implements ConnectionFactory {
     // this map only ensures JVM keep alive socket caching works properly
-    private final ConcurrentMap<URI, SSLSocketFactory> socketFactoryMap = new ConcurrentHashMap<>();
-    private final Queue<byte[]> drainBuffers = new ConcurrentLinkedQueue<>();
+    private final ConcurrentMap<URI, SSLSocketFactory> socketFactoryMap = new ConcurrentHashMap<URI,
SSLSocketFactory>();
+    private final Queue<byte[]> drainBuffers = new ConcurrentLinkedQueue<byte[]>();
 
     @Override
     public Connection getConnection(final URI uri) throws IOException {
@@ -74,7 +74,10 @@ public class HttpConnectionFactory implements ConnectionFactory {
                 throw new IllegalArgumentException("Invalid uri " + uri.toString(), e);
             }
 
-            httpURLConnection = (HttpURLConnection) url.openConnection();
+            final String authorization = params.get("authorization");
+
+            httpURLConnection = (HttpURLConnection) (authorization == null ?
+                    url : new URL(stripQuery(url.toExternalForm(), "authorization"))).openConnection();
             httpURLConnection.setDoOutput(true);
 
             final int timeout;
@@ -89,8 +92,8 @@ public class HttpConnectionFactory implements ConnectionFactory {
             if (params.containsKey("readTimeout")) {
                 httpURLConnection.setReadTimeout(Integer.parseInt(params.get("readTimeout")));
             }
-            if (params.containsKey("authorization")) {
-                httpURLConnection.setRequestProperty("Authorization", params.get("authorization"));
+            if (authorization != null) {
+                httpURLConnection.setRequestProperty("Authorization", authorization);
             }
 
             if (params.containsKey("sslKeyStore") || params.containsKey("sslTrustStore"))
{
@@ -105,7 +108,9 @@ public class HttpConnectionFactory implements ConnectionFactory {
                     }
 
                     ((HttpsURLConnection) httpURLConnection).setSSLSocketFactory(sslSocketFactory);
-                } catch (final NoSuchAlgorithmException | KeyManagementException e) {
+                } catch (final KeyManagementException e) {
+                    throw new ClientRuntimeException(e.getMessage(), e);
+                } catch (final NoSuchAlgorithmException e) {
                     throw new ClientRuntimeException(e.getMessage(), e);
                 }
             }
@@ -117,6 +122,18 @@ public class HttpConnectionFactory implements ConnectionFactory {
             }
         }
 
+        private String stripQuery(final String url, final String param) {
+            String result = url;
+            do {
+                final int h = result.indexOf(param + '=');
+                final int end = result.indexOf('&', h);
+                if (h <= 0) {
+                    return result;
+                }
+                result = result.substring(0, h - 1) + (end < 0 ? "" : result.substring(end
+ 1, result.length()));
+            } while (true);
+        }
+
         @Override
         public void discard() {
             try {

http://git-wip-us.apache.org/repos/asf/tomee/blob/1f4b821b/server/openejb-client/src/main/java/org/apache/openejb/client/ResourceFinder.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/ResourceFinder.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/ResourceFinder.java
index b768b75..848a30f 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/ResourceFinder.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/ResourceFinder.java
@@ -1067,8 +1067,10 @@ public class ResourceFinder {
                         return resourceURL;
                     }
                 }
-            } catch (SecurityException | IOException e) {
+            } catch (final IOException e) {
                 // Keep iterating through the URL list
+            } catch (final SecurityException e) {
+                // no-op
             }
         }
         return null;

http://git-wip-us.apache.org/repos/asf/tomee/blob/1f4b821b/server/openejb-client/src/main/java/org/apache/openejb/client/ServiceLocator.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/ServiceLocator.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/ServiceLocator.java
index 72b42bd..ed18d54 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/ServiceLocator.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/ServiceLocator.java
@@ -58,7 +58,9 @@ public class ServiceLocator {
     public Object lookup(final String name) {
         try {
             return context.lookup(name);
-        } catch (NamingException | RuntimeException e) {
+        } catch (final RuntimeException e) {
+            throw new IllegalArgumentException(e);
+        } catch (final NamingException e) {
             throw new IllegalArgumentException(e);
         }
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/1f4b821b/server/openejb-client/src/main/java/org/apache/openejb/client/proxy/Jdk13ProxyFactory.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/proxy/Jdk13ProxyFactory.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/proxy/Jdk13ProxyFactory.java
index a8e0f8e..e0c7fbb 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/proxy/Jdk13ProxyFactory.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/proxy/Jdk13ProxyFactory.java
@@ -108,7 +108,7 @@ public class Jdk13ProxyFactory implements ProxyFactory {
             //noinspection RedundantArrayCreation
             return cons.newInstance(new Object[]{new Jdk13InvocationHandler()});
 
-        } catch (NoSuchMethodException | InvocationTargetException | InstantiationException
| IllegalAccessException e) {
+        } catch (final Exception e) {
             throw new InternalError(e.toString());
         }
     }

http://git-wip-us.apache.org/repos/asf/tomee/blob/1f4b821b/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
b/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
index a37d8d3..1f6717e 100644
--- a/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
+++ b/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
@@ -48,6 +48,10 @@ public class HttpConnectionTest {
 
                 final OutputStream responseBody = exchange.getResponseBody();
                 responseBody.write("secure page".getBytes());
+                final String query = exchange.getRequestURI().getQuery();
+                if (query != null) {
+                    responseBody.write(query.getBytes());
+                }
                 final String authorization = exchange.getRequestHeaders().getFirst("Authorization");
                 if (authorization != null) {
                     responseBody.write(authorization.getBytes("UTF-8"));


Mime
View raw message