Subject.toString() returns the list of principals but no the authenticated user name

StackOverflow https://stackoverflow.com/questions/22863198

  •  27-06-2023
  •  | 
  •  

Question

 [java] Logged in as Subject:
 [java]     Principal: write
 [java]     Principal: read
 [java]     Principal: delete

That's the output of javax.security.auth.Subject#toString(). It's not returning the username, but it does return the principals properly.

What could be failing?

        logincontext.login();
        Subject subject = logincontext.getSubject();
        System.out.println("Logged in as " + subject.toString());

edit: it seems to be something normal. I have been checking lot of examples, and no one is returning the username. Don't know why whoever developed this added a Subject tag then...

Était-ce utile?

La solution

it seems to be something normal. I have been checking lot of examples, and no one is returning the username. Don't know why whoever developed this added a Subject tag then...

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top