Showing posts with label WebSphere Application Server. Show all posts
Showing posts with label WebSphere Application Server. Show all posts

Wednesday, October 19, 2011

Redirecting all users using Mobile devices to a specific URL

To redirect all the incoming requests from mobile devices to a sub-directory or a specific URL in IBM HTTP Server follow below steps: Open C:\IBM\HTTPServer\conf\httpd.conf file in edit mode. 1. Un-comment following live in the file by removing "#" from the front of the line. #LoadModule rewrite_module modules/mod_rewrite.so 2. Enable rewrite engine by adding following line to the end of the file: RewriteEngine on 3. Add rewrite condition for the detecting mobile devices after the above line using the below example: RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC] 4. Add rewrite rule for redirecting the user to specific URL after the above line using the below example RewriteRule ^(.*)$ http://mobile.example.com/wps/portal [L,R=302] 5. Save the file 6. Restart IBM HTTP Server. Now all user requests will be redirected to "http://mobile.example.com/wps/portal" sub URL.

Enable user redirection in IBM HTTP Server 7.0

To redirect all the incoming requests to a sub-directory or a specific URL in IBM HTTP Server follow below steps: Open C:\IBM\HTTPServer\conf\httpd.conf file in edit mode. 1. Un-comment following live in the file by removing "#" from the front of the line. #LoadModule rewrite_module modules/mod_rewrite.so 2. Enable rewrite engine by adding following line to the end of the file: RewriteEngine on 3. Add rewrite rule after the above line using the below example: RewriteRule ^/$ wps/portal [L,R] 4. Save the file 5. Restart IBM HTTP Server. Now all user requests will be redirected to "wps/portal" sub URL. You can redirect the user to another website also using the same method but in that situation you have to provide full URL starting with Http://...

Wednesday, July 6, 2011

Datasource Isolation Levels in WebSphere Application Server (WAS)

WebSphere Application Server (WAS) 6.0.2 and higher provide a new custom property webSphereDefaultIsolationLevel. This property can take one of the four values as listed below:
a) 8 -> TRANSACTION_SERIALIZABLE -> Repeatable Read (RR)
b) 4(default) -? TRANSACTION_REPEATABLE_READ -> Read Stability (RS)
c) 2 -> TRANSACTION_READ_COMMITTED -> Cursor Stability (CS)
d) 1 -> TRANSACTION_READ_UNCOMMITTED -> Uncommitted Read (UR)

Wednesday, June 8, 2011

Profile Management on 64 bit WebSphere Application Server (WAS) 7.0.x

WebSphere Application Server (WAS) 7.0.x does not provide Graphical Profile Management Tool like its sister 32 bit version does. Therefore you have to rely on manageprofiles.(bat/sh) command to create/augment/delete a profile.

Below command creates Deployment Manager Profile on the same server on which WebSphere Portal is installed.

manageprofiles -create -profileName DmgrDev01 -profilePath E:/IBM/WebSphere/DmgrDev01 -templatePath E:/IBM/WebSphere/AppServer/profileTemplates/management -serverType DEPLOYMENT_MANAGER -nodeName nodeo1 -cellName cello1 -hostName portal.pankaj.com -validatePorts -defaultPorts

This command has to be executed from \bin directory. The node name and cell should be different from the ones used while installing Portal Server.

Custom Authentication Filter

package com.pankaj.filters;

import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibm.portal.auth.ExplicitLoginFilter;
import com.ibm.portal.auth.ExplicitLoginFilterChain;
import com.ibm.portal.auth.FilterChainContext;
import com.ibm.portal.auth.exceptions.AuthenticationException;
import com.ibm.portal.auth.exceptions.AuthenticationFailedException;
import com.ibm.portal.auth.exceptions.PasswordInvalidException;
import com.ibm.portal.auth.exceptions.SystemLoginException;
import com.ibm.portal.auth.exceptions.UserIDInvalidException;

