Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to retrieve user name from a given Subject?

843811Jul 11 2005 — edited Jul 12 2005
I am in a situation where I need to retrieve user name from the Subject that is populated when user logs in. I have the active Subject and I do following to get the principals in the subject and iterate through them:
Set principals = subject.getPrincipals();
Iterator ite = principals.iterator();
while (ite.hasNext()) {
Principal prin = (Principal)ite.next();
String name = prin.getName();
}

But this contains all the principals, including user name, roles, password, etc. How do I programmatically determine which one is user name?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 9 2005
Added on Jul 11 2005
2 comments
297 views