Saturday, December 31, 2011

Configure Database Server LoginModule Realm in Jboss AS 7

If we want to do a Database login for JavaEE6 application, We need to configure the DatabaseServerLoginModule of Jboss by creating a Realm. Put following lines in standalone.xml ( or domain.xml) :

 
   
    
          
               
               
               
               
               
          
     
  


Replace values with your respected values. If you are using custom database module class replace code="Database" with code="<your class name>"
Now the realm is configured into server, We need to tell our application to use this realm. This can be achieved using web.xml

 
  FORM
  MyRealm
  
   /login.jsp
   /loginerror.jsp
  
 
 
  SuperAdmin
 
 
  Admin
 
 
  Manager
 
 
  Employee
 
From lines 1 to 8 we inform the application to make use of FORM method to authenticate users with Realm MyRealm and also provide the login and error pages.
Next we need to declare the security roles in the application. We have declared 4 roles SuperAdmin, Admin, Manager and Employee from lines 9 to 20.
Now we have configured the application we will add security constraint in web.xml to our application as below.

  
   MyApplication
   /administration/*
   GET
   POST
  
  
   SuperAdmin
   Admin
  
 
 
  
   Unprotected area
   /resources/*
  
 
We added two security constraints. First is to allow only SuperAdmin and Admin to enter the admin panel. Another example is when you have protected entire site but want to allow access to resources to all.

11 Things every Software Developer should be doing in 2012.

Saturday, December 24, 2011

JPA Performance, Don't Ignore the Database

http://weblogs.java.net/blog/caroljmcdonald/archive/2009/08/28/jpa-performance-dont-ignore-database-0

Friday, December 16, 2011

Install Postgresql 9.1 in Ubuntu 9.04

first install python-software-properties:
sudo apt-get install python-software-properties

now add repository and update apt.
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update

now instal postgresql
sudo apt-get install postgresql-9.1 libpq-dev

Now change the postgres user password (still running as root):
su postgres
psql -d postgres -U postgres
alter user postgres with password 'a';
\q

To install GUI client pgsql
sudo apt-get install pgadmin3

original article: http://bit.ly/sUFCgb

How to Accomplish More by Doing Less - Tony Schwartz - Harvard Business Review

How to Accomplish More by Doing Less - Tony Schwartz - Harvard Business Review.

Enable AutoComplete commands in Pinguy OS 11.04

To enable bash completion in interactive shells do following steps:

$ sudo vi /etc/bash.bashrc


uncomment following line in it

# enable bash completion in interactive shells
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi


Restart your terminal and its done!!!

Fix GPG error:....NO_PUBKEY

In Ubuntu, when we try to update the system we sometimes get error for GPG No_PUBKEY as follows:


W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://ppa.launchpad.net lucid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C1622487AAA521A8

This does no harm as its not a security issue but its very annoying everytime getting the same error. It happens because you don't have a suitable public key for a repository. Follow this steps to get rid of the error:


gpg --keyserver keyserver.ubuntu.com --recv 9BDB3D89CE49EC21

Which retrieves the key from ubuntu key server and then this:


gpg --export --armor 9BDB3D89CE49EC21 | sudo apt-key add -

Which adds the key to apt trusted keys. This will solve you problem.

The solution can be found here & here.

Tuesday, December 13, 2011

Real Java Geeks


Code hard! And get out of your cubicles! Video created for the Community Keynote at JavaOne Brasil.

Monday, December 12, 2011

Create intro flash / page in Joomla

Recently I am doing a website in joomla and I wanted to have an intro page for it. By default, there is no facility for it in joomla by default. Dont worry. Create an index.html file and put in the root directory. It will first take up that html file and you have successfully created an intro page. On this intro page provide a link to index.php file and you just entered into your joomla site. What if your hosting takes index.php as default? Then create .htaccess file and add following line in it:
       DirectoryIndex index.html index.php
This tells apache to load index.html as default page. replace index.html with your intro filename. Another option is to install joomla inside sub-directory and put intro file outside joomla directory and point index.php inside that sub directory.

Reset Apache2 on Ubuntu

Recently I was experimenting on apache2 and edited many config files. Soon I realised that PHP was not working properly on it. While installing joomla it was failing. So I removed apache2 using command:
     sudo apt-get purge apache2 
The problem was I didnt removed apache2 completely. Then I quicked googled and find out the correct way of getting it working back use following snippet.
APACHE_PKGS=`sudo dpkg --get-selections | grep apache | cut -f 1`
# Make sure things are sane:
echo $APACHE_PKGS
# Example output: apache2 apache2-mpm-prefork apache2-utils apache2.2-common \
# libapache2-mod-php5 libapache2-mod-python libapache2-svn
# Likely if you have a Python application:
# libapache2-mod-python libapache2-mod-python-doc libapache2-mod-wsgi
# Or if you roll with the PHP:
# libapache2-mod-php5
sudo apt-get remove --purge $APACHE_PKGS
# You might want to consider not re-installing the whole list;
# instead dump it out, audit, and install what you need:
sudo apt-get install $APACHE_PKGS
After this apache2 got resetted and working as it was freshly installed with all configurations replaced.
Reference : http://bit.ly/uBxq7L

Quote

"Never take decision when angry and Never make promise when happy."

Saturday, December 10, 2011

Data Structures: Stack

Data Structures can be defined as arrangement and storage or organization of data so that inserting, retrieving and modifying the data becomes efficient, faster and easier. There are different kinds of data structures available and can be used in our applications according to our requirement. Any application we develop is all about manipulating the data. So data structures are always required to write any application. Any data structure we consider can be implemented in any language of your choice. Hence data structures are independent of language. Data Structure consists of two parts:
  1. Data.
  2. Operations on that data.