Jetspeed with filter authentication

Jetspeed 2 authenticate user’s with JAAS. Jetspeed installer and maven plug-in both configure tomcat for JAAS authentication.

I have seen people facing problem in configuring JAAS in different application server e.g Websphere, Jboss etc.In some case user face error in tomcat too.
This is the common error log, if JAAS is not configured properly

javax.security.auth.login.LoginException: unable to find LoginModule
class: org.apache.jetspeed.security.impl.DefaultLoginModule
at javax.security.auth.login.LoginContext.invoke(LoginContext.java:808)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)

Jetspeed is modular and easy to configure. Jetspeed authentication can be configured with-out JASS.
For using different authentication then JAAS, you would need to edit web.xml of jetspeed. You will find an commented entry for portal filter.

<!--

<filter>

<filter-name>PortalFilter</filter-name>

<filter-class>org.apache.jetspeed.login.filter.PortalFilter</filter-class>

</filter>

-->

<!--

<filter-mapping>

<filter-name>PortalFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

-->

Just un-comment the above filter configuration and restart your application ( Some application server, don’t take changes in web.xml, once deployed). I would recommend to make these changes before deploy.

Once server is started, Jetspeed login should work

Apache Jetspeed-2 installation

Jetspeed-2 installation

Jetspeed-2 (JS2) portal installation is very easy and simple,still i have seen lot of people
having trouble in installation. Its very important to under-stand, what exactly is required to run jetspeed.

Jetspeed in more generic way an web application, which is serving user request as portal and requires three simple thing to run

Database

Jetspeed has custom database structure, which is an essential for running.
JS2 use database via JNDI, JS2 expect jndi to be named is “jdbc/jetspeed”.
JS2 will try to access database with this JNDI, there can be different way to setup JNDI in different application server. I would recommend to test database via JNDI from application server.

Shared lib

Jetspeed require shared lib to be setup with in application server. Each application server have different way to set-up shared lib. Different version of jetspeed require different files in shared lib.

Jetspeed 2.1.3
jetspeed-api-2.1.3.jar
jetspeed-commons-2.1.3.jar
pluto-1.0.1.jar
portals-bridges-common-1.0.4.jar
portlet-api-1.0.jar

Jetspeed 2.2.0
ccpp-1.0.jar
jetspeed-api-2.2-SNAPSHOT.jar
jetspeed-commons-2.2-SNAPSHOT.jar
pluto-container-api-2.0.0-SNAPSHOT.jar
pluto-taglib-2.0.0-SNAPSHOT.jar
portals-bridges-common-1.0.4.jar
portlet-api-2.0.jar

Note:

1) Make sure, Version of shared libraries should be same as version of jetspeed.
2) Jetspeed-api and jetspeed common, should be present only in shared lib, not even with your portlet application.

JAAS authentication setup


I would say this step is more-over optional and can be configured differently according to your requirement. Jespeed out-of-box comes with JAAS authentication, again like the above two steps. It is all depends on the application server to configure it.

Jetspeed installer comes with tomcat 5.5.27 and have JAAS authentication as pre configured to use. If you are facing problem ins setting up JAAS in your application server. I would suggest you to go set up jetspeed with filter authentication  Go here “filter-Authentication” for details on this.

Last and final step

Deploy jetspeed.war in your application server.

open browser with http://localhost:8080/jetspeed/portal
this should show default jetspeed.

Hope this will help.

Delegation Versus Inheritance in java

Inheritance in JAVA programming is the process by which one class takes the property of another other class. i.e. the new classes, known as derived or super class, take over the attributes and behavior of the pre-existing classes, which are referred to as base classes or child class.

Inheritance is used to create a hierarchical-type code structure that tries to keep as much “common” code near the top of the hierarchy. In small, static systems, inheritance can be ok. But large inheritance chains can also lead to hard-to-maintain code. Read up on design patterns that favor composition over inheritance for more info when to use inheritance and when not to.

Delegation is simply passing a duty off to someone/something else.Delegation is alternative to inheritance. Delegation means that you use an object of another class as an instance variable, and forward messages to the instance. It is better than inheritance because it makes you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn’t force you to accept all the methods of the super class: you can provide only the methods that really make sense.Delegation can be viewed as a relationship between objects where one object forwards certain method calls to another object, called its delegate. Delegation can also a powerful design/reuse technique. The primary advantage of delegation is run-time flexibility – the delegate can easily be changed at run-time. But unlike inheritance, delegation is not directly supported by most popular object-oriented languages, and it doesn’t facilitate dynamic polymorphism.

Here is a simple example:

class ABC {
	     void methodHello()
    {
    System.out.println("hello");

    }

    void methodBye()
    {
     System.out.println("bye"); }
    }

class XYZ {
	     ABC obj = new ABC();

	 void methodHello()
        {
         obj.methodHello();
        }

        void methodBye()
        {
         obj.methodBye();
        }

}

public class VinayMain {
	     public static void main(String[] args) {
	         XYZ obj = new XYZ();
	         obj.methodHello();
	         obj.methodBye();
	     }
}

Sometimes, the choice between delegation and inheritance is driven by external factors such as programming language support for multiple inheritance or design constraints requiring polymorphism. Consider threads in Java. You can associate a class with a thread in one of two ways: either by extending (inheriting) directly from class Thread, or by implementing the Runnable interface and then delegating to a Thread object. Often the approach taken is based on the restriction in Java that a class can only extend one class (i.e., Java does not support multiple inheritance). If the class you want to associate with a thread already extends some other class in the design, then you would have to use delegation; otherwise, extending class Thread would usually be the simpler approach

 

Pin it