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:33 UTC

[12/14] tomee git commit: Cleanup and reverted changes for Authentication Header implementation with the least amount of code changes.

Cleanup and reverted changes for Authentication Header implementation with the least amount of code changes.


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

Branch: refs/heads/tomee-1.7.x
Commit: 03e69634614db9c72a13dcab174864794f12c0d5
Parents: 62e0e31
Author: Roberto Cortez <ra...@yahoo.com>
Authored: Thu Nov 17 00:20:51 2016 +0000
Committer: Roberto Cortez <ra...@yahoo.com>
Committed: Thu Nov 17 00:20:51 2016 +0000

----------------------------------------------------------------------
 .../org/apache/openejb/client/JNDIContext.java  | 27 +++++++++-----------
 .../catalina/remote/TomEERemoteWebapp.java      |  4 ---
 2 files changed, 12 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/03e69634/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 120be87..852ebae 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
@@ -232,7 +232,8 @@ public class JNDIContext implements InitialContextFactory, Context {
             env = (Hashtable) environment.clone();
         }
 
-
+        final String userID = (String) env.get(Context.SECURITY_PRINCIPAL);
+        final String psswrd = (String) env.get(Context.SECURITY_CREDENTIALS);
         String providerUrl = (String) env.get(Context.PROVIDER_URL);
 
         final boolean authWithRequest = "true".equalsIgnoreCase(String.class.cast(env.get(AUTHENTICATE_WITH_THE_REQUEST)));
@@ -243,16 +244,14 @@ public class JNDIContext implements InitialContextFactory, Context {
             providerUrl = addMissingParts(providerUrl);
             location = new URI(providerUrl);
         } catch (final URISyntaxException e) {
-            throw (ConfigurationException) new ConfigurationException(
-                    "Property value for " + Context.PROVIDER_URL + " invalid: " + providerUrl + " - " + e.getMessage())
-                            .initCause(e);
+            throw (ConfigurationException) new ConfigurationException("Property value for " +
+                    Context.PROVIDER_URL +
+                    " invalid: " +
+                    providerUrl +
+                    " - " +
+                    e.getMessage()).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);
@@ -262,14 +261,12 @@ public class JNDIContext implements InitialContextFactory, Context {
 
         Client.fireEvent(new RemoteInitialContextCreated(location));
 
-        // TODO: Either aggressively initiate authentication or wait for the
-        // server to send us an authentication challenge.
-        if (securityPrincipal != null) {
+        //TODO: Either aggressively initiate authentication or wait for the server to send us an authentication challenge.
+        if (userID != null) {
             if (!authWithRequest) {
-                authenticate(securityPrincipal, securityCredentials, false);
+                authenticate(userID, psswrd, false);
             } else {
-                authenticationInfo = new AuthenticationInfo(String.class.cast(env.get(AUTHENTICATION_REALM_NAME)), securityPrincipal,
-                        securityCredentials.toCharArray(), getTimeout(env));
+                authenticationInfo = new AuthenticationInfo(String.class.cast(env.get(AUTHENTICATION_REALM_NAME)), userID, psswrd.toCharArray(), getTimeout(env));
             }
         }
         if (client == null) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/03e69634/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 bf7baeb..4a2bde9 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
@@ -25,16 +25,12 @@ import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.server.httpd.ServerServlet;
 import org.apache.tomee.catalina.IgnoredStandardContext;
 import org.apache.tomee.catalina.OpenEJBValve;
-import org.apache.catalina.deploy.LoginConfig;
-import org.apache.catalina.deploy.SecurityCollection;
-import org.apache.catalina.deploy.SecurityConstraint;
 
 import java.beans.PropertyChangeListener;
 
 public class TomEERemoteWebapp extends IgnoredStandardContext {
     private static final String CONTEXT_NAME = SystemInstance.get().getProperty("tomee.remote.support.context", "/tomee");
     private static final String MAPPING = SystemInstance.get().getProperty("tomee.remote.support.mapping", "/ejb");
-    
 
     public TomEERemoteWebapp() {
         setDocBase("");