Personalize

How to access a secure endpoint with basic auth?

Forums :

From ws02 esb, I want to access a service at an http endpoint which is secure with basic authentication.
I guess I have to used the PropertyMediator (with user/password) before the SendMediator but I don't know which properties I have to set. Any ideas where to look at?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: any update?

I'm tackling a similar problem with an ESB proxy service trying to access an existing service that is secured with HTTP basic authentication.

Any pointers on how to configure HTTP username/password tokens with the SendMediator?

We do not have a BasicAuth

We do not have a BasicAuth mediator.. Yet! But supporting basic auth is a trivial task, and you can do something like below to achieve this:

<syn:script language="groovy">
byte[] username = mc.getProperty("username").getBytes();
byte[] password = mc.getProperty("password").getBytes();
byte[] authString = new byte[username.length + password.length + 1];
System.arraycopy(username, 0, authString, 0, username.length);
authString[username.length] = (byte) ':';
System.arraycopy(password, 0, authString, username.length+1, password.length);
mc.setProperty("Authorization", "Basic " +
org.apache.axiom.om.util.Base64.encode(authString));</syn:script>
<syn:property name="Authorization" expression="get-property('Authorization')" scope="transport"/>

 You basically set a transport header "Authorization" and set it to the required text for BasicAuth (http://en.wikipedia.org/wiki/Basic_authentication_scheme)

asankha

Possible fault with web sequence editor?

Thank you Asankha, my proxy is passing the Authorization header now and everything appears to be working.

One thing I discovered though was that passing groovy script into the Extension -> Script mediator in the web-based sequence editor does not allow me save when I'm done. Instead, it produces a browser/client-based javascript error when I click the Save button citing "mediatornode.removeAttribute is not a function (line 372)" in /extensions/core/js/sequences.js.

This is the js code in question:

function clearnodepositions(mediatornode) {
    if (mediatornode.nodeType != 3) {
        mediatornode.removeAttribute("esb_med_pos");
        var med_children = mediatornode.childNodes;

        for (var i = 0; i < med_children.length; i++) {
            clearnodepositions(med_children[i]);
        }
    }
}

Creating the XML sequence configuration directly from the Manage -> Configuration function works perfectly however.

Is this an editor bug?

Thanks William for letting

Thanks William for letting us know, Yes, it seems like a UI bug, and we will rectify and fix this issue soon

asankha

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.