Wednesday, September 4, 2013

Configure WSO2 Identity server to use Apache DS LDAP

1. Configure a LDAP from Apache DS.


To configure Apache DS first download the latest version of apache directory studio from here.


Then install the setup (for windows users) and start the Apache Directory Studio.


Then go to “Window - > show view -> other ” and select “LDAP servers”.



In the server view click on “new server” and create a new server instance. Start the server by right clicking on the server instance and click on “start”.



Then go to connections tab next to the LDAP servers tab and create a new connection.



This will open “New LDAP Connection" wizard.



Enter the connection details and click next. (Here in my example i run on localhost port 10389.)


In the next window you will be asked for parameters for authentication details.



Enter the parameters for simple authentication. In the Bind DN or user field, enter the DN of the administrator’s account on the directory server (for the default instance of the Apache directory server, this is uid=admin,ou=system). In the Bind password field, enter the administrator’s password (for the default instance of the Apache directory server, the administrator’s password is secret). Click Finish


If the connection is successfully established, you should see an outline of the Directory Information Tree (DIT) in the LDAP Browser view. In the LDAP Browser view, drill down to the ou=users node, as shown.




Right-click on the ou=users node and select New Entry. The New Entry wizard appears. Leave the Entry Creation Method by clicking next. In the Object Classes pane, select inetOrgPerson from the list of Available object classes on the left and then click Add to populate the list of Selected object classes. Click Next.



In the Distinguished Name pane, complete the RDN field, putting uid in front and jdoe after the equals sign. Click Next.



Fill in the remaining mandatory attributes in the Attributes pane. Set the cn (common name) attribute to John Doe and the sn (surname) attribute to Doe. Click Finish.



To add a userPassword attribute to the user entry. In the LDAP Browser view, you should now be able to see a new node, uid=jdoe. Select the uid=jdoe node. Now, right-click in the Entry Editor view and select New Attribute. The New Attribute wizard appears. From the Attribute type drop-down list, select userPassword. Click Finish. The Password Editor dialog appears. In the Enter New Password field, enter the password, secret. Click Ok.


Point wso2 Identity server to the newly created external LDAP


Goto Identity server root folder and browse in to “wso2esb-{version}\repository\conf”. Open “user-mgt.xml” in the editor.


Un-comment the commented section about external LDAP.




Change the password of connection as following line. (since our previously entered default password is “secret” we entered that below)


<Property name=”ConnectionPassword”>secret</Property>


Run the Identity server and create a new user by signup.


If all goes correctly you may be able to add new users by Identity server and, in Apache DS you may see the newly added  users.

Tuesday, August 6, 2013

Gradle how to add 'providedCompile' configuration

"providedCompile" configuration is used to declare dependencies that will be provided in run time so there is no need to copy the dependencies to resources folder.



But this configuration has not added in some plugins by default (ex. “java” plugin). Thus we have to manually configure our build script for “providedCompile” configuration.


First we add configuration for providedCompile as below,




configurations { providedCompile }



Then we have to add the new configuration into classpaths as below.





sourceSets.main.compileClasspath += configurations.providedCompile
sourceSets.test.compileClasspath += configurations.providedCompile
sourceSets.test.runtimeClasspath += configurations.providedCompile

Wednesday, July 3, 2013

Websphere - increasing wait time when uploading an application via admin console

Default time for application install (upload) in websphere has been set to 60 seconds.


To increase this you have to go to


Application servers > server1 > Web container > Web container transport chains



There are several handler chains defined for various purposes. Since in this post i m going to describe the scenario of uploading app via admin console, i l skip the rest. (though the procedure is same)




Select WCInboundAdminSecure from the above lists (since admin console use SSL).


Increase the “Read timeout" . Click Apply and save.


Monday, June 3, 2013

Using XQuery to get values from set of XPaths and return null if node is not presented.

I have been stuck for few days due to that i can not return anything from querying XPath if that specific XPath is not presented in my XML file. The scenario is that we have nodes in our XML file that may be or may not be present in XML file arbitrarily.

