Showing posts from July, 2012

Creating a portlet project using maven archetype

mvn archetype:create -DgroupId=com.myportlet -DartifactId=myportletproject -DarchetypeArtifactId=maven-archetype-portlet

Integrating Struts2 and spring security -with apache ds

Pre-requisites: Apache directory studio-1.5.3Apache- Ds server 1.5Jboss5.1gaEclipseJava 1.6
Add  a application-security-ldap.xml to web-inf folder.

The application-secuirty-ldap.xml file  contains 2 parts  that needs to be configured: http and the authentication manager

The http tag-contains url that needs to be authenticated and  and authorised with role.
If a user is authenticated and not authorised -then the app redirects the user to access denied page.This configuration is done in web.xml file.

The second part is the <authentication-manager> this has information about type of authentication provider used, its urls and credentials.In the below example I have used ldap-server which connects with apache ds which is listening at port:10389 and the partition that needs to be searched is "sevenSeas".
The ldap-authentication provider gives input on what attributes needs to be searched for the user name.In the configuration- mail is mapped as username  and roles are retrieved fro…

Starting apache ds server

Control Panel->Administrative Tools->Services

Click on Apache Directory Server- in the left side you would get an option to start the server.
Click on start.

Creating partition in apache directory server and loading the context

Install-apache ds1.5 and apache directory studio.

Creating partition in apache directory server and loading the context

Open server.xml file--->C:\Program Files\Apache Directory Server\instances\default\conf\server.xml
add jdm partition-   
<jdbmPartition id="prdc" suffix="o=prdc"/> 
You can restart the apache ds server to see the changes.

Then connect to Apache DS using the Apache Directory Studio.
Right Click on DIT
Create Entry from Scratch  select Organization 
select o and in the value enter-"prdc"
select finish
and refesh the DIT to see the updates.

JBOSS-javax.inject.DefinitionException: import not a Java type

I got this error while executing spring-jdbc with spring secuirty.
The reason is the name- of the beans.xml file.
Looks like jboss doesnt like beans.xml .
I renamed my beans.xml file to jdbc-beans.xml.
The error was gone.

Integrating Struts2 with Spring Security using Custom Login Form

Integrating Struts2 with Spring Security involves few configurations.

Add all the spring core and spring security related jars-- spring -3.0.6

Struts2-Action :gets user principal and displays it on jsp after authentication
package com.prdc.spring3; import java.util.ArrayList; import javax.servlet.http.HttpServletRequest; import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.Set; import org.apache.struts2.ServletActionContext; public class HelloWorld { private String message; private String username; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String execute() { /*to get the authenticated username*/ HttpServletRequest request = ServletActionContext.getRequest(); this.setUsername(request.getUserPrincipal().getName()); …

How Does DriverManger -return a Connection Object

DriverManger has a static method called -static Connection getConnection(String url, String user, String password)--> Attempts to establish a connection to the given database URL.

which returns a Connection Object.
The returned Connection Object is an Interface.
Connection con=DriverManger.getConnection(String url, String user, String password)