/**
 * @author Pankaj Gupta
 * build path dependency
 * 1. C:/IBM/WebSphere/PortalServer/base/wp.auth.base/shared/app/wp.auth.base.jar
 * 2. C:/IBM/WebSphere/PortalServer/base/wp.auth.cmd/shared/app/wp.auth.cmd.jar
 *
 */
public class CustomExplicitLoginFilter implements ExplicitLoginFilter {

 Context context = null;
 PumaHome pumaHome = null;

    public CustomExplicitLoginFilter() {
        super();

    }

    public void init(SecurityFilterConfig filterConfig) throws SecurityFilterInitException {
        System.out.println("Entering com.pankaj.filters.CustomExplicitLoginFilter.init(...)");
     try{
      context = new InitialContext();
   pumaHome = (PumaHome) context.lookup(com.ibm.portal.um.PumaHome.JNDI_NAME);
     } catch (Exception exp){
      exp.printStackTrace();
     }
        System.out.println("Exiting com.pankaj.filters.CustomExplicitLoginFilter.init(...)");
    }

    public void login(HttpServletRequest req, HttpServletResponse resp, String userID, char password[],
            FilterChainContext portalLoginContext, Subject subject, String realm, ExplicitLoginFilterChain chain)
            throws LoginException, WSSecurityException, PasswordInvalidException, UserIDInvalidException,
            AuthenticationFailedException, AuthenticationException, SystemLoginException,
            com.ibm.portal.auth.exceptions.LoginException {

     long startTime = System.currentTimeMillis();

     long subTaskTime = startTime;

     System.out.println("Entering CustomExplicitLoginFilter.login() ... Time Taken : " + (System.currentTimeMillis() - startTime) + " milli seconds");

     chain.login(req, resp, userID, password, portalLoginContext, subject, realm);

     System.out.println("User Authenticated ... Time Taken : " + (System.currentTimeMillis() - subTaskTime) + " milli seconds");
     subTaskTime = System.currentTimeMillis();

     List groupList = this.getUserGroups(req);

     System.out.println("User groups retrieved ... Time Taken : " + (System.currentTimeMillis() - subTaskTime) + " milli seconds");
     subTaskTime = System.currentTimeMillis();

     if(this.isUserGroupAvailable(req, groupList, "wpsadmins") || this.isUserGroupAvailable(req, groupList, "wpadmins")){
            System.out.println("Group Checked ... Time Taken : " + (System.currentTimeMillis() - subTaskTime) + " milli seconds");
            subTaskTime = System.currentTimeMillis();
      portalLoginContext.setRedirectURL("/wps/myportal/Administration");
            System.out.println("URL created ... Time Taken : " + (System.currentTimeMillis() - subTaskTime) + " milli seconds");
            subTaskTime = System.currentTimeMillis();
     }
        System.out.println("Exiting CustomExplicitLoginFilter.login(...) ... Time Took : "
          + (System.currentTimeMillis() - startTime) + " milli seconds");
    }


    public void destroy() {
        // This is an empty implementation. No code required!!!
    }

    private List getUserGroups(HttpServletRequest request) {
     List groupList = null;
     try {
      PumaProfile pumaProfile = pumaHome.getProfile(request);
      com.ibm.portal.um.User user = pumaProfile.getCurrentUser();
      PumaLocator pl = pumaHome.getLocator(request);
      groupList = pl.findGroupsByPrincipal(user, false);
     } catch(Exception exp){
      exp.printStackTrace();
     }

     return groupList;
    }

 private boolean isUserGroupAvailable(HttpServletRequest request, List groupList, String userGroup) {
  boolean groupFlag = false;
     try {
      List attribs = new ArrayList();
      attribs.add("cn");
      PumaProfile pumaProfile = pumaHome.getProfile(request);
      for(Iterator group_itr = groupList.iterator();group_itr.hasNext();){
       Group group = (Group) group_itr.next();
       Map group_attribs = pumaProfile.getAttributes(group, attribs );
       String group_cn = (String) group_attribs.get((Object)"cn");
       System.out.println("group cn: " + group_cn);
       if(group_cn.equals(userGroup)){
         groupFlag = true;
         break;
       }
      }
     }
     catch (Exception exp) {
   exp.printStackTrace();
     }
  return groupFlag;
    }
}