Yes you can do it programmatically if you only use one XPath at a time. But my need is different. I want to get values of several XPaths at once and at the same time i need it to give me something pre-defined ( let's say "null"), if one of XPaths i am querying for is not presented.

So i basically had two problems to overcome. One is how to get values of several XPaths at once.
And the other is getting per-defined value if that specific node is not presented in my XML document.

First i tried using purely XPaths. In this way i have been able to overcome my first problem, that is querying several XPaths at once. That is by using XPath Union operation. XPath union operator can be use as follows

 /A/B/C/text() | /A/D/C/text() | /A/E/C/text()  

or

 /A/B/C/text() union /A/D/C/text() union /A/E/C/text()  

Here by using "|"  or "union" you  can join as much as XPaths you want. And i have seen that this improves performance since you can use to get several values you want through out the system at one call without calling the same function (which you use to execute your XPaths) several times.

Also order of the values return by using XPath union preserve the order of the elements appear in XML document.

Problem in this method come with this order. If you join an element that will not present in the XML file always, it will destroy the order of the values return. Which is lets say if all the "C" elements present in above example, then the returning order values should be,

 1. value of /A/B/C/text()   
 2. value of /A/D/C/text()   
 3. value of /A/E/C/text()   

But, lets say that Node /A/D/C is not presented in XML file.Then the order will be,

 1. value of /A/B/C/text()   
 2. value of /A/E/C/text()   

Yes you get it right!!! Nothing in the middle saying that we have no /A/D/C node. So the order of the return values have been changed.

Because of this I have find an alternative and XQuery came to rescue. Yes XPath is to do complicate stuff like querying and modifying results. That is the job of XQuery. XPath is there to show the way to XQuery ("hey dude the node you are looking for is this way")

So by using XQuery FLOWER statement i have been able to write following query to evaluate set of XPaths and get their values at the same time and also if there is some node missing in the middle to return "null" which help to preserve the order of the return values.

 let $i1:=/A/B/C/text()   
 let $i2:=/A/D/C/text()   
 let $i2:=/A/E/C/text()  
 return string-join((if($i1) then ($i1) else ('null') , if($i2) then ($i2) else ('null') ) , ';')  

Here i have used string-join(string1, string2 ... stringN, 'delemeter') function of XQuery to join the results and ';' as the delimiter.

We can use if(condition or XPath) then (statement or XPath) else (statement or XPath)to check the availability of node and send a per-defined value if node is missing.






Monday, April 29, 2013

jQuery - when to use attr() ?? when to use prop() ???

with effect from jQuery 1.6 a new method has been introduced to change or retrieve values of attributes (or properties).

So what is the big deal here you might ask. the problem is that new comers doesn't understand the difference between the attr() method which has been there and the new method prop() which introduced lately.

In a HTML element there is two kind of  things we can see.
  1. Attributes
  2. Properties
I will explain this by an example. Lets take following HTML input tag for an instance.

 <input id="q" value="" class="button-gray" name="_3_keywords" readonly>  

In the above example  id, value, name are belong to Attribute family while readonly is a property. So when to use attr() method or when to use prop() method is depend on whether you are dealing with an attribute or a property.

For example lets say you want to change the class attribute of above INPUT tag. Here you have to use  attr() method like below.

 $("#q").attr("class", "newclass")  

But lets say if you want to make the above INPUT tag readable (it is readonly originally according to the code above). So here you have to use prop() from  jQuery 1.6 onwards like below.

 $("#q").prop("readonly", false)  

Yeah you might noticed the change. Before jQuery 1.6 you have to use attr() method like below. 

 $("#q").attr("readonly", "readonly")  

But with new  prop() you can save life by just giving a boolean as the second attribute.

 


"ceylon" command throwing "UnsupportedClassVersionError" exception

When i was trying to install and configure classpath for Ceylon programming language to begin coding i was getting this error which does not describe it self.


 Exception in thread "main" java.lang.UnsupportedClassVersionError: com/redhat/ce  
 ylon/launcher/CeylonClassLoader : Unsupported major.minor version 51.0  
     at java.lang.ClassLoader.defineClass1(Native Method)  
     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)  
     at java.lang.ClassLoader.defineClass(ClassLoader.java:615)  
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14  
 1)  
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)  
     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)  
     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)  
     at java.security.AccessController.doPrivileged(Native Method)  
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)  
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)  
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)  
     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)  
 Could not find the main class: com.redhat.ceylon.launcher.Launcher. Program will  
  exit.  

The mistake i did at the beginning seems to be avoid reading the "README.md" file in ceylon package. In there it clearly stated that "Ceylon execute on any Java 7 compatible JVM ... "

So the above error gives because of the incompatible JVM version. (as it says in the line "Unsupported major.minor version 51.0" ).

So to fix this what you need to do is simply install the JDK 7 and add it to the classpath, JAVA_HOME and JRE_HOME. That will fix this.

HAPPY CEYLON CODING !!!


Monday, April 22, 2013

tools.jar can not be found in JRE folder

I came across this error other day i was trying to configure ant in my new machine. The reason for this is that the relevant jar file is not in the <JRE location>lib folder but in <JDK location>lib folder.

The most simplest fix for this is to just copy the "tools.jar" file from the <JDK location>lib to  
<JRE location>lib folder.
 
Good luck.
:)