Topic
  • 6 replies
  • Latest Post - ‏2013-02-06T13:46:58Z by mburati
SystemAdmin
SystemAdmin
9029 Posts

Pinned topic Using a Custom UserInfoHandler

‏2010-03-29T19:59:29Z |
Hey All,

Im trying to implement a custom UserInfoHandler and have followed the below steps
1) Added "bowstreet.webapp.UserInfoHandler=com.wps.common.CustomUserInfoHandler" to my override.properties file.

2) Created a new class CustomUserInfoHandler.java to implement the UserInfoHandler class and added a method getUserInfo() to return my Custom UserInfo class.

public UserInfo getUserInfo(HttpServletRequest request) {
// TODO Auto-generated method stub
System.out.println("CHANGES MADE TO THE WEBAPPUSERINFORHANDLER");
CustomUserInfo custUserInfo = new CustomUserInfo();
custUserInfo.setRequest(request);
return custUserInfo;
}

3) Created a new class CustomUserInfo.java to implement UserInfo.java
Inside this class I overwrote the getUserID() method to simply return a string.
public String getUserID()
{
System.out.println("CUSTOMUSERINFO being called");
return "testing";
}
4) I added a class which tries to read the current user thats logged in
by useing the below code
String userLogged = webAppAccess.getUserInfo().getUserID();

Will the value of the userLogged == "testing" or will it be the current user logged into the Portal server.

Any help will be appreciated.

Regards
S