Step-by-step guide to Portal clustering

Installing and Clustering WebSphere Application Server (WAS) 7.0.0.5 and WebSphere Portal 6.1.5

Below are the major steps required to perform for Installing and clustering WebSphere Application Server and WebSphere Portal:

1. Install WebSphere Application Server Network Deployment 7.0.0.0 on the machine.
a. Select "None" during the step of creating a profile. WebSphere Portal will create its own WebSphere Application Server Profile later.
2. Update WebSphere Application Server to 7.0.0.5 level by installing respective fix pack. You can go to a higher version as well if available. Apply all available fixes as well. This is the minimum required. Apply both WAS and SDK fix packs.
3. Install Portal. Select "Full" install to install everything or "Administrative install" to install blank portal with only Administration Portlets. Apply any fix packs and fixes available to make sure that portal version is current and update with all the fixes.
4. Install Deployment Manager or create a new profile using "Profile Management Tool". Select "Management" and "Deployment Manager" in the profile sections. Install all fix packs and fixes as have been applied to WebSphere Application Server in the previous section to make sure that Deployment Manager and Application Server are on the same level if you are installing a fresh copy of Application Server for deployment manager.
5. Configure Deployment Manager, create a group called "wpsadmins", create exactly the same user as you have provided during the Portal installation and add this user to "wpsadmins" group.
6. Configure Portal for federation.





Following link provides a step-by-step guide to Portal clustering.

https://www-304.ibm.com/support/docview.wss?uid=swg21413946

Thursday, May 26, 2011

Fixpack and Fix download location for IBM Products

Use the following location to find and download fixes for different IBM products:

IBM Products Fixcentral

Version Details of WebSphere Portal, WebSphere Application Server (WAS) and Java SDK

To find the version of WebSphere Portal Server use the following command:

On Windows : run %WPS_HOME%\bin\WPVersionInfo.bat (e.g) c:\IBM\WebSphere\PortalServer\bin\WPVersionInfo.bat

On Unix : run $WPS_HOME/bin/versionInfo.sh (e.g) /opt/IBM/WebSphere/PortalServer/bin/WPVersionInfo.sh

To find the version of WebSphere Application Server use the following command:

On Windows : run %WAS_HOME%\bin\versionInfo.bat (e.g) c:\IBM\WebSphere\AppServer\versionInfo.bat

On Unix : run $WAS_HOME/bin/versionInfo.sh (e.g) /opt/IBM/WebSphere/AppServer/bin/versionInfo.sh

To find the version of Java SDK installed with WebSphere Application Server use the following command:

On Windows : run %WAS_HOME%\java\bin\java -fullversion (e.g) c:\IBM\WebSphere\AppServer\java\bin\java -fullversion

On Unix : run $WAS_HOME/java/bin/java -fullversion (e.g) /opt/IBM/WebSphere/AppServer/java/bin/java -fullversion

Removing Windows Service for WebSphere Application Server (WAS)

WASService.exe can be used to remove the Windows Service created for WebSphere Application Server. Following command can be used to remove the windows service:

WASService.exe -remove service_name

Here service name is the name which you see when you look at the properties of a service. The name is the last part of the service name. Complete name will be something like "IBMWAS70Service - HostNameNode01". Here the service name is "HostNameNode01". You should issue the command as:

WASService.exe -remove HostNameNode01

Note: You need to be logged in as Administrator and with a user having administrator rights. Also right click on the command console window and from the context menu choose "Run as Administrator".

Monday, January 31, 2011

Custom TAI Interceptor for WAS 6.1.x and upwards

package com.pankaj.test;

