multipart/form-data with WSO2 ESB - wso2-esb

I need to pass photo and access token to back end REST service. Content type
is multipart/form-data I created html form and action is endpoint of esb And I have traced the traffic on the way to ESB [A] and going out from ESB [B]. It seems slide changes on those and I have no idea to fix this. When I send captured traffic on the way to ESB [A] its accepting by back end service. But traffic which going out by ESB[B] is not accepting by back end. Means not recognized the values in boundaries. It says “values empty”
Output on the way to ESB – when this FWD to backend it recognize ==========================================================================
POST /services/postPhotoToAlbumHttpSoap11Endpoint HTTP/1.1
Host: localhost:8280
Connection: keep-alive
Content-Length: 4623
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Origin: null
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryPSfmjvLcmpwvN6Gt
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: menuPanel=visible; menuPanelType=main
X-Forwarded-For: 0:0:0:0:0:0:0:1
------WebKitFormBoundaryPSfmjvLcmpwvN6Gt
Content-Disposition: form-data; name="accessToken"
CAACEdEose0cBALXnbsnFzenjs7ni1bkLYx0Tybmfd4G5CBWifG3VnP9xWQDNT52mCWZA2dTESXYc4aMNOZAHfNUNO0jxV5IZC9PQzjeWBZCHuOOexnzpt5BmNCeZAAFb3juHU2aZAZCNLozkOYcyKUj1IOl2jYzCpTjLdnynqhsDrZCknPC9670N0bOw1cIVUohLh9OBEjqyogZDZD
------WebKitFormBoundaryPSfmjvLcmpwvN6Gt
Content-Disposition: form-data; name="source"; filename="kdinesh_LThumb.jpg"
Content-Type: image/jpeg
ÿØÿà_
Output going OUT from ESB ==========================================================================
POST /10150897830516344/photos HTTP/1.1
Accept-Language: en-US,en;q=0.8
Cookie: menuPanel=visible; menuPanelType=main
Accept-Encoding: gzip,deflate,sdch
X-Forwarded-For: 0:0:0:0:0:0:0:1
Origin: null
Content-Type: multipart/form-data
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Cache-Control: max-age=0
Transfer-Encoding: chunked
Host: api.localhost
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
X-Forwarded-For: 0:0:0:0:0:0:0:1, 127.0.0.1
1816
--MIMEBoundary_960dd4bb3066b1fff153bc3151e7776b65947ba8dd00425e
Content-Disposition: form-data; name="access_token"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
CAACEdEose0cBALXnbsnFzenjs7ni1bkLYx0Tybmfd4G5CBWifG3VnP9xWQDNT52mCWZA2dTESXYc4aMNOZAHfNUNO0jxV5IZC9PQzjeWBZCHuOOexnzpt5BmNCeZAAFb3juHU2aZAZCNLozkOYcyKUj1IOl2jYzCpTjLdnynqhsDrZCknPC9670N0bOw1cIVUohLh9OBEjqyogZDZD
--MIMEBoundary_960dd4bb3066b1fff153bc3151e7776b65947ba8dd00425e
Content-Disposition: form-data; name="source"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
/9j/4AAQSkZJRgABAgEAAAAAAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8KCwkMEQ8SEhEPERATFhwXExQaFRARGCEYGhwdHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCABvAG8DASIAAhE --MIMEBoundary_960dd4bb3066b1fff153bc3151e7776b65947ba8dd00425e--
0
Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="postPhoto"
transports="https,http" statistics="disable" trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="accessToken" expression="//accessToken/text()" />
<property name="source" expression="//source/text()" />
<conn.init>
<accessToken>{$ctx:accessToken}</accessToken>
</conn.init>
<conn.postPhotoToAlbum>
<source>{$ctx:source}</source>
</conn.postPhotoToAlbum>
<respond></respond>
</inSequence>
<outSequence>
<log></log>
<send></send>
</outSequence>
</target>
</proxy>
Template
==========================================================================
<parameter name="source" description="The source" />
<sequence>
<property name="enableMTOM" value="true" scope="axis2" />
<header name="Content-Type" value="multipart/form-data" scope="transport" action="add" />
<property name="preserveProcessedHeaders" value="true" scope="default"/>
<property name="uri.var.source" expression="$func:source" />
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header></soapenv:Header>
<soapenv:Body>
<root>
<access_token>$1</access_token>
<source>$2</source>
</root>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg expression="get-property('uri.var.accessToken')" />
<arg expression="get-property('uri.var.source')" />
</args>
</payloadFactory>
<call>
<endpoint>
<http method="post" uri-template="http://localhost:8888/photos" />
</endpoint>
</call>
</sequence>
front end
<html>
<head><title>multipart/form-data - Client</title></head>
<body>
<form action="http:/localhost:7777/services/postPhotoToAlbumHttpSoap11Endpoint" method="POST" enctype="multipart/form-data">
url: <input type="text" name="accessToken" value=""><br/>
Profile pic :
<input type="file" name="source" size="40" multiple>
</p>
<input type="submit" value="Submit">
</form>
</body>
</html>
===========================================
seems it is missing boundary when in leaving from ESB.. it that the problem?
Content-Type: multipart/form-data;
boundary=----WebKitFormBoundaryPSfmjvLcmpwvN6Gt
Pls find the behaviors of output based on axis to relay configuration
INPUT to ESB
POST /services/postPhotoToAlbumHttpSoap11Endpoint HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "urn:mediate"
Content-Length: 488
Host: localhost:8280
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
X-Forwarded-For: 127.0.0.1
<accessToken>CAACEdEose0cBAMotx64LhZBfX7VXAgdt1zsHJCnwJRewdi55clZBUIb6FdRdBKoU4INqXPI5NekgGkPEf5FwIk3ASIZBqmJQPkomlOZAxvj2tusLPl57tUk1RZBGvNq8iQmWKuoW1KsUerxhI4vA1Nol5DvQj4oVLqVO6hwTaC9rArNSWIbr99DZApGxIA5YGxFGi8E0JotgZDZD</accessToken>
<source></source>
output from ESB
BinaryRelayBuilder<->ExpandingMessageFormatter
POST /10150897830516344/photos HTTP/1.1
Accept-Encoding: gzip,deflate
X-Forwarded-For: 127.0.0.1
Content-Type: multipart/form-data
SOAPAction: "urn:mediate"
Transfer-Encoding: chunked
Host: a.b.com:443
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
X-Forwarded-For: 127.0.0.1, 127.0.0.1
201
CAACEdEose0cBAMotx64LhZBfX7VXAgdt1zsHJCnwJRewdi55clZBUIb6FdRdBKoU4INqXPI5NekgGkPEf5FwIk3ASIZBqmJQPkomlOZAxvj2tusLPl57tUk1RZBGvNq8iQmWKuoW1KsUerxhI4vA1Nol5DvQj4oVLqVO6hwTaC9rArNSWIbr99DZApGxIA5YGxFGi8E0JotgZDZD
0
BinaryRelayBuilder<-> MultipartFormDataFormatter
class="org.wso2.carbon.relay."/>
class="org.apache.axis2.transport.http."/>
fromESB
--MIMEBoundary_4005c93d90f5f09d8bd30c0691e5b1ddf2192b5c862bdf91
Content-Disposition: form-data; name="access_token"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
CAACEdEose0cBAMotx64LhZBfX7VXAgdt1zsHJCnwJRewdi55clZBUIb6FdRdBKoU4INqXPI5NekgGkPEf5FwIk3ASIZBqmJQPkomlOZAxvj2tusLPl57tUk1RZBGvNq8iQmWKuoW1KsUerxhI4vA1Nol5DvQj4oVLqVO6hwTaC9rArNSWIbr99DZApGxIA5YGxFGi8E0JotgZDZD
--MIMEBoundary_4005c93d90f5f09d8bd30c0691e5b1ddf2192b5c862bdf91
Content-Disposition: form-data; name="source"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
--MIMEBoundary_4005c93d90f5f09d8bd30c0691e5b1ddf2192b5c862bdf91--
MultipartFormDataBuilder<-> ExpandingMessageFormatter
POST /10150897830516344/photos HTTP/1.1
Accept-Encoding: gzip,deflate
X-Forwarded-For: 127.0.0.1
Content-Type: multipart/form-data
SOAPAction: "urn:mediate"
Transfer-Encoding: chunked
Host: a.b.com:443
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
X-Forwarded-For: 127.0.0.1, 127.0.0.1
201
CAACEdEose0cBAMotx64LhZBfX7VXAgdt1zsHJCnwJRewdi55clZBUIb6FdRdBKoU4INqXPI5NekgGkPEf5FwIk3ASIZBqmJQPkomlOZAxvj2tusLPl57tUk1RZBGvNq8iQmWKuoW1KsUerxhI4vA1Nol5DvQj4oVLqVO6hwTaC9rArNSWIbr99DZApGxIA5YGxFGi8E0JotgZDZD
0
MultipartFormDataBuilder <-> MultipartFormDataFormatter
POST /10150897830516344/photos HTTP/1.1
Accept-Encoding: gzip,deflate
X-Forwarded-For: 127.0.0.1
Content-Type: multipart/form-data
SOAPAction: urn:mediate
Transfer-Encoding: chunked
Host: a.b.com:443
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
X-Forwarded-For: 127.0.0.1, 127.0.0.1
29c
--MIMEBoundary_588b3db44ce49dd52107589eea5fdcdc3d9a943eeeadcc5a
Content-Disposition: form-data; name="access_token"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
CAACEdEose0cBAMotx64LhZBfX7VXAgdt1zsHJCnwJRewdi55clZBUIb6FdRdBKoU4INqXPI5NekgGkPEf5FwIk3ASIZBqmJQPkomlOZAxvj2tusLPl57tUk1RZBGvNq8iQmWKuoW1KsUerxhI4vA1Nol5DvQj4oVLqVO6hwTaC9rArNSWIbr99DZApGxIA5YGxFGi8E0JotgZDZD
--MIMEBoundary_588b3db44ce49dd52107589eea5fdcdc3d9a943eeeadcc5a
Content-Disposition: form-data; name="source"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
--MIMEBoundary_588b3db44ce49dd52107589eea5fdcdc3d9a943eeeadcc5a--
0

