[
http://jira.jboss.com/jira/browse/JBESB-1391?page=comments#action_12390361 ]
Faisal Azizullah commented on JBESB-1391:
-----------------------------------------
the Junit test case is as follows
package net.lisd.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.FileRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.http.configurators.AuthNTLM;
import junit.framework.Assert;
import junit.framework.TestCase;
public class NTLMAuthTest extends TestCase
{
public void testNTLMAUTH()
{
String strURL = "http://xxxxxx.lisd.net/InterfaceServices";
String strXMLFilename = "c:/testNTLM/Pcard.soap"; //soap message to be send
File input = new File(strXMLFilename);
Properties props = null;
// Prepare HTTP post
PostMethod post = new PostMethod(strURL);
AuthNTLM myAuth = new AuthNTLM();
//Properties
try
{
File pro = new File("c:/testNTLM/NTLM.properties"); //properties file
FileInputStream propertiesF = new FileInputStream(pro);
props =new Properties();
props.load(propertiesF);
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
//Request content will be retrieved directly from the input stream
RequestEntity entity = new FileRequestEntity(input, "text/xml;
charset=ISO-8859-1");
post.setRequestEntity(entity);
HttpClient httpclient = new HttpClient();
try {
myAuth.configure(httpclient, props);
} catch (ConfigurationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Execute request
try {
int result = httpclient.executeMethod(post);
String aResult = post.getResponseBodyAsString();
System.out.println(aResult);
}
catch( Exception e)
{
e.printStackTrace();
Assert.assertTrue(false);
}
finally {
// Release current connection to the connection pool once you are done
post.releaseConnection();
}
}
}
NTLMConfigurator
----------------
Key: JBESB-1391
URL:
http://jira.jboss.com/jira/browse/JBESB-1391
Project: JBoss ESB
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Components: Rosetta
Affects Versions: 4.2.1
Environment: JBOSS ESB 4.2.1 GA
Reporter: Faisal Azizullah
Fix For: 4.3
Original Estimate: 0 minutes
Remaining Estimate: 0 minutes
package org.jboss.soa.esb.http.configurators;
/*
*
*@ author: Faisal Azizullah
*@ company : Lewisville ISD
*
*/
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.NTCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.http.Configurator;
import java.util.Properties;
/**
* HTTP NTLM Authentication Configurator.
* <p/>
* Properties:
* <ul>
* <li><b>username</b>: See {@link NTCredentials}.
(Required)</li>
* <li><b>password</b>: See {@link NTCredentials}.
(Required)</li>
* <li><b>authscope-host</b>: See {@link AuthScope}.
(Required)</li>
* <li><b>authscope-port</b>: See {@link AuthScope}.
(Required)</li>
* <li><b>authscope-domain</b>: See {@link AuthScope}.
(Required)</li>
* <li><b>authscope-realm</b>: See {@link AuthScope}.
(Optional)</li>
* </ul>
* <p/>
* See <a
href="http://jakarta.apache.org/commons/httpclient/authentication.ht...
Authentication Guide</a>.
*
*
*/
public class AuthNTLM extends Configurator
{
public void configure(HttpClient httpClient, Properties properties) throws
ConfigurationException {
String username = properties.getProperty("ntauth-username");
String password = properties.getProperty("ntauth-password");
String authScopeHost = properties.getProperty("ntauthscope-host");
String authScopePort = properties.getProperty("ntauthscope-port");
String authScopeRealm = properties.getProperty("ntauthscope-realm");
String authScopeDomain = properties.getProperty("ntauthscope-domain");
assertPropertySetAndNotBlank(username, "ntauth-username");
assertPropertySetAndNotBlank(password, "ntauth-password");
assertPropertySetAndNotBlank(authScopeHost, "ntauthscope-host");
assertPropertyIsInteger(authScopePort, "ntauthscope-port");
assertPropertySetAndNotBlank(authScopeDomain, "ntauthscope-domain");
Credentials creds = new NTCredentials(username,
password,authScopeHost,authScopeDomain);
AuthScope authScope;
if(authScopeRealm != null && !authScopeRealm.trim().equals(""))
{
authScope = new AuthScope(authScopeHost, Integer.parseInt(authScopePort),
authScopeRealm);
} else {
authScope = new AuthScope(authScopeHost, Integer.parseInt(authScopePort));
}
httpClient.getState().setCredentials(authScope, creds);
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira