Since clients authenticate to the secured system with the PortalSession object, any Java component that is hosted on the application server can retrieve the PortalSession object using the following code:
InitialContext ctx = new InitialContext();
PortalSessionHome pshome =
ctx.lookup("com.sybase.ep.security.sessionsvcs/PortalSession");
PortalSession session = pshome.findByCurrentSession();