problem is WSO2-ESB current version (4.9.0) is not supporting for multipart/form-data processing. you cannot mediate those. only what you can do is use pass through proxy. it is working

Related

Converting LogMeIn Refresh Token Curl to Coldfusion

The LogMeIn API for GoToWebinar says to use this code to refresh an Access Token after it expire:
curl -X POST "https://api.getgo.com/oauth/v2/token" \
-H "Authorization: Basic {Base64 Encoded consumerKey and consumerSecret}" \
-H "Accept:application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=refresh_token&refresh_token={refresh_token}"
Tried recreating it in ColdFusion like this:
<cfhttp url="https://api.getgo.com/oauth/v2/token" method="post" result="httpResp" timeout="60">
<cfhttpparam type="header" name="Accept" value="application/json" />
<cfhttpparam type="header" name="Authorization" value="Basic ...abc123..." />
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
<cfhttpparam type="body" encoded="false" value="grant_type=refresh_token&refresh_token=#refreshToken#" />
</cfhttp>
The error we are getting is "error":"invalid_grant".
Before I delve further, is the ColdFusion translation correct (assuming the refresh_token and Authorization encoded keys are correct)?

ColdFusion 9 to SSL API connection- I/O Exception: peer not authenticated

I'm using ColdFusion on a Windows server.
I try to connect to an API, it works on http url, but not on https.
<cfhttp url="https://www.example.com/api/login" method="post" result="httpResp" timeout="120">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
<cfhttpparam type="formField" name="user_key" value="#user_key#" />
<cfhttpparam type="formField" name="email" value="#user_email#" />
<cfhttpparam type="formField" name="password" value="#user_password#" />
</cfhttp>
<cfdump var="#httpResp#">
I'm getting this response:
struct
Charset [empty string]
ErrorDetail I/O Exception: peer not authenticated
Filecontent Connection Failure
Header [empty string]
Mimetype Unable to determine MIME type of file.
Responseheader
struct [empty]
Statuscode Connection Failure. Status code unavailable.
Text YES
When opening the URL from the server, I'm getting this xml response:
<rsp stat="fail" version="1.0">
<err code="15">Login failed</err>
</rsp>
And in my code, I have another https post that works without issue:
<cfhttp url="https://www.example2.com" method="post" result="httpResp" timeout="120">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="body" value="#Replace(myJsonStruct,"//","")#">
</cfhttp>
That means that the issue is not coming from SSL settings on the server.
Is there an error in my CF code?