import java.util.Properties;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibm.websphere.security.WebTrustAssociationException;
import com.ibm.websphere.security.WebTrustAssociationFailedException;
import com.ibm.wsspi.security.tai.TAIResult;
import com.ibm.wsspi.security.tai.TrustAssociationInterceptor;

public class PortalCustomTAI implements TrustAssociationInterceptor {


public void cleanup() {
//TODO ... Perform any cleanup here.
}

public String getType() {
return "Custom TAI ... " + this.getClass().getName();
}

public String getVersion() {
return "1.0";
}

public int initialize(Properties prop) throws WebTrustAssociationFailedException {
System.out.println("Portal Custom TAI Initialized ... ");
//TODO Perform any initialization operations here.
return 0;
}

public boolean isTargetInterceptor(HttpServletRequest req) throws WebTrustAssociationException {
System.out.println("Portal Custom TAI isTargetInterceptor ... sessionId : " + req.getRequestedSessionId());
boolean isTAIHandlingRequired = false;
// isTAIHandlingRequired = .... ; //Perform the appropriate operation here to check if this is the right TAI to invoke.
System.out.println("Portal Custom TAI isTargetInterceptor ... : " + isTAIHandlingRequired);
return isTAIHandlingRequired;
}

public TAIResult negotiateValidateandEstablishTrust(HttpServletRequest req, HttpServletResponse res) throws WebTrustAssociationFailedException {
TAIResult taiResult = null;
System.out.println("1. Portal Custom TAI negotiateValidateandEstablishTrust ... sessionId : " + req.getRequestedSessionId());
String userId = "testUser"; //Perform the appropriate operation here to obtain the user id which needs to be authenticated without password.
if(userId != null && !userId.trim().equals("")){
taiResult = TAIResult.create(HttpServletResponse.SC_OK, userId);
}
System.out.println("2. Portal Custom TAI negotiateValidateandEstablishTrust userId: " + userId);
return taiResult;
}

}

Reuse the old session ID in WAS 6.1.x

Navigate to following:

Application servers > WebSphere_Portal > Process Definition > Java Virtual Machine > Custom Properties

Add a "New" custom property

Name: HttpSessionIdReuse
Value: true
Description: It instructs JVM to reuse the session ID when user session changes from unauthenticated to authenticated.

Enable anonymous session in WAS 6.1.x

Navigate to following:

Resource environment providers > WP NavigatorService > Custom properties

Add a "New" custom property:

Name: public.session
Value: true
Description: This property is used to enable anonymous user session.

Saturday, October 30, 2010

How to add a new base entry to VMM DB?

VMM Database insert statement:

insert into dbentity (entity_id, entity_type, unique_id, unique_name, unique_name_key) values (-3000, 'OrgContainer', 'a9e5a980-3cec-11da-a833-828d43500d21', 'o=testOrg2', 'o=testOrg2');


wimconfig.xml file changes:

<config:repositories xsi:type="config:DatabaseRepositoryType" adapterClassName="com.ibm.ws.wim.adapter.db.DBAdapter"
id="DB2MemberRepos" isExtIdUnique="true" supportExternalName="false" supportPaging="false"
.......
.......
entityRetrievalLimit="50" JDBCDriverClass="com.ibm.db2.jcc.DB2Driver" saltLength="12">
<config:baseEntries name="o=testOrg1" nameInRepository="o=testOrg1"/>
<config:baseEntries name="o=testOrg2" nameInRepository="o=testOrg2"/>
</config:repositories>


