Subject.getPrincipal

Returns this Subject's application-wide uniquely identifying principal, or {@code null} if this Subject is anonymous because it doesn't yet have any associated account data (for example, if they haven't logged in). <p/> The term <em>principal</em> is just a fancy security term for any identifying attribute(s) of an application user, such as a username, or user id, or public key, or anything else you might use in your application to identify a user. <h4>Uniqueness</h4> Although given names and family names (first/last) are technically considered principals as well, Shiro expects the object returned from this method to be an identifying attribute unique across your entire application. <p/> This implies that things like given names and family names are usually poor candidates as return values since they are rarely guaranteed to be unique; Things often used for this value: <ul> <li>A {@code long} RDBMS surrogate primary key</li> <li>An application-unique username</li> <li>A {@link java.util.UUID UUID}</li> <li>An LDAP Unique ID</li> </ul> or any other similar suitable unique mechanism valuable to your application. <p/> Most implementations will simply return <code>{@link #getPrincipals()}.{@link hunt.shiro.subject.PrincipalCollection#getPrimaryPrincipal() getPrimaryPrincipal()}</code>

@return this Subject's application-specific unique identity. @see hunt.shiro.subject.PrincipalCollection#getPrimaryPrincipal()

interface Subject
Object
getPrincipal
()

Meta