WCF SOAP Response Namespace Issue

WCF returns empty objects, although I can see from a fiddler trace that data is being returned. I am sure it is namespace issue, but after reading all the docs I can't see what is wrong! Request and response SOAP below:
Request:
POST https://x.x.x.x:9001/soap/ HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.34209)
VsDebuggerCausalityData: uIDPo0Xy/aB8aeVEhMD2Z4yiT1MAAAAAKokUeOFUmEaRRFeDK7Ihn37dui0ez7tEhWItLBqEHq0ACQAA
Content-Type: text/xml; charset=utf-8
SOAPAction: "get_wsdl_version"
Host: x.x.x.x:9001
Content-Length: 236
Expect: 100-continue
Connection: Keep-Alive
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body />
</soap:Envelope>
Response:
HTTP/1.1 200 OK
Date: Thu, 05 Feb 2015 10:10:18 GMT
Server: Apache
Vary: Accept-Encoding,User-Agent
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/xml
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<get_wsdl_versionResponse>
<get_wsdl_versionResult xsi:type="xs:int">2002</get_wsdl_versionResult>
</get_wsdl_versionResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Edit: adding (very simple) client code
Dim TestClient = New ServiceReference1.TableLampServiceClient
Dim Creds = New ServiceReference1.AuthInfo()
Creds.username = "xxx"
Creds.password = "yyy"
Dim TestVersion = TestClient.get_wsdl_version()
Edit: adding WDSL snippet - pulled from VS
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:tns="cust_service.TableLampService" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:typens="cust_service.TableLampService" name="TableLampService" targetNamespace="cust_service.TableLampService" xmlns="http://schemas.xmlsoap.org/wsdl/">
<plnk:partnerLinkType name="TableLampService">
<plnk:role name="TableLampService">
<plnk:portType name="tns:TableLampService" />
</plnk:role>
</plnk:partnerLinkType>
<types>
<xs:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="cust_service.TableLampService">
<xs:element name="get_wsdl_versionResponse" type="typens:get_wsdl_versionResponse" />
<xs:complexType name="get_wsdl_versionResponse">
<xs:sequence>
<xs:element name="get_wsdl_versionResult" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name="get_wsdl_version" />
<message name="get_wsdl_versionResponse">
<part name="get_wsdl_versionResponse" element="typens:get_wsdl_versionResponse" />
</message>
<portType name="TableLampService">
<operation name="get_wsdl_version" parameterOrder="get_wsdl_version">
<documentation>
get_wsdl_version() -> int
Return the SOAP server's WSDL version. This is used to check
client/server compatibility.
Parameters: None
Exceptions: None
</documentation>
<input name="get_wsdl_version" message="typens:get_wsdl_version" />
<output name="get_wsdl_versionResponse" message="typens:get_wsdl_versionResponse" />
</operation>
</portType>
<binding name="TableLampService" type="typens:TableLampService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="get_wsdl_version">
<soap:operation soapAction="get_wsdl_version" style="document" />
<input name="get_wsdl_version">
<soap:body use="literal" />
</input>
<output name="get_wsdl_versionResponse">
<soap:body use="literal" />
</output>
</operation>
</binding>
</definitions>
It may be worth mentioning that I have no control over the server-side. I just need to consume the service in my code however I can.
Thanks in advance!