<config:realms delimiter="/" name="defaultWIMFileBasedRealm" securityUse="active"
allowOperationIfReposDown="false">
<config:participatingBaseEntries name="o=defaultWIMFileBasedRealm"/>
<config:participatingBaseEntries name="o=testOrg"/>
<config:participatingBaseEntries name="o=testOrg1"/>
<config:participatingBaseEntries name="o=testOrg2"/>
<config:defaultParents entityTypeName="OrgContainer" parentUniqueName="o=testOrg"/>
<config:defaultParents entityTypeName="PersonAccount" parentUniqueName="o=testOrg"/>
<config:defaultParents entityTypeName="Group" parentUniqueName="o=testOrg"/>
<config:uniqueUserIdMapping propertyForInput="uniqueName" propertyForOutput="uniqueName"/>
<config:userSecurityNameMapping propertyForInput="principalName" propertyForOutput="principalName"/>
<config:userDisplayNameMapping propertyForInput="principalName" propertyForOutput="principalName"/>
<config:uniqueGroupIdMapping propertyForInput="uniqueName" propertyForOutput="uniqueName"/>
<config:groupSecurityNameMapping propertyForInput="cn" propertyForOutput="cn"/>
<config:groupDisplayNameMapping propertyForInput="cn" propertyForOutput="cn"/>
</config:realms>

<config:realms delimiter="/" name="dbdir.testOrg" securityUse="active" allowOperationIfReposDown="true">
<config:participatingBaseEntries name="o=defaultWIMFileBasedRealm"/>
<config:participatingBaseEntries name="o=testOrg"/>
<config:participatingBaseEntries name="o=testOrg1"/>
<config:participatingBaseEntries name="o=testOrg2"/>
<config:defaultParents entityTypeName="OrgContainer" parentUniqueName="o=testOrg2"/>
<config:defaultParents entityTypeName="PersonAccount" parentUniqueName="o=testOrg2"/>
<config:defaultParents entityTypeName="Group" parentUniqueName="o=testOrg2"/>
<config:uniqueUserIdMapping propertyForInput="uniqueName" propertyForOutput="uniqueName"/>
<config:userSecurityNameMapping propertyForInput="principalName" propertyForOutput="externalName"/>
<config:userDisplayNameMapping propertyForInput="principalName" propertyForOutput="principalName"/>
<config:uniqueGroupIdMapping propertyForInput="uniqueName" propertyForOutput="uniqueName"/>
<config:groupSecurityNameMapping propertyForInput="cn" propertyForOutput="externalName"/>
<config:groupDisplayNameMapping propertyForInput="cn" propertyForOutput="cn"/>
</config:realms>

Friday, October 29, 2010

SECJ0369E: Authentication failed when using LTPA. The exception is

Check if following is correct based on the repository setting:

<config:supportedEntityTypes defaultParent="o=testOrg" name="PersonAccount">
<config:rdnProperties>uid</config:rdnProperties>

Check if defaultParent and config:rdnProperties have correct values.

Try cleaning up temporary folders :
wp_profile\temp
wp_profile\wstemp
wp_profile\tranlog

This might resolve the issue if all the configuration seems correct.

Thursday, April 1, 2010

New Features of WebSphere Application Server V 7.0

New features and enhancements in WebSphere Application Server V 7.0

Common
•    Built on top of Java Platform Enterprise Edition (Java EE) 5.0 and Java Standard Edition (Java SE) 6.0
•    Provides EJB 3.0
•    Provides Java Persistence API (JPA) 1.0
•    Ease in administration and movement of the applications from one environment to another.
•    Better performance than previous versions
•    EJB 3.0 API is simpler to code and provides better performance of previous versions.
•    Resource efficient features, faster run-time, and new high-performance Web Service Engine
•    LTPA Token V2.0 support for SSO

Administration
•    Easy administration with Job Manager – remotely manage different environments with Job Manager including standalone servers and clustered environments from one central location across dispersed geographical locations.
•    Administer multiple stand-alone nodes using Administrative agent – Single interface to administer multiple application servers, thereby reducing the overhead of running administrative services in every application server.
•    Provides support for portable properties files which can be deployed across multiple environments with portable resource identifiers. Improves administration and movement of applications across different environments like dev, test, uat, prod, etc.
•    Configure client reroute for applications using DB2 database – Specify alternate DB2 database server in case primary server fails to reroute the client requests to provide high availability.
•    Authentication alias can be defined for each server. Server level authentication aliases will not be visible / accessible to other servers in the environment.
•    Multiple mail providers and sessions supported. Different versions of the mail provider can co-exist with in the same JVM to provide better control and segregation for different applications.
•    Business-level application is a new way of grouping applications together. This is in addition to servers, clusters, cells, EARs, WARs, etc. This way multiple EARs/WARs/JARs can be grouped together into one logical unit and me managed that way like start/stop them all with one command.
•    Support of trusted context for DB2 databases to provide fine grained access control.

