TIBCO BusinessWorks and NTLMv2 (Microsoft Sharepoint 2010) part 1

By | 2014/04/22
This entry is part 1 of 1 in the series TIBCO BusinessWorks and NTLMv2 (Microsoft Sharepoint 2010)
  • TIBCO BusinessWorks and NTLMv2 (Microsoft Sharepoint 2010) part 1

Since version 5.10 of BusinessWorks (BW) NTLMv2 is supported natively. But how to make previous versions of BW compatible with it?
Actually I have no idea how to make it compatible, but at least I can share some workaround: proxy. I have found the solution somehwere in web, and after couple adjustments it appears to do what I wanted (version with apache’s httpclient)..

  1. java code parameters (java code activity configuration)
    parameters_soap
  2. java code:
    1. imports:
      import java.io.IOException;
      import java.nio.charset.Charset;
      import java.security.cert.CertificateException;
      import java.util.concurrent.Callable;
      import java.util.concurrent.ExecutorService;
      import java.util.concurrent.Executors;
      import java.util.concurrent.Future;
      import java.util.concurrent.TimeUnit;
      import java.util.concurrent.TimeoutException;
      import java.util.regex.Matcher;
      import java.util.regex.Pattern;
        
      import javax.net.ssl.SSLContext;
      import javax.net.ssl.SSLException;
      import javax.net.ssl.SSLSession;
      import javax.net.ssl.SSLSocket;
      import javax.net.ssl.TrustManager;
      import javax.net.ssl.X509TrustManager;
        
      import org.apache.http.Header;
      import org.apache.http.HttpHeaders;
      import org.apache.http.HttpStatus;
      import org.apache.http.StatusLine;
      import org.apache.http.auth.AuthScope;
      import org.apache.http.auth.NTCredentials;
      import org.apache.http.client.methods.HttpPost;
      import org.apache.http.conn.ClientConnectionManager;
      import org.apache.http.conn.scheme.PlainSocketFactory;
      import org.apache.http.conn.scheme.Scheme;
      import org.apache.http.conn.scheme.SchemeRegistry;
      import org.apache.http.conn.ssl.SSLSocketFactory;
      import org.apache.http.conn.ssl.X509HostnameVerifier;
      import org.apache.http.entity.ContentType;
      import org.apache.http.entity.StringEntity;
      import org.apache.http.impl.client.BasicResponseHandler;
      import org.apache.http.impl.client.DefaultHttpClient;
      import org.apache.http.impl.conn.BasicClientConnectionManager;
      import org.apache.http.message.BasicHttpResponse;
    2. main class – part automatically created by Tibco BusinessWorks to allow passing and receiving parameters:
      public class SSOAuthentication4SOAPForwardrequest {
          /****** START SET/GET METHOD, DO NOT MODIFY *****/
          protected String method              = "";
          protected String endpoint            = "";
          protected String soapAction          = "";
          protected String soapRequest         = "";
          protected String userName            = "";
          protected String password            = "";
          protected String domain              = "";
          protected String contentType         = "";
          protected String charset             = "";
          protected int    timeout             = 0;
          protected String host                = "";
          protected String statusLine          = "";
          protected String responseBody        = "";
          protected String responseContentType = "";
        
          public String getmethod() {
              return method;
          }
        
          public void setmethod(String val) {
              method = val;
          }
        
          public String getendpoint() {
              return endpoint;
          }
        
          public void setendpoint(String val) {
              endpoint = val;
          }
        
          public String getsoapAction() {
              return soapAction;
          }
        
          public void setsoapAction(String val) {
              soapAction = val;
          }
        
          public String getsoapRequest() {
              return soapRequest;
          }
        
          public void setsoapRequest(String val) {
              soapRequest = val;
          }
        
          public String getuserName() {
              return userName;
          }
        
          public void setuserName(String val) {
              userName = val;
          }
        
          public String getpassword() {
              return password;
          }
        
          public void setpassword(String val) {
              password = val;
          }
        
          public String getdomain() {
              return domain;
          }
        
          public void setdomain(String val) {
              domain = val;
          }
        
          public String getcontentType() {
              return contentType;
          }
        
          public void setcontentType(String val) {
              contentType = val;
          }
        
          public String getcharset() {
              return charset;
          }
        
          public void setcharset(String val) {
              charset = val;
          }
        
          public int gettimeout() {
              return timeout;
          }
        
          public void settimeout(int val) {
              timeout = val;
          }
        
          public String gethost() {
              return host;
          }
        
          public void sethost(String val) {
              host = val;
          }
        
          public String getstatusLine() {
              return statusLine;
          }
        
          public void setstatusLine(String val) {
              statusLine = val;
          }
        
          public String getresponseBody() {
              return responseBody;
          }
        
          public void setresponseBody(String val) {
              responseBody = val;
          }
        
          public String getresponseContentType() {
              return responseContentType;
          }
        
          public void setresponseContentType(String val) {
              responseContentType = val;
          }
        
          /****** END SET/GET METHOD, DO NOT MODIFY *****/
    3. inner classes – defined inside the SSOAuthentication4SOAPForwardrequest class:
      1. TimedWrapper class which is just implementation of Callable<MyHttpPost> interface
            private class TimedWrapper implements Callable<MyHttpPost> {
                MyHttpPost post;
          
                public TimedWrapper(MyHttpPost post) {
                    this.post = post;
                }
          
                @Override
                public MyHttpPost call() throws Exception {
                    post = new MyHttpPost(endpoint);
                    post.run();
                    return post;
                }
            }

Leave a Reply

Your email address will not be published. Required fields are marked *