Sunday, October 14, 2012

Mule ldap Connector

Ldap connector in mule has been broken for some time now. The good news however is that with mule 3.3 the ldap connector has been fixed.
Couldn't find any example for using the ldap connector so here is my poc for the same.

Just some basic concepts i learnt along the way,
baseDn --> its the top level in the ldap directory tree that you want to start your querying from.
                   e.g OU=Locations,dc=anil,dc=com (for something like anil.com)
authDn --> this is usually the authentication username with domain name usually
                  eg. apuliyeril@anil.com


http://jxplorer.org/ is a wonderful ldap browser that helps you start your venture and understand the structure of your ldap.

I'm not sure if the older versions of mule supports this but mule 3.3 does so if it doesn't seem to work you need to upgrade to mule 3.3.

Add the following link to you mule plugin updates.

If you are not sure how to add a plugin refer
install connector step.


Make a new project called Ldap connector with a mule-flow in it.

The ldap mule config

In this simple example there is a http endpoint which when you hit gives a list of csv of the user details present in the system. url needs to be given with the port (389) the authentication used here is simple There are different scopes available scope="SUB_TREE" is the one used here, this will search through out the tree structure and fetch all the information present.
Filter refers to the search filter here it is an and of  objectCategory=person and objectclass=user


The groovy file for the same
The groovy logic is pretty much straight forward. it is fetching the fields from the message.payload if the value is not null.
The tricky part is the date. it needs a formatter as it uses the UTC time format to show the data.

Tuesday, October 9, 2012

Mule & cmis integration (Alfresco)


There are many cmis compliant systems like sharepoint, alfresco etc. Since sharepoint is paid I used alfresco for this short sample purpose, should be same for sharepoint as well because both are cmis compliant.

You can download alfresco server from
http://wiki.alfresco.com/wiki/Download_and_Install_Alfresco
The mule flow for the same.



as per request an image of the flow.


Copy the contents of mule-config.xml to a new mule flow that you create.
The custom code is in groovy hence no need to set classpath etc in mule.

Services implemented with sample url are as follows
http://localhost:8081/alfresco/list lists all the files available (currently only the root folder for poc)
http://localhost:8081/alfresco/download?id=5454d82c-c8aa-4e6b-bbf8-378644e6d121 downloads a file to the local disk
http://localhost:8081/alfresco/upload?filepath=D:/files/int_person.csv uploads a file found at this path to the root directory
http://localhost:8081/alfresco/delete?id=c1eba832-725f-4c9c-b8ec-baed82f7a06e delete the file with the given id

Mule & Box.net integration


For box.net you need to first install the box.net plugin in mule. For this purpose you need to add an eclipse update site
Link for the same.
http://repository.mulesoft.org/connectors/releases/3.3.1add the box.net plugin only.

The mule-config.xml file for the box.net connector is available at link
No other files are needed as the code for the same is written in groovy and is a part of the mule-config.xml

Examples of services available are
1.       localhost:8081/integrate/ticket
2.       localhost:8081/integrate/auth
3.       localhost:8081/integrate/upload?fileName=D:/deleteme/d/int_person.csv
4.       localhost:8081/integrate/download?fileName=int_personNew.csv&id=3444993848
5.       localhost:8081/integrate/delete?id=3444931678
6.       localhost:8081/integrate/list

After the ticket service (step 1) you need to authenticate the user on the box.net site url using
https://www.box.com/api/1.0/auth/{your ticket} 
This is similar to an oauth kind of authentication