servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r934473 - /servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
Date Thu, 15 Apr 2010 16:25:45 GMT
Author: jbonofre
Date: Thu Apr 15 16:25:45 2010
New Revision: 934473

URL: http://svn.apache.org/viewvc?rev=934473&view=rev
Log:
[SMXCOMP-698] Authentication is not implemented in the HttpProviderEndpoint.

Modified:
    servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java

Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java?rev=934473&r1=934472&r2=934473&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
(original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpProviderEndpoint.java
Thu Apr 15 16:25:45 2010
@@ -47,6 +47,8 @@ import org.apache.servicemix.http.jetty.
 import org.mortbay.jetty.client.Address;
 import org.mortbay.jetty.client.HttpClient;
 import org.mortbay.jetty.client.security.ProxyAuthorization;
+import org.mortbay.jetty.client.security.Realm;
+import org.mortbay.jetty.client.security.SimpleRealmResolver;
 import org.mortbay.thread.QueuedThreadPool;
 import org.mortbay.resource.Resource;
 
@@ -59,12 +61,13 @@ import org.mortbay.resource.Resource;
  */
 public class HttpProviderEndpoint extends ProviderEndpoint implements HttpEndpointType {
 
-    // private BasicAuthCredentials basicAuthentication;
     private HttpProviderMarshaler marshaler;
     private String locationURI;
     private int clientSoTimeout = 60000;
     private HttpClient jettyClient;
     private boolean ownClient = false;
+    private String principal;
+    private String credentials;
 
     private String proxyHost;
     private int proxyPort = 80;
@@ -222,6 +225,38 @@ public class HttpProviderEndpoint extend
     public void setGzipRequest(boolean gzipRequest) {
         this.gzipRequest = gzipRequest;
     }
+    
+    public String getPrincipal() {
+        return principal;
+    }
+    
+    /**
+     * <p>
+     * Principal used by authentication realm.
+     * </p>
+     * 
+     * @param principal the principal used by authentication realm.
+     * @org.apache.xbean.Property description="The authentication principal" 
+     */
+    public void setPrincipal(String principal) {
+        this.principal = principal;
+    }
+    
+    public String getCredentials() {
+        return this.credentials;
+    }
+    
+    /**
+     * <p>
+     * Credentials used by authentication realm.
+     * </p>
+     * 
+     * @param credentials the credentials used by authentication realm.
+     * @org.apache.xbean.Property description="The authentication credentials"
+     */
+    public void setCredentials(String credentials) {
+        this.credentials = credentials;
+    }
 
     public void process(MessageExchange exchange) throws Exception {
         if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
@@ -294,6 +329,19 @@ public class HttpProviderEndpoint extend
                     }
                 }
                 jettyClient.setSoTimeout(getClientSoTimeout());
+                if (principal != null && credentials != null) {
+                    jettyClient.setRealmResolver(new SimpleRealmResolver(new Realm() {
+                        public String getPrincipal() {
+                            return principal;
+                        }
+                        public String getCredentials() {
+                            return credentials;
+                        }
+                        public String getId() {
+                            return null;
+                        }
+                    }));
+                }
                 jettyClient.start();
             } else {
                 ownClient = false;



Mime
View raw message