• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getUserPrincipal returns user ID differently

 
naga eswar
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI… I have an issue with getUserPrincipal.

I fetched username(proliant) using getUserPrincipal to my jsp page using getName().

But after fetching its getting “P” as capital letter i.e, Proliant.
User id should be case sensitive. I am using websphere application server 6.1
Please help me

 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
First of all, I suspect that you are in the wrong forum, since I assume your question is about web applications.
Second, what is the name of the principal that (probably) is defined in your application server?
Note that you can NOT obtain the name of the user retrieving the name of the principal, you will obtain the name of the principal which matched the user login credentials.
Best wishes!
 
naga eswar
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ivan,

Thank you for your reply.
Actually I posated in EJB and Other Java EE Technologies. As there is no reply, I posted here also.

As I am using getUserPrincipal() method first time. I dont know much about it.

But here I will describe about my application below clearly.

My application is recently integrating with SSO. SSO (LTPA) part is taking care by another team. As my client has many applications, he is going to integrate all applications under SSO. One of them is my application. Only authorized persons can enter into my application.

Here from our side we have done all changes and application is working fine except the above issue.
For testing getUserPrincipal() method in my local system, in websphere 6.1 I have enabled Administrative security and selected Local operating system user account repository. Now we have to provide credentials in order to enter into websphere console and also my application.

After login into websphere with credentials(user name as proliant ), on top its showing welcome Proliant i.e, p as capitcal letter.

When I ran my application, in logs it showing user name as Proliant. If we create new user with Proliant at the backend then its working.

Below is my code

String struserid=null;
Principal userPrincipal=request.getUserPrincipal();

if(userPrincipal!=null)
struserid=userPrincipal.getName();


You have mention name of the principal that (probably) is defined in your application server . Please let me know where this name of the principal is defined in application server and as read some where that Java.security.Principal.getName() will gives the username.

Actually what is the meaning of principal....???

Note: Websphere is installed by portal team. we dont have any admin role on it.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
A principal connects an identity with a credential which can be used for authentication. For instance, associates a user with a password.
For some explanations, see page 322-323 in this document: http://www.slideshare.net/krizsan/ocp-jbcd-6-study-notes
The reason for you seeing "proliant" in one place and "Proliant" in another may be that the latter is the user name (being part of the principal) and the former is the login credential (not being available in the principal).
I am not familiar with Websphere, so I cannot help you with configuration of the server, sorry.
Best wishes!
 
naga eswar
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ivan..

Thanks for your information.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic