-
1. Re: Mappoint Digest Authentication and JBoss Configuration
thomas.diesler Mar 4, 2005 1:32 PM (in response to pnichols_sr)Are you saying that Digest Authentication does not work? If so, could you please create a sample deployment and a JIRA issue? Thanks.
-
2. Re: Mappoint Digest Authentication and JBoss Configuration
pnichols_sr Mar 4, 2005 1:49 PM (in response to pnichols_sr)Correct.. Digest Authentication did not work in Axis 1.1 (do not know about 1.2), so you needed to override the Basic Handler. Since MS uses Digest Authentication with the MapPoint Web Service, I must use it :)
I am not sure what you are asking in terms of a sample deployment, since I am consuming a Web service, not creating one.
As stated my work around works fine in Tomcat 5.0, but not so in JBoss. I am sure this is a configuration issue (on my part), but I do not knwo how to resolve it.
I can include the src for the Override Sender I am using, and the config file.
source for SimpleHttpSender:
import java.io.*;
import java.net.*;
import org.apache.axis.*;
import org.apache.axis.handlers.*;
/**
* SimpleHTTPSender is an HTTP transport handler for the Axis library, providing
* basic HTTP communication with the server. This class is needed in order to use
* MapPoint .NET, because Axis does not yet support digest authentication. The
* CommonsHTTPSender almost works, but it currently fails with large POST requests,
* such as those that are sent when calling GetRouteMap with a very long route.
public class SimpleHTTPSender extends BasicHandler {
/**
* SimpleAuthenticator provides the user name and password to an URLConnection.
*/
private static class SimpleAuthenticator extends Authenticator {
private PasswordAuthentication m_authentication;
SimpleAuthenticator(String userName, String password) {
m_authentication = new PasswordAuthentication(userName, password.toCharArray());
}
protected PasswordAuthentication getPasswordAuthentication() {
return m_authentication;
}
}
/**
* Invoke a remote call using an URLConnection. This method is called by Axis.
*/
public void invoke(MessageContext messageContext)
throws AxisFault {
try {
String userName = messageContext.getUsername();
String password = messageContext.getPassword();
if (userName != null && password != null) {
Authenticator.setDefault(new SimpleAuthenticator(userName, password));
}
URL url = new URL(messageContext.getStrProp(MessageContext.TRANS_URL));
URLConnection conn = url.openConnection();
writeToConnection(conn, messageContext);
readFromConnection(conn, messageContext);
}
catch (Exception e) {
throw AxisFault.makeFault(e);
}
finally {
Authenticator.setDefault(null);
}
}
/**
* Write the SOAP request message to an URLConnection.
*/
private void writeToConnection(URLConnection conn, MessageContext messageContext)
throws Exception {
conn.setDoOutput(true);
Message request = messageContext.getRequestMessage();
String contentType = request.getContentType(messageContext.getSOAPConstants());
conn.setRequestProperty("Content-Type", contentType);
if (messageContext.useSOAPAction()) {
conn.setRequestProperty("SOAPAction", messageContext.getSOAPActionURI());
}
OutputStream out = new BufferedOutputStream(conn.getOutputStream(), 8192);
request.writeTo(out);
out.flush();
}
/**
* Read the SOAP response message from an URLConnection.
*/
private void readFromConnection(URLConnection conn, MessageContext messageContext)
throws Exception {
String contentType = conn.getContentType();
String contentLocation = conn.getHeaderField("Content-Location");
InputStream in = ((HttpURLConnection) conn).getErrorStream();
if (in == null) {
in = conn.getInputStream();
}
in = new BufferedInputStream(in, 8192);
Message response = new Message(in, false, contentType, contentLocation);
response.setMessageType(Message.RESPONSE);
messageContext.setResponseMessage(response);
}
}
Config file:
client-config.wsdd
<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultClientConfig"
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
Hope this helps explain the situation.