Search code examples
javajaas

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


 [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...


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...