Security
•    Support for Security Domains – Multiple security domains can be configured. Different applications/servers/clusters can be assigned to different security domains to achieve fine grained control over authentication/authorization. Local configuration defined for an application/server/cluster will over-ride global configuration; Following can be configured at local level:
o    Application Security
o    Java 2 Security
o    User Realm (user registry)
o    Trust Association (TAI)
o    JAAS Login Module (Application, System and J2C Authentication Data)
o    Authentication mechanism attributes
o    Simple and Protected GSS-API Negotiation (SPNEGO) Web Authentication
o    Authorization provider
o    Other attributes
o    Custom properties
•    SPNEGO Web Authentication is now supported with enhanced features including dynamic reload of SPNEGO module with the need of server restart.

Development
•    Better transaction execution isolation with the provision to specify “commit priority” of the resources contained in a transaction.
•    Client reroute for applications that use DB2 databases
•    Better handling of data access exception with custom error mapping in DataStoreHelper

Friday, February 5, 2010

Scoped Classloading in WebSphere

Often there are situations when libraries included in the web archive (*.war) file are to be loaded first since their version differs from the version being loaded at enterprise archive (*.ear) level. Lets take an example where X.ear has a war module Z.war. There is a common.jar file which is included at X.ear level. If Z.war wants to provide its own version of the common.jar file then the best way to load this jar file is to use application class loader only to load war module files also. By default application (.ear) has application scope class loader and web module (.war) has its own class loader. The default setting to load classes is “Parent First”. Change this setting to “Parent Last” and also change the setting to single calss loader as per the figure shown below:
image
There is only one class loader for application and all web module files are also loaded using the same application class loader. This makes web module level classes also visible to the application class loader. As per the hierarchy, parent class loader cannot see classes loaded by the child class loader. In this case all files are loaded by one class loader therefore all classes are visible to each other across the application. Moreover, we have asked it to load child classes first, therefore, it will loaded web module (.war) classes first and then will load the classes defined at application level. This way web module can load its own classes first and hide the classes provided by application.

Tuesday, January 12, 2010

Custom Portlet Service

A WebSphere Portlet service is used to provide common functionality/services to portlets. WebSphere Portal provides many out of the box portlet services for different functionality like PUMA, authentication, etc.

JSR 168 portlets use JNDI lookup to obtain an instance of the required portlet service. A portlet service can only be invoked from inside a portlet.

Following are the steps to create a custom Portlet Service:
1. Create an interface which extends com.ibm.portal.portlet.service.PortletService interface and defines public methods which you want to expose through the service.
2. Implement the above interface along with com.ibm.portal.portlet.service.spi.PortletServiceProvider interface in your custom class.
3. Register the portlet service with Portal.

CODE for the above is as follows:

package com.pankaj.portlet.service;

import java.util.Map;

import com.ibm.portal.portlet.service.PortletService;

/**
* @author Pankaj Gupta
*
*/

public interface PortalUserCreationService extends PortletService {

public static final String JNDI_NAME = "portletservice/com.pankaj.portlet.service.PortalUserCreationService";

public static final Class serviceClass = com.pankaj.portlet.service.PortalUserCreationService.class;

public boolean createUser(String shortName, String parentDN, Map map);
}

Code Listing 1: Interface PortalUserCreationService


package com.pankaj.portlet.service.impl;

