You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2016/11/28 23:22:23 UTC

[02/14] tomee git commit: cannot figure out this damned "Undefined realm:tomee:tomee:Undefined" issue

cannot figure out this damned "Undefined realm:tomee:tomee:Undefined" issue


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

Branch: refs/heads/tomee-1.7.x
Commit: ca5545a89ad92a8e684f133aeb95890ed02167b9
Parents: 57a4dec
Author: Jonathan S. Fisher <jf...@tomitribe.com>
Authored: Fri Nov 4 15:20:01 2016 -0500
Committer: Jonathan S. Fisher <jf...@tomitribe.com>
Committed: Fri Nov 4 15:20:01 2016 -0500

----------------------------------------------------------------------
 .../java/org/apache/openejb/client/Client.java  | 120 ++++++++-----------
 .../openejb/client/HttpConnectionFactory.java   |  13 +-
 .../org/apache/openejb/client/JNDIContext.java  |  26 ++--
 .../apache/openejb/client/JNDIContextAuth.java  |  79 ------------
 .../apache/openejb/client/ServerMetaData.java   |  46 ++++++-
 .../openejb/client/ServerMetaDataTest.java      |   1 -
 .../catalina/remote/TomEERemoteWebapp.java      |   1 +
 7 files changed, 111 insertions(+), 175 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/ca5545a8/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 71c2c76..4cc352a 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
@@ -16,7 +16,15 @@
  */
 package org.apache.openejb.client;
 
-import static org.apache.openejb.client.Exceptions.newIOException;
+import org.apache.openejb.client.event.ClientVersion;
+import org.apache.openejb.client.event.ClusterMetaDataUpdated;
+import org.apache.openejb.client.event.ObserverAdded;
+import org.apache.openejb.client.event.RequestFailed;
+import org.apache.openejb.client.event.RetryConditionAdded;
+import org.apache.openejb.client.event.RetryConditionRemoved;
+import org.apache.openejb.client.event.RetryingRequest;
+import org.apache.openejb.client.event.ServerAdded;
+import org.apache.openejb.client.event.ServerRemoved;
 
 import java.io.EOFException;
 import java.io.IOException;