After following the above three steps. I redeployed my portlet to the WPS 6.1 portal server and
Updated on 2013-02-06T13:46:58Z at 2013-02-06T13:46:58Z by mburati
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Using a Custom UserInfoHandler

    ‏2010-03-30T18:42:20Z  
    Hey All,

    I have gotten this to work on the WAS CE Environment. But the same doesnt work in a Portal Evironment.

    Im attaching the model,code and the .properties files.

    Thx for looking.
  • mburati
    mburati
    2569 Posts

    Re: Using a Custom UserInfoHandler

    ‏2010-03-30T19:09:55Z  
    Hey All,

    I have gotten this to work on the WAS CE Environment. But the same doesnt work in a Portal Evironment.

    Im attaching the model,code and the .properties files.

    Thx for looking.
    Custom User Info handlers are not typically used anymore, so I'm curious what your use case is - there may be a better way to do what you're trying to accomplish.

    Way back at the beginning of time, before a little company called Bowstreet discovered how wonderful WebSphere Portal is and how much it does for you, the Bowstreet Factory used to support mainly web applications on application servers that didn't provide much in the way of user info, so the factory exposed the UserInfo API so that you could get things like LDAP data in a common means (API) if the appserver switched backennd user repositories and such. Most of what little doc there is on custom user info handlers is from those days.

    When WebSphere Portlet Factory started supporting WebSphere Portal, we used the same custom user info mechanism such that you could use the same user info API when running standalone as you can when running in portal, without having to change your app, BUT since portal does such a great job of insulating the user from which user repository IT is talking to, you don't typically have to change anything in the WPF portlet based on changing the backend because Portal hides that behind PUMA and WPF abstracts that with the UserInfo API, so there's usually no need anymore to change the user info handler.

    Anyway, it's better to try to make use of what's there than to reinvent it, so if you could describe what you're trying to get out of a custom user info handler (and if that info is available via PUMA then it should be available via the existing WPF portlet adapter custom user info handler) we can probably provide suggestions on how to meet your needs.

    ..mb1
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Using a Custom UserInfoHandler

    ‏2010-03-30T19:26:13Z  
    • mburati
    • ‏2010-03-30T19:09:55Z
    Custom User Info handlers are not typically used anymore, so I'm curious what your use case is - there may be a better way to do what you're trying to accomplish.

    Way back at the beginning of time, before a little company called Bowstreet discovered how wonderful WebSphere Portal is and how much it does for you, the Bowstreet Factory used to support mainly web applications on application servers that didn't provide much in the way of user info, so the factory exposed the UserInfo API so that you could get things like LDAP data in a common means (API) if the appserver switched backennd user repositories and such. Most of what little doc there is on custom user info handlers is from those days.

    When WebSphere Portlet Factory started supporting WebSphere Portal, we used the same custom user info mechanism such that you could use the same user info API when running standalone as you can when running in portal, without having to change your app, BUT since portal does such a great job of insulating the user from which user repository IT is talking to, you don't typically have to change anything in the WPF portlet based on changing the backend because Portal hides that behind PUMA and WPF abstracts that with the UserInfo API, so there's usually no need anymore to change the user info handler.

    Anyway, it's better to try to make use of what's there than to reinvent it, so if you could describe what you're trying to get out of a custom user info handler (and if that info is available via PUMA then it should be available via the existing WPF portlet adapter custom user info handler) we can probably provide suggestions on how to meet your needs.

    ..mb1
    Thx mb1,
    That answered my question.
    I was trying to connect to the LDAP using PUMA with code inside UserInfo, only coz I read this note on "Gathering Information" on Infocenter for WPF 6.1.2.

    I have decided to use a custom builder to achieve this task.

    Regards,
    S
  • mburati
    mburati
    2569 Posts

    Re: Using a Custom UserInfoHandler

    ‏2010-03-30T19:34:06Z  
    Thx mb1,
    That answered my question.
    I was trying to connect to the LDAP using PUMA with code inside UserInfo, only coz I read this note on "Gathering Information" on Infocenter for WPF 6.1.2.

    I have decided to use a custom builder to achieve this task.

    Regards,
    S
    Note, the default user info handler for WPF portlets already uses PUMA to get the user's info/attributes, so it may already do what you want.

    ..mb1
  • CarlD
    CarlD
    46 Posts

    Re: Using a Custom UserInfoHandler

    ‏2013-02-06T13:35:27Z  
    • mburati
    • ‏2010-03-30T19:09:55Z
    Custom User Info handlers are not typically used anymore, so I'm curious what your use case is - there may be a better way to do what you're trying to accomplish.

    Way back at the beginning of time, before a little company called Bowstreet discovered how wonderful WebSphere Portal is and how much it does for you, the Bowstreet Factory used to support mainly web applications on application servers that didn't provide much in the way of user info, so the factory exposed the UserInfo API so that you could get things like LDAP data in a common means (API) if the appserver switched backennd user repositories and such. Most of what little doc there is on custom user info handlers is from those days.

    When WebSphere Portlet Factory started supporting WebSphere Portal, we used the same custom user info mechanism such that you could use the same user info API when running standalone as you can when running in portal, without having to change your app, BUT since portal does such a great job of insulating the user from which user repository IT is talking to, you don't typically have to change anything in the WPF portlet based on changing the backend because Portal hides that behind PUMA and WPF abstracts that with the UserInfo API, so there's usually no need anymore to change the user info handler.

    Anyway, it's better to try to make use of what's there than to reinvent it, so if you could describe what you're trying to get out of a custom user info handler (and if that info is available via PUMA then it should be available via the existing WPF portlet adapter custom user info handler) we can probably provide suggestions on how to meet your needs.

    ..mb1
    What about using a custom UserInfoHandler when testing on tomcat? My client typically develops WEF portlets as servlets on tomcat even though the production target is portal server. There is no PUMA on tomcat, and we don't use LDAP to keep things simple - would it be appropriate to write a custom UserInfoHandler for development/unit testing purposes? The handler would never go to prod.

    Thanks. Carl.


    IBM Certified Solution Developer - WebSphere Portlet Factory 7.0
    My blog http://dsixe-wpf.blogspot.com
  • mburati
    mburati
    2569 Posts

    Re: Using a Custom UserInfoHandler

    ‏2013-02-06T13:46:58Z  
    • CarlD
    • ‏2013-02-06T13:35:27Z
    What about using a custom UserInfoHandler when testing on tomcat? My client typically develops WEF portlets as servlets on tomcat even though the production target is portal server. There is no PUMA on tomcat, and we don't use LDAP to keep things simple - would it be appropriate to write a custom UserInfoHandler for development/unit testing purposes? The handler would never go to prod.

    Thanks. Carl.


    IBM Certified Solution Developer - WebSphere Portlet Factory 7.0
    My blog http://dsixe-wpf.blogspot.com
    Carl,
    That seems like a reasonable use of a custom UserInfo handler, if the portlets rely on the UserInfo API but also must run standalone for testing.

    While portal does use more memory than Tomcat, I do find it's often better to use portal for dev too, if you're developing portlets that rely on portlet and portal functionality, so that you find out earlier in the cycle if there are going to be any integration issues, rather than later. You can still run standalone on the WAS server that portal runs on, for quicker dev/test turnaround cycles, but then also test as portlets more often than if you only have an appserver on your dev machines instead of a portal server(s).

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.