import java.util.Map;
import java.util.prefs.Preferences;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.ibm.portal.portlet.service.PortletServiceHome;
import com.ibm.portal.portlet.service.PortletServiceUnavailableException;
import com.ibm.portal.portlet.service.spi.PortletServiceProvider;
import com.ibm.portal.um.PumaController;
import com.ibm.portal.um.PumaHome;
import com.ibm.portal.um.User;
import com.ibm.portal.um.exceptions.PumaAttributeException;
import com.ibm.portal.um.exceptions.PumaMissingAccessRightsException;
import com.ibm.portal.um.exceptions.PumaModelException;
import com.ibm.portal.um.exceptions.PumaSystemException;
import com.ibm.websphere.cache.DistributedMap;

/**
* @author Pankaj Gupta
*
*/

public class PortalUserCreationServiceImpl implements PortalUserCreationService, PortletServiceProvider {

private Context ctx = null;

private PumaController pumaController = null;
private PumaHome pumaHome = null;

public boolean createUser(String shortName, String parentDN, Map map) {
boolean flag = false;
try {
User user = pumaController.createUser(shortName, parentDN, map);
flag = true;
}
catch (PumaAttributeException e) {
e.printStackTrace();
}
catch (PumaSystemException e) {
e.printStackTrace();
}
catch (PumaModelException e) {
e.printStackTrace();
}
catch (PumaMissingAccessRightsException e) {
e.printStackTrace();
}
return flag;
}

public void init(Preferences arg0) throws PortletServiceUnavailableException {

try {
ctx = new InitialContext();
pumaHome = (PumaHome)ctx.lookup(PumaHome.JNDI_NAME);
pumaController = pumaHome.getController();
}
catch (NamingException e) {
e.printStackTrace();
}

}

}

Code Listing 2: Implementation of the Listing 1 Interface

package com.pankaj.portlet.service.common;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.ibm.portal.portlet.service.PortletService;
import com.ibm.portal.portlet.service.PortletServiceHome;
import com.ibm.portal.portlet.service.PortletServiceUnavailableException;

/**
* @author Pankaj Gupta
*
*/
public class PortletServiceLocator {
//
public static PortletService getPortletService(String jndiName, Class serviceClass){
PortletServiceHome portletServiceHome = null;
PortletService portletService = null;

try {
Context ctx = new InitialContext();
portletServiceHome = (PortletServiceHome)ctx.lookup(jndiName);
portletService = (PortletService) portletServiceHome.getPortletService(serviceClass);
}
catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (PortletServiceUnavailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return portletService;
}
}

Code Listing 3: Service Locator class which abstracts the service lookup.

Monday, January 11, 2010

DB2 DB creation script to create user repository DB for Portal

The following script creates a DB2 DB for storing user credentials. This DB will be used to create a custom user repository in DB2 and use the same to authenticate the portal users.




db2 "CREATE DB wimDb ON 'D:\', 'D:\IBM\wimDb' DBPATH ON 'D:\' using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR wimDb USING applheapsz 4096"
db2 "UPDATE DB CFG FOR wimDb USING app_ctl_heap_sz 1024"
db2 "UPDATE DB CFG FOR wimDb USING stmtheap 32768"
db2 "UPDATE DB CFG FOR wimDb USING dbheap 2400"
db2 "UPDATE DB CFG FOR wimDb USING locklist 1000"
db2 "UPDATE DB CFG FOR wimDb USING logfilsiz 4000"
db2 "UPDATE DB CFG FOR wimDb USING logprimary 12"
db2 "UPDATE DB CFG FOR wimDb USING logsecond 20"
db2 "UPDATE DB CFG FOR wimDb USING logbufsz 32"
db2 "UPDATE DB CFG FOR wimDb USING avg_appls 5"
db2 "UPDATE DB CFG FOR wimDb USING locktimeout 30"
db2 "UPDATE DB CFG FOR wimDb using AUTO_MAINT off"



Replace the 'D:\', 'D:\IBM\wimDb' DBPATH ON 'D:\' with your own settings. D:\IBM\wimDb is the directory where DB data files will be stored. D:\ is the path under which DB2 directory will be created which will store DB configuration files.

Sponsor Advertisement