Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 50744 invoked from network); 9 Jun 2006 10:41:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Jun 2006 10:41:23 -0000 Received: (qmail 9239 invoked by uid 500); 9 Jun 2006 10:41:22 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 9187 invoked by uid 500); 9 Jun 2006 10:41:21 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 9176 invoked by uid 500); 9 Jun 2006 10:41:21 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 9173 invoked by uid 99); 9 Jun 2006 10:41:21 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Jun 2006 03:41:21 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Jun 2006 03:41:20 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id A216B1A983A; Fri, 9 Jun 2006 03:41:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r413005 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http: AbstractHTTPSender.java HTTPConstants.java HttpTransportProperties.java SOAPOverHTTPSender.java Date: Fri, 09 Jun 2006 10:40:59 -0000 To: axis2-cvs@ws.apache.org From: saminda@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060609104100.A216B1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: saminda Date: Fri Jun 9 03:40:59 2006 New Revision: 413005 URL: http://svn.apache.org/viewvc?rev=413005&view=rev Log: Proper fix to NTLM Auth. Introduce new property NTLM_AUTHENTICATION AND NTLMAuthentication bean. Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HttpTransportProperties.java webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?rev=413005&r1=413004&r2=413005&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original) +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Fri Jun 9 03:40:59 2006 @@ -1,19 +1,19 @@ -/* -* Copyright 2004,2005 The Apache Software Foundation. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - +/* +* Copyright 2004,2005 The Apache Software Foundation. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + package org.apache.axis2.transport.http; import org.apache.axiom.om.OMAttribute; @@ -287,7 +287,7 @@ throws AxisFault { boolean isHostProxy = isProxyListed(msgCtx); // list the proxy - boolean basicAuthenticationEnabled = serverBasicPreemtiveAuthentication(msgCtx); // server authentication + boolean authenticationEnabled = serverPreemtiveAuthentication(msgCtx); // server authentication int port = targetURL.getPort(); if (port == -1) { @@ -297,14 +297,14 @@ // to see the host is a proxy and in the proxy list - available in axis2.xml HostConfiguration config = new HostConfiguration(); - if (!isHostProxy && !basicAuthenticationEnabled) { + if (!isHostProxy && !authenticationEnabled) { config.setHost(targetURL.getHost(), port, targetURL.getProtocol()); - }else if(basicAuthenticationEnabled){ - // premtive authentication + }else if(authenticationEnabled){ + // premtive authentication Basic or NTLM this.configServerPreemtiveAuthenticaiton(client,msgCtx,config,targetURL); } else { - // proxy and NTLM configuration + // proxy configuration this.configProxyAuthentication(client, proxyOutSetting, config, msgCtx); } @@ -312,6 +312,35 @@ return config; } + private boolean NTLMAuthentication(HttpClient agent, + MessageContext msgCtx) { + HttpTransportProperties.NTLMAuthentication ntlmAuthentication = + (HttpTransportProperties.NTLMAuthentication) msgCtx + .getProperty(HTTPConstants.NTLM_AUTHENTICATION); + Credentials defaultCredentials; + if (ntlmAuthentication != null) { + + if (ntlmAuthentication.getRealm() == null) { + defaultCredentials = new UsernamePasswordCredentials( + ntlmAuthentication.getUsername(), + ntlmAuthentication.getPassword()); + } else { + defaultCredentials = new NTCredentials( + ntlmAuthentication.getUsername(), + ntlmAuthentication.getPassword(), + ntlmAuthentication.getHost(), + ntlmAuthentication.getRealm()); + } + agent.getState().setCredentials(new AuthScope( + ntlmAuthentication.getHost(), + ntlmAuthentication.getPort(), + null), defaultCredentials); + return true; + } + return false; + + } + private void configServerPreemtiveAuthenticaiton(HttpClient agent, MessageContext msgCtx, HostConfiguration config, @@ -321,42 +350,39 @@ agent.getParams().setAuthenticationPreemptive(true); + + Credentials defaultCredentials = null; + + // check for NTLM Authentication + boolean bntlm = NTLMAuthentication(agent, msgCtx); + HttpTransportProperties.BasicAuthentication basicAuthentication = (HttpTransportProperties.BasicAuthentication) msgCtx .getProperty(HTTPConstants.BASIC_AUTHENTICATION); - Credentials defaultCredentials = null; - if (basicAuthentication.getRealm() == null) { + + if (basicAuthentication != null && !bntlm) { defaultCredentials = new UsernamePasswordCredentials( basicAuthentication.getUsername(), basicAuthentication.getPassword()); - } else { - defaultCredentials = new NTCredentials( - basicAuthentication.getUsername(), - basicAuthentication.getPassword(), - basicAuthentication.getHost(), - basicAuthentication.getRealm()); - agent.getState().setCredentials(new AuthScope( - basicAuthentication.getHost(), - basicAuthentication.getPort(), - null), defaultCredentials); - - return; - } - if (basicAuthentication.getPort() == -1 || - basicAuthentication.getHost() == null) { - agent.getState().setCredentials(AuthScope.ANY, defaultCredentials); - } else { - if (basicAuthentication.getRealm() == null) { - agent.getState().setCredentials(new AuthScope( - basicAuthentication.getHost(), - basicAuthentication.getPort(), - AuthScope.ANY_REALM), defaultCredentials); + if (basicAuthentication.getPort() == -1 || + basicAuthentication.getHost() == null) { + agent.getState() + .setCredentials(AuthScope.ANY, defaultCredentials); } else { - agent.getState().setCredentials(new AuthScope( - basicAuthentication.getHost(), - basicAuthentication.getPort(), - basicAuthentication.getRealm()), defaultCredentials); + if (basicAuthentication.getRealm() == null) { + agent.getState().setCredentials(new AuthScope( + basicAuthentication.getHost(), + basicAuthentication.getPort(), + AuthScope.ANY_REALM), defaultCredentials); + + } else { + agent.getState().setCredentials(new AuthScope( + basicAuthentication.getHost(), + basicAuthentication.getPort(), + basicAuthentication.getRealm()), + defaultCredentials); + } } } @@ -397,10 +423,10 @@ //Server Preemptive Authentication RUNTIME - private boolean serverBasicPreemtiveAuthentication(MessageContext msgContext) { + private boolean serverPreemtiveAuthentication(MessageContext msgContext) { - return msgContext.getProperty(HTTPConstants.BASIC_AUTHENTICATION) != - null; + return (msgContext.getProperty(HTTPConstants.BASIC_AUTHENTICATION) != + null || msgContext.getProperty(HTTPConstants.NTLM_AUTHENTICATION) != null); } private boolean isProxyListed(MessageContext msgCtx) throws AxisFault { Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java?rev=413005&r1=413004&r2=413005&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java (original) +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java Fri Jun 9 03:40:59 2006 @@ -371,6 +371,7 @@ public static final byte SENDER[] = "400".getBytes(); public static final String PROXY = "PROXY"; public static final String BASIC_AUTHENTICATION = "_BASIC_AUTHENTICATION_"; + public static final String NTLM_AUTHENTICATION = "_NTLM_AUTHENTICATION_"; public static final String MTOM_RECEIVED_CONTENT_TYPE = "MTOM_RECEIVED"; /** Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HttpTransportProperties.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HttpTransportProperties.java?rev=413005&r1=413004&r2=413005&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HttpTransportProperties.java (original) +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HttpTransportProperties.java Fri Jun 9 03:40:59 2006 @@ -162,4 +162,51 @@ this.password = password; } } + public class NTLMAuthentication{ + private String host; + private int port = -1; + private String realm; + private String username; + private String password; + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getRealm() { + return realm; + } + + public void setRealm(String realm) { + this.realm = realm; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + } } Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java?rev=413005&r1=413004&r2=413005&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java (original) +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java Fri Jun 9 03:40:59 2006 @@ -1,19 +1,19 @@ -/* -* Copyright 2004,2005 The Apache Software Foundation. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - +/* +* Copyright 2004,2005 The Apache Software Foundation. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + package org.apache.axis2.transport.http; import org.apache.axiom.om.OMElement; @@ -189,9 +189,16 @@ this.soapActionString = soapActionString; } - private void handleOMOutput(OutputStream out, boolean doingMTOM) throws XMLStreamException { + private void handleOMOutput(OutputStream out, boolean doingMTOM) + throws XMLStreamException { format.setDoOptimize(doingMTOM); - element.serializeAndConsume(out, format); + // To support NTLM Authentication the following check has been done. + if (msgCtxt.getProperty(HTTPConstants.NTLM_AUTHENTICATION) != null) + { + element.serialize(out, format); + } else { + element.serializeAndConsume(out, format); + } } public byte[] writeBytes() throws AxisFault { --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org