Worklight 6.2 Authentication to LDAP using OpenDS

I am struggling to get ldap authentication using openDS to work. I am using Worklight Studio 6.2 and Apache DS 2.0 as the ldap browser.
The project is supposed to call a login page, and then submit the username and password for authentication to ldap.
I get the following error in the firefox console:
POST http://x.x.x.x:10080/LDAPTest/apps/services/j_security_check [HTTP/1.1 200 OK 253ms]
undefined entity j_security_check:134
And in eclipse in the worklight console:
[WARNING ] FWLSE0138W: LdapLoginModule authentication failed. Reason 'javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
[WARNING ] FWLSE0239W: Authentication failure in realm 'LDAPRealm': login fail [project LDAPTest]
I thought that the issue would be either my connection string or my challange handler. But I suspect that since my errror is invalid credentials that it must be my connection string in the authenticationconfig.xml.
I have tried several methods including some of the posts here such as :
Worklight LDAP authentication using ApacheDS
Worklight LDAP authentication using ApacheDS 2.0
and there others. I followed the IBM LDAP sample to set this up and I have checked to make sure that I have the same structure.
Any help figuring this out would be much appreciated. Also if you think I should check my LDAP config, I can post that too I followed a tutorial from openDS wiki. I was able to connect to it using apache browser studio and softera LDAP administrator.
My project is as follows:-
index.html:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>LDAPTest</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<!--
<link rel="shortcut icon" href="images/favicon.png">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
-->
<link rel="stylesheet" href="css/main.css">
<script>window.$ = window.jQuery = WLJQ;</script>
</head>
<body style="display: none;">
<div id="header">
<h1>SigmaLDAP Login Module</h1>
</div>
<div id="wrapper">
<div id="AppDiv">
<input type="button" class="appButton"
value="Call protected adapter proc" onclick="getSecretData()" /> <input
type="button" class="appButton" value="Logout"
onclick="WL.Client.logout('LDAPRealm',{onSuccess: WL.Client.reloadApp})" />
<p id="resultDiv"></p>
</div>
<div id="AuthDiv" style="display: none">
<div id="loginForm">
<input type="text" id="usernameInputField"
placeholder="Enter username" /> <br /> <input type="password"
placeholder="Enter password" id="passwordInputField" /> <br /> <input
type="button" class="formButton" id="loginButton" value="Login" />
<input type="button" class="formButton" id="cancelButton"
value="Cancel" />
</div>
</div>
</div>
<script src="js/initOptions.js"></script>
<script src="js/main.js"></script>
<script src="js/messages.js"></script>
<script src="js/LDAPRealmChallenger.js"></script>
</body>
</html>
Main.js
function wlCommonInit(){
}
function getSecretData(){
WL.Logger.info('invoking the adpater');
var invocationData = {
adapter: "LDAPter",
procedure: "getSecretData",
parameters: []
};
WL.Client.invokeProcedure(invocationData, {
onSuccess: getSecretData_Callback,
onFailure: getSecretData_Callback,
timeout: 2000
});
}
function getSecretData_Callback(response){
$("#resultDiv").css("padding", "10px");
$("#resultDiv").html(new Date() + "<hr/>");
$("#resultDiv").append("Secret data :: " + response.invocationResult.secretData + "<hr/>");
$("#resultDiv").append("Response :: " + JSON.stringify(response));
}
My Challenger.js
var LDAPRealmChallengeHandler = WL.Client.createChallengeHandler("LDAPRealm");
LDAPRealmChallengeHandler.isCustomResponse = function(response) {
if (!response || !response.responseText) {
WL.Logger.info('failed to authenticate');
}
var idx = response.responseText.indexOf("j_security_check");
if (idx >= 0){
WL.Logger.info("Authenticated");
return true;
}
return false;
};
LDAPRealmChallengeHandler.handleChallenge = function(response){
$('#AppDiv').hide();
$('#AuthDiv').show();
$('#passwordInputField').val('');
};
$('#loginButton').bind('click', function () {
var reqURL = '/j_security_check';
var options = {};
options.parameters = {
j_username : $('#usernameInputField').val(),
j_password : $('#passwordInputField').val()
};
options.headers = {};
LDAPRealmChallengeHandler.submitLoginForm(reqURL, options, LDAPRealmChallengeHandler.submitLoginFormCallback);
});
$('#cancelButton').bind('click', function () {
$('#AppDiv').show();
$('#AuthDiv').hide();
LDAPRealmChallengeHandler.submitFailure();
});
LDAPRealmChallengeHandler.submitLoginFormCallback = function(response) {
var isLoginFormResponse = LDAPRealmChallengeHandler.isCustomResponse(response);
if (isLoginFormResponse){
LDAPRealmChallengeHandler.handleChallenge(response);
} else {
$('#AppDiv').show();
$('#AuthDiv').hide();
LDAPRealmChallengeHandler.submitSuccess();
}
};
My adpater:
the js file
function getSecretData(){
console.log("getting you secrets mofos");
return {secretData: 1234};
}
The xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
5725-I43 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<wl:adapter name="LDAPter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">
<displayName>LDAPter</displayName>
<description>LDAPter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>none</domain>
<port>80</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="getSecretData" securityTest="LDAPSecurityTest" />
</wl:adapter>
The authenticationConfig.xml:
<?xml version="1.0" encoding="UTF-8"?>
<tns:loginConfiguration xmlns:tns="http://www.worklight.com/auth/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- Licensed Materials - Property of IBM 5725-I43 (C) Copyright IBM Corp.
2006, 2013. All Rights Reserved. US Government Users Restricted Rights -
Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM Corp. -->
<staticResources>
<!-- <resource id="logUploadServlet" securityTest="LogUploadServlet"> <urlPatterns>/apps/services/loguploader*</urlPatterns>
</resource> -->
<resource id="subscribeServlet" securityTest="SubscribeServlet">
<urlPatterns>/subscribeSMS*;/receiveSMS*;/ussd*</urlPatterns>
</resource>
</staticResources>
<!-- Sample security tests Even if not used there will be some default webSecurityTest
and mobileSecurityTest Attention: If you are adding an app authenticity realm
to a security test, you must also update the application-descriptor.xml.
Please refer to the user documentation on application authenticity for environment
specific guidelines. -->
<securityTests>
<customSecurityTest name="LDAPSecurityTest">
<test isInternalUserID="true" realm="LDAPRealm" />
</customSecurityTest>
<!-- <mobileSecurityTest name="mobileTests"> <testAppAuthenticity/> <testDeviceId
provisioningType="none" /> <testUser realm="myMobileLoginForm" /> <testDirectUpdate
mode="perSession" /> </mobileSecurityTest> <webSecurityTest name="webTests">
<testUser realm="myWebLoginForm"/> </webSecurityTest> <customSecurityTest
name="customTests"> <test realm="wl_antiXSRFRealm" step="1"/> <test realm="wl_authenticityRealm"
step="1"/> <test realm="wl_remoteDisableRealm" step="1"/> <test realm="wl_directUpdateRealm"
mode="perSession" step="1"/> <test realm="wl_anonymousUserRealm" isInternalUserID="true"
step="1"/> <test realm="wl_deviceNoProvisioningRealm" isInternalDeviceID="true"
step="2"/> </customSecurityTest> <customSecurityTest name="LogUploadServlet">
<test realm="wl_anonymousUserRealm" step="1"/> <test realm="LogUploadServlet"
isInternalUserID="true"/> </customSecurityTest> -->
<customSecurityTest name="SubscribeServlet">
<test realm="SubscribeServlet" isInternalUserID="true" />
</customSecurityTest>
</securityTests>
<realms>
<realm loginModule="LDAPLoginModule" name="LDAPRealm">
<className>com.worklight.core.auth.ext.FormBasedAuthenticator</className>
<onLoginUrl>/console</onLoginUrl>
</realm>
<realm name="SubscribeServlet" loginModule="rejectAll">
<className>com.worklight.core.auth.ext.HeaderAuthenticator</className>
</realm>
<!-- For client logger -->
<!-- <realm name="LogUploadServlet" loginModule="StrongDummy"> <className>com.worklight.core.auth.ext.HeaderAuthenticator</className>
</realm -->
<!-- For websphere -->
<!-- realm name="WASLTPARealm" loginModule="WASLTPAModule"> <className>com.worklight.core.auth.ext.WebSphereFormBasedAuthenticator</className>
<parameter name="login-page" value="/login.html"/> <parameter name="error-page"
value="/loginError.html"/> </realm -->
<!-- For User Certificate Authentication -->
<!-- realm name="wl_userCertificateAuthRealm" loginModule="WLUserCertificateLoginModule">
<className>com.worklight.core.auth.ext.UserCertificateAuthenticator</className>
<parameter name="dependent-user-auth-realm" value="WASLTPARealm" /> <parameter
name="pki-bridge-class" value="com.worklight.core.auth.ext.UserCertificateEmbeddedPKI"
/> <parameter name="embedded-pki-bridge-ca-p12-file-path" value="/opt/ssl_ca/ca.p12"/>
<parameter name="embedded-pki-bridge-ca-p12-password" value="capassword"
/> </realm -->
<!-- For Trusteer Fraud Detection -->
<!-- Requires acquiring Trusteer SDK -->
<!-- realm name="wl_basicTrusteerFraudDetectionRealm" loginModule="trusteerFraudDetectionLogin">
<className>com.worklight.core.auth.ext.TrusteerAuthenticator</className>
<parameter name="rooted-device" value="block"/> <parameter name="device-with-malware"
value="block"/> <parameter name="rooted-hiders" value="block"/> <parameter
name="unsecured-wifi" value="alert"/> <parameter name="outdated-configuration"
value="alert"/> </realm -->
</realms>
<loginModules>
<loginModule name="LDAPLoginModule">
<className>com.worklight.core.auth.ext.LdapLoginModule</className>
<parameter name="ldapProviderUrl" value="ldap://localhost:389/dc=sigma,dc=com" />
<parameter name="ldapTimeoutMs" value="2000"/>
<parameter name="ldapSecurityAuthentication" value="simple"/>
<parameter name="validationType" value="searchPattern"/>
<parameter name="ldapSecurityPrincipalPattern" value="uid={username},ou=users,dc=sigma,dc=com"/>
<parameter name="ldapSearchFilterPattern" value="(uid={username})"/>
<parameter name="ldapSearchBase" value="ou=users,dc=sigma,dc=com"/>
</loginModule>
<loginModule name="StrongDummy">
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule>
<loginModule name="requireLogin">
<className>com.worklight.core.auth.ext.SingleIdentityLoginModule</className>
</loginModule>
<loginModule name="rejectAll">
<className>com.worklight.core.auth.ext.RejectingLoginModule</className>
</loginModule>
<!-- Required for Trusteer - wl_basicTrusteerFraudDetectionRealm -->
<!-- loginModule name="trusteerFraudDetectionLogin"> <className>com.worklight.core.auth.ext.TrusteerLoginModule</className>
</loginModule -->
<!-- For websphere -->
<!-- loginModule name="WASLTPAModule"> <className>com.worklight.core.auth.ext.WebSphereLoginModule</className>
</loginModule -->
<!-- Login module for User Certificate Authentication -->
<!-- <loginModule name="WLUserCertificateLoginModule"> <className>com.worklight.core.auth.ext.UserCertificateLoginModule</className>
</loginModule> -->
<!-- For enabling SSO with no-provisioning device authentication -->
<!-- <loginModule name="MySSO" ssoDeviceLoginModule="WLDeviceNoProvisioningLoginModule">
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule> -->
<!-- For enabling SSO with auto-provisioning device authentication -->
<!-- <loginModule name="MySSO" ssoDeviceLoginModule="WLDeviceAutoProvisioningLoginModule">
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule> -->
</loginModules>
</tns:loginConfiguration>
The response from the j_security_check
Request URL: http://x.x.x.x:10080/LDAPTest/apps/services/j_security_check
Request Method: POST
Status Code: HTTP/1.1 200 OK
Request Headers 12:47:00.000
x-wl-app-version: 1.0
x-wl-analytics-tracking-id: a948e425-1ace-a28b-3d27-11bac5ba3de3
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
Referer: http://10.2.38.14:10080/LDAPTest/apps/services/preview/LDAPTest/common/0/default/index.html
Pragma: no-cache
Host: 10.2.38.14:10080
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 37
Connection: keep-alive
Cache-Control: no-cache
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Accept: text/javascript, text/html, application/xml, text/xml, */*
Sent Cookie
WL_PERSISTENT_COOKIE: b24de65a-9c5a-4f58-97d7-348e92c78034
testcookie: oreo
LtpaToken2: rZBXVP4XKLnpvJpLFrp3UArtZGrcsGAXr4jGDTBurns9Ej5Nrx1s4/yWsDJJN6xfWkxWh1/3bBruHvL9twdae1qVcE2/D/0GfMwd1pVLbpowclNLFtqKBonEXxV6TlFIVaKgKz62SHR2to3Az/vbTjF+ZH8V1QnAdGi6dC8mk+wympju0P/4hLKWHseN9Sty2UM94cL2Cd+vcBGhJ5QVF211RIwQTXuGeQl+WMTg6B8Kfjlvly4sanyVr5va2AW38752VNEWtdnsrTHcayO/lAG1SyebFEKtaTVZhOPBkml5m6AojEGlDbcUjjof6e9H
JSESSIONID: 0000QTvrT7OBSgjn7OJG9XPMtIE:b45f2ac7-fb59-4da4-b233-f8bc81b81cf0
Response Headers Δ315ms
X-Powered-By: Servlet/3.0
Transfer-Encoding: chunked
P3P: policyref="/w3c/p3p.xml", CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
Expires: -1
Date: Mon, 10 Nov 2014 11:47:00 GMT
Content-Language: en-US
And the firefox console also returns undefined entity for j_sescurity_check and a line number 134, which in the snippet below is the last line before the dic.
The code it points to is as follows:
body onload="isPopup(); setFocus();">
<div id="authenticatorLoginFormWrapper">
<h1>IBM</h1>
<h2>IBM Worklight</h2>
<form method="post" action="j_security_check">
<p id="error">Please check the credentials</p>
<label for="j_username">User name:</label>
<input type="text" id="j_username" name="j_username" placeholder="User name" />
<br />
<label for="j_password">Password:</label>
<input type="password" id="j_password" name="j_password" placeholder="Password" />
<br />
<input type="submit" id="login" name="login" value="Log In" />
</form>
<p id="copyright">© 2006, 2012 IBM Corporation. Trademark</p>
</div>
Can you try and eliminate some variables in your setup and try as a first step to check whether your LDAP server is configured properly?
you can use this: https://serverfault.com/questions/514870/how-do-i-authenticate-with-ldap-via-the-command-line
to do a simple connection to your ldap server using a command line tool
I had a similar issue and a working config in my case was to move from simple to exists check in the authenticationConfig.xml file.
But especially the big leap forward was not using the uid anymore in the ldapSecurityPrincipalPattern and instead use cn for the user.
I paste the configuration below hoping it's useful for you (please note in my specific case I setup a test server corp.workgroup.com domain):
<loginModules>
<loginModule expirationInSeconds="-1" name="LDAPLoginModule">
<className>com.worklight.core.auth.ext.LdapLoginModule</className>
<parameter name="ldapProviderUrl" value="ldap://yourserver" />
<parameter name="ldapTimeoutMs" value="2000" />
<parameter name="ldapSecurityAuthentication" value="simple" />
<parameter name="validationType" value="exists" />
<parameter name="ldapSecurityPrincipalPattern" value="cn={username},cn=Users,dc=corp,dc=workgroup,dc=com" />
<parameter name="ldapReferral" value="ignore" />
</loginModule>

WCF Compression on basicHttpBinding

Tried everything to enable Compression on a WCF service but still no success the service is on basicHttpBinding so it returns the content-type as text/xml; charset=utf-8 .
On my applicationHost.config add inumerous dynamic types:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" doDiskSpaceLimiting="false" maxDiskSpaceUsage="100000" minFileSizeForComp="0" noCompressionForHttp10="false" noCompressionForProxies="false" noCompressionForRange="false" dynamicCompressionBufferLimit="6553600">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
<add mimeType="text/*" enabled="true" />
</staticTypes>
<dynamicTypes>
<add mimeType="application/json" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/atom+xml;charset=utf-8" enabled="true" />
<add mimeType="application/soap+xml" enabled="true" />
<add mimeType="application/soap+xml; charset=utf-8" enabled="true" />
<add mimeType="application/soap+xml; charset=ISO-8895-1" enabled="true" />
<add mimeType="application/msbin1" enabled="true" />
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="Application/octet-stream" enabled="true" />
<add mimeType="text/xml; charset=utf-8" enabled="true" />
<add mimeType="application/xml; charset=utf-8" enabled="true" />
<add mimeType="application/soap+msbin1" enabled="true" />
<add mimeType="*/*" enabled="true" />
</dynamicTypes>
</httpCompression>
On Fiddler:
Request:
POST http://[omitted]/Service/ HTTP/1.1
Content-Type: text/xml; charset=utf-8
VsDebuggerCausalityData: uIDPo01MZ7JWHO9Kg43Hd3AGkiQAAAAASwm/c9G/206hW6j58tpV5waE+e97MShJvqGukMzMybEACQAA
SOAPAction: "http://tempuri.org/IService/GetCountries"
Host: [omitted]
Content-Length: 137
Expect: 100-continue
Accept-Encoding: gzip, deflate
Proxy-Connection: Keep-Alive
Response:
HTTP/1.1 200 OK
Via: 1.1 PROXY
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Content-Length: 81623
Date: Tue, 20 Nov 2012 18:20:48 GMT
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
What else could I do?