@@ -38,16 +46,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.openejb.client.HttpConnectionFactory.HttpConnection;
-import org.apache.openejb.client.event.ClientVersion;
-import org.apache.openejb.client.event.ClusterMetaDataUpdated;
-import org.apache.openejb.client.event.ObserverAdded;
-import org.apache.openejb.client.event.RequestFailed;
-import org.apache.openejb.client.event.RetryConditionAdded;
-import org.apache.openejb.client.event.RetryConditionRemoved;
-import org.apache.openejb.client.event.RetryingRequest;
-import org.apache.openejb.client.event.ServerAdded;
-import org.apache.openejb.client.event.ServerRemoved;
+import static org.apache.openejb.client.Exceptions.newIOException;
 
 public class Client {
 
@@ -138,15 +137,14 @@ public class Client {
     }
 
     public static Response request(final Request req, final Response res, final ServerMetaData server) throws RemoteException {
-        return request(req, res, server, null);
+        try {
+            return client.processRequest(req, res, server);
+        } finally {
+            failed.remove();
+        }
     }
 
     protected Response processRequest(final Request req, final Response res, final ServerMetaData server) throws RemoteException {
-        return processRequest(req, res, server, null);
-    }
-
-    protected Response processRequest(final Request req, final Response res, final ServerMetaData server,
-            JNDIContextAuth jndiContextAuth) throws RemoteException {
 
         if (server == null) {
             throw new IllegalArgumentException("Server instance cannot be null");
@@ -155,11 +153,12 @@ public class Client {
         final long start = System.nanoTime();
         final ClusterMetaData cluster = getClusterMetaData(server);
 
-        // Determine which protocol to use for request writes
+        //Determine which protocol to use for request writes
         final ProtocolMetaData protocolRequest = (null != COMPATIBLE_META_DATA ? COMPATIBLE_META_DATA : PROTOCOL_META_DATA);
 
         /*----------------------------*/
         /* Get a connection to server */
+        /*----------------------------*/
 
         final Connection conn;
         try {
@@ -168,15 +167,12 @@ public class Client {
             throw new RemoteException("Unable to connect", e);
         }
 
-        if (jndiContextAuth != null && conn instanceof HttpConnection) {
-            ((HttpConnection) conn).setAuthenticationHeader(jndiContextAuth);
-        }
-
         OutputStream out = null;
         InputStream in = null;
 
         try {
 
+
             /*----------------------------------*/
             /* Get output streams */
             /*----------------------------------*/
@@ -189,7 +185,7 @@ public class Client {
             }
 
             /*----------------------------------*/
-            /* Write the protocol magic */
+            /* Write the protocol magic         */
             /*----------------------------------*/
             try {
                 protocolRequest.writeExternal(out);
@@ -260,7 +256,7 @@ public class Client {
             }
 
             /*----------------------------------*/
-            /* Get input streams */
+            /* Get input streams               */
             /*----------------------------------*/
 
             try {
@@ -271,7 +267,7 @@ public class Client {
                 throw newIOException("Cannot open input stream to server: ", e);
             }
 
-            // Determine the server response protocol for reading
+            //Determine the server response protocol for reading
             final ProtocolMetaData protocolResponse = new ProtocolMetaData();
             try {
 
@@ -279,14 +275,11 @@ public class Client {
 
             } catch (final EOFException e) {
 
-                String message = "Prematurely reached the end of the stream.  " + protocolResponse.getSpec() + " : " + e.getMessage();
-                throw newIOException(message, e);
+                throw newIOException("Prematurely reached the end of the stream.  " + protocolResponse.getSpec() + " : " + e.getMessage(), e);
 
             } catch (final IOException e) {
 
-                String message = "Cannot determine server protocol version: Received " + protocolResponse.getSpec() + " : "
-                        + e.getMessage();
-                throw newIOException(message, e);
+                throw newIOException("Cannot determine server protocol version: Received " + protocolResponse.getSpec() + " : " + e.getMessage(), e);
             }
 
             final ObjectInput objectIn;
@@ -295,8 +288,7 @@ public class Client {
                 objectIn = new EjbObjectInputStream(in);
 
             } catch (final IOException e) {
-                String message = "Cannot open object input stream to server (" + protocolResponse.getSpec() + ") : " + e.getMessage();
-                throw newIOException(message, e);
+                throw newIOException("Cannot open object input stream to server (" + protocolResponse.getSpec() + ") : " + e.getMessage(), e);
             }
 
             /*----------------------------------*/
@@ -307,26 +299,22 @@ public class Client {
                 clusterResponse.setMetaData(protocolResponse);
                 clusterResponse.readExternal(objectIn);
                 switch (clusterResponse.getResponseCode()) {
-                case UPDATE: {
-                    setClusterMetaData(server, clusterResponse.getUpdatedMetaData());
-                }
+                    case UPDATE: {
+                        setClusterMetaData(server, clusterResponse.getUpdatedMetaData());
+                    }
                     break;
-                case FAILURE: {
-                    throw clusterResponse.getFailure();
-                }
+                    case FAILURE: {
+                        throw clusterResponse.getFailure();
+                    }
                 }
             } catch (final ClassNotFoundException e) {
-                String message = "Cannot read the cluster response from the server.  The class for an object being returned is not located in this system:";
-                throw new RemoteException(message, e);
+                throw new RemoteException("Cannot read the cluster response from the server.  The class for an object being returned is not located in this system:", e);
 
             } catch (final IOException e) {
-                String message = "Cannot read the cluster response from the server (" + protocolResponse.getSpec() + ") : "
-                        + e.getMessage();
-                throw newIOException(message, e);
+                throw newIOException("Cannot read the cluster response from the server (" + protocolResponse.getSpec() + ") : " + e.getMessage(), e);
 
             } catch (final Throwable e) {
-                String message = "Error reading cluster response from server (" + protocolResponse.getSpec() + ") : " + e.getMessage();
-                throw new RemoteException(message, e);
+                throw new RemoteException("Error reading cluster response from server (" + protocolResponse.getSpec() + ") : " + e.getMessage(), e);
             }
 
             /*----------------------------------*/
@@ -336,16 +324,13 @@ public class Client {
                 res.setMetaData(protocolResponse);
                 res.readExternal(objectIn);
             } catch (final ClassNotFoundException e) {
-                String message = "Cannot read the response from the server.  The class for an object being returned is not located in this system:";
-                throw new RemoteException(message, e);
+                throw new RemoteException("Cannot read the response from the server.  The class for an object being returned is not located in this system:", e);
 
             } catch (final IOException e) {
-                String message = "Cannot read the response from the server (" + protocolResponse.getSpec() + ") : " + e.getMessage();
-                throw newIOException(message, e);
+                throw newIOException("Cannot read the response from the server (" + protocolResponse.getSpec() + ") : " + e.getMessage(), e);
 
             } catch (final Throwable e) {
-                String message = "Error reading response from server (" + protocolResponse.getSpec() + ") : " + e.getMessage();
-                throw new RemoteException(message, e);
+                throw new RemoteException("Error reading response from server (" + protocolResponse.getSpec() + ") : " + e.getMessage(), e);
             }
 
             if (retryConditions.size() > 0) {
@@ -353,19 +338,18 @@ public class Client {
                     final EJBResponse ejbResponse = (EJBResponse) res;
                     if (ejbResponse.getResult() instanceof ThrowableArtifact) {
                         final ThrowableArtifact artifact = (ThrowableArtifact) ejbResponse.getResult();
-                        // noinspection ThrowableResultOfMethodCallIgnored
+                        //noinspection ThrowableResultOfMethodCallIgnored
                         if (retryConditions.contains(artifact.getThrowable().getClass())) {
 
                             throw new RetryException(res);
 
-                            // if (? < maxConditionRetry) {
-                            // throw new RetryException(res);
-                            // } else {
-                            // if (FINER) {
-                            // logger.log(Level.FINER, "Giving up on " +
-                            // artifact.getThrowable().getClass().getName().toString());
-                            // }
-                            // }
+                            //                            if (? < maxConditionRetry) {
+                            //                                throw new RetryException(res);
+                            //                            } else {
+                            //                                if (FINER) {
+                            //                                    logger.log(Level.FINER, "Giving up on " + artifact.getThrowable().getClass().getName().toString());
+                            //                                }
+                            //                            }
                         }
                     }
                 }
@@ -373,8 +357,7 @@ public class Client {
 
             if (FINEST) {
                 final long time = System.nanoTime() - start;
-                final String message = String.format("Invocation %sns - %s - Request(%s) - Response(%s)", time, conn.getURI(), req,
-                        res);
+                final String message = String.format("Invocation %sns - %s - Request(%s) - Response(%s)", time, conn.getURI(), req, res);
                 logger.log(Level.FINEST, message);
             }
 
@@ -397,7 +380,7 @@ public class Client {
 
                     Client.fireEvent(new RetryingRequest(req, server));
 
-                    processRequest(req, res, server, jndiContextAuth);
+                    processRequest(req, res, server);
                 } catch (final RemoteFailoverException re) {
                     throw re;
                 } catch (final RemoteException re) {
@@ -425,15 +408,6 @@ public class Client {
         return res;
     }
 
-    public static Response request(final Request req, final Response res, final ServerMetaData server, JNDIContextAuth jndiContextAuth)
-            throws RemoteException {
-        try {
-            return client.processRequest(req, res, server, jndiContextAuth);
-        } finally {
-            failed.remove();
-        }
-    }
-
     public static Set<URI> getFailed() {
         Set<URI> set = failed.get();
         if (set == null) {
@@ -452,7 +426,7 @@ public class Client {
         return getContext(server).getClusterMetaData();
     }
 
-    // openejb.client.connection.strategy
+    //openejb.client.connection.strategy
 
     private boolean getRetry() {
         return retry = Boolean.valueOf(System.getProperty("openejb.client.requestretry", retry + ""));

http://git-wip-us.apache.org/repos/asf/tomee/blob/ca5545a8/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 4551305..9cb86bd 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
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 package org.apache.openejb.client;
-
+import static javax.xml.bind.DatatypeConverter.printBase64Binary;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -23,6 +23,7 @@ import java.net.HttpURLConnection;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
 import java.util.Map;
@@ -92,6 +93,12 @@ public class HttpConnectionFactory implements ConnectionFactory {
                 httpURLConnection.setReadTimeout(Integer.parseInt(params.get("readTimeout")));
             }
 
+            if (uri.getUserInfo() != null) {
+                String authorization = "Basic "
+                        + printBase64Binary((url.getUserInfo()).getBytes(StandardCharsets.UTF_8));
+                httpURLConnection.setRequestProperty("Authorization", authorization);
+            }
+
             if (params.containsKey("sslKeyStore") || params.containsKey("sslTrustStore")) {
                 try {
                     SSLSocketFactory sslSocketFactory = socketFactoryMap.get(uri);
@@ -182,9 +189,5 @@ public class HttpConnectionFactory implements ConnectionFactory {
             }
             return inputStream;
         }
-
-        public void setAuthenticationHeader(JNDIContextAuth jndiContextAuth) {
-            jndiContextAuth.setAuthenticationHeader(httpURLConnection);
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/ca5545a8/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
index b97b636..94dd9c3 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java
@@ -88,7 +88,6 @@ public class JNDIContext implements InitialContextFactory, Context {
     private ClientInstance clientIdentity;
     // TODO read HTTP_AUTH_DISABLE on creation
     private boolean disableHttpAuth = false;
-    private JNDIContextAuth jndiContextAuth;
 
     private static final ThreadPoolExecutor GLOBAL_CLIENT_POOL = newExecutor(10, null);
 
@@ -226,19 +225,16 @@ public class JNDIContext implements InitialContextFactory, Context {
         req.setServerHash(server.buildHash());
 
         final JNDIResponse response = new JNDIResponse();
-        if (authenticationInfo != null && !disableHttpAuth){
-            Client.request(req, response, server, jndiContextAuth);
-        } else {
-            Client.request(req, response, server, null);
-        }
+        Client.request(req, response, server);
         if (null != response.getServer()) {
             server.merge(response.getServer());
         }
         return response;
     }
 
+
     protected AuthenticationResponse requestAuthorization(final AuthenticationRequest req) throws RemoteException {
-        return (AuthenticationResponse) Client.request(req, new AuthenticationResponse(), server, jndiContextAuth);
+        return (AuthenticationResponse) Client.request(req, new AuthenticationResponse(), server);
     }
 
     @Override
@@ -249,8 +245,7 @@ public class JNDIContext implements InitialContextFactory, Context {
             env = (Hashtable) environment.clone();
         }
 
-        jndiContextAuth = new JNDIContextAuth((String) env.get(Context.SECURITY_PRINCIPAL),
-                ((String) env.get(Context.SECURITY_CREDENTIALS)));
+
         String providerUrl = (String) env.get(Context.PROVIDER_URL);
 
         final boolean authWithRequest = "true"
@@ -267,6 +262,11 @@ public class JNDIContext implements InitialContextFactory, Context {
                             .initCause(e);
         }
         this.server = new ServerMetaData(location);
+        String securityPrincipal = (String) env.get(Context.SECURITY_PRINCIPAL);
+        String securityCredentials = (String) env.get(Context.SECURITY_CREDENTIALS);
+        if (securityPrincipal != null) {
+            server = new ServerMetaData(server, securityPrincipal, securityCredentials);
+        }
 
         final Client.Context context = Client.getContext(this.server);
         context.getProperties().putAll(environment);
@@ -278,12 +278,12 @@ public class JNDIContext implements InitialContextFactory, Context {
 
         // TODO: Either aggressively initiate authentication or wait for the
         // server to send us an authentication challenge.
-        if (jndiContextAuth.username != null) {
+        if (securityPrincipal != null) {
             if (!authWithRequest) {
-                authenticate(jndiContextAuth.username, String.valueOf(jndiContextAuth.password), false);
+                authenticate(securityPrincipal, securityCredentials, false);
             } else {
                 authenticationInfo = new AuthenticationInfo(String.class.cast(env.get(AUTHENTICATION_REALM_NAME)),
-                        jndiContextAuth.username, jndiContextAuth.password, getTimeout(env));
+                        securityPrincipal, securityCredentials.toCharArray(), getTimeout(env));
             }
         }
         if (client == null) {
@@ -370,7 +370,7 @@ public class JNDIContext implements InitialContextFactory, Context {
 
     public void authenticate(final String userID, final String psswrd, final boolean logout)
             throws AuthenticationException {
-
+//TODO needs http auth
         final AuthenticationRequest req = new AuthenticationRequest(
                 String.class.cast(env.get(AUTHENTICATION_REALM_NAME)), userID, psswrd, getTimeout(env));
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/ca5545a8/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContextAuth.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContextAuth.java b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContextAuth.java
deleted file mode 100644
index 6fb7f98..0000000
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContextAuth.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.apache.openejb.client;
-
-import static javax.xml.bind.DatatypeConverter.printBase64Binary;
-
-import java.io.Serializable;
-import java.net.HttpURLConnection;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-
-public class JNDIContextAuth implements Serializable {
-    private static final long serialVersionUID = 1L;
-    public final String username;
-    public final char[] password;
-
-    public JNDIContextAuth(String username, String password) {
-        this.username = username;
-        if (password != null) {
-            this.password = password.toCharArray();
-        } else {
-            this.password = new char[0];
-        }
-        checkConstraints();
-    }
-
-    public void checkConstraints() {
-        if (username == null) {
-            throw new IllegalArgumentException("username cannot be null, don't use this class if you don't have a username");
-        }
-    }
-
-    public void setAuthenticationHeader(HttpURLConnection httpURLConnection) {
-        httpURLConnection.setRequestProperty("Authorization", "Basic " + toEncodedString());
-    }
-
-    public String toEncodedString() {
-        byte[] message = (username + ":" + String.valueOf(password)).getBytes(StandardCharsets.UTF_8);
-        String encoded = printBase64Binary(message);
-        return encoded;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + Arrays.hashCode(password);
-        result = prime * result + ((username == null) ? 0 : username.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (!(obj instanceof JNDIContextAuth)) {
-            return false;
-        }
-        JNDIContextAuth other = (JNDIContextAuth) obj;
-        if (!Arrays.equals(password, other.password)) {
-            return false;
-        }
-        if (username == null) {
-            if (other.username != null) {
-                return false;
-            }
-        } else if (!username.equals(other.username)) {
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public String toString() {
-        return "JNDIContextAuth [username=" + username + ", password=" + Arrays.toString(password) + "]";
-    }
-}

http://git-wip-us.apache.org/repos/asf/tomee/blob/ca5545a8/server/openejb-client/src/main/java/org/apache/openejb/client/ServerMetaData.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/ServerMetaData.java b/server/openejb-client/src/main/java/org/apache/openejb/client/ServerMetaData.java
index bb9e36d..60c9c92 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/ServerMetaData.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/ServerMetaData.java
@@ -21,23 +21,62 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 public class ServerMetaData implements Externalizable {
 
     private static final long serialVersionUID = -915541900332460068L;
+    private static final transient Pattern urlPattern = Pattern.compile("http(?s):\\/\\/(.+):(.+)@.*");
     private transient URI[] locations;
     private transient URI location;
     private transient ProtocolMetaData metaData;
 
-    public ServerMetaData() {
-    }
-
     public ServerMetaData(final URI... locations) {
         this.locations = locations;
         location = locations[0];
     }
 
+    public ServerMetaData(ServerMetaData server, String securityPrincipal, String securityCredentials) {
+        List<URI> locationList = new ArrayList<URI>(server.locations.length);
+        for (URI uri : server.locations) {
+            uri = addUserToURI(securityPrincipal, securityPrincipal, uri);
+            locationList.add(uri);
+        }
+        locations = locationList.toArray(new URI[server.locations.length]);
+        location = addUserToURI(securityPrincipal, securityPrincipal, server.location);
+        this.metaData = server.metaData;
+    }
+
+    private URI addUserToURI(String securityPrincipal, String securityCredentials, URI uri) {
+        String uriString = uri.toString();
+        Matcher matcher = urlPattern.matcher(uriString);
+        if (!matcher.matches()) {
+            String restOfUrl = null;
+            String scheme = null;
+            if (uriString.startsWith("http://")) {
+                restOfUrl = uriString.substring("http://".length());
+                scheme = "http://";
+            } else if (uriString.startsWith("https://")) {
+                restOfUrl = uriString.substring("https://".length());
+                scheme = "https://";
+            }
+            if (restOfUrl != null) {
+                try {
+                    uri = new URI(scheme + securityPrincipal + ":" + (securityCredentials == null ? "" : securityCredentials) + "@"
+                            + restOfUrl);
+                } catch (URISyntaxException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+        return uri;
+    }
+
     public void setMetaData(final ProtocolMetaData metaData) {
         this.metaData = metaData;
     }
@@ -100,4 +139,3 @@ public class ServerMetaData implements Externalizable {
         return (location != null ? location.hashCode() : 0);
     }
 }
-

http://git-wip-us.apache.org/repos/asf/tomee/blob/ca5545a8/server/openejb-client/src/test/java/org/apache/openejb/client/ServerMetaDataTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/test/java/org/apache/openejb/client/ServerMetaDataTest.java b/server/openejb-client/src/test/java/org/apache/openejb/client/ServerMetaDataTest.java
index 365deff..b578695 100644
--- a/server/openejb-client/src/test/java/org/apache/openejb/client/ServerMetaDataTest.java
+++ b/server/openejb-client/src/test/java/org/apache/openejb/client/ServerMetaDataTest.java
@@ -29,5 +29,4 @@ public class ServerMetaDataTest extends TestCase {
         final ServerMetaData server2 = new ServerMetaData(uri2, uri1);
         assertEquals(server1.buildHash(), server2.buildHash());
     }
-
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/ca5545a8/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
index 006db5e..8946428 100644
--- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
+++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/remote/TomEERemoteWebapp.java
@@ -47,6 +47,7 @@ public class TomEERemoteWebapp extends IgnoredStandardContext {
         if (BASIC_AUTH_ROLE_NAME != null) {
             LoginConfig config = new LoginConfig();
             config.setAuthMethod("BASIC");
+            config.setRealmName("TomEERemoteWebapp");
             SecurityConstraint constraint = new SecurityConstraint();
             SecurityCollection collection = new SecurityCollection();
             collection.addPattern("/*");