shiro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tkofford <>
Subject Best Way to Add Multiple Fields to Subject?
Date Fri, 02 Oct 2015 19:50:35 GMT
I'd really like to integrate my user model object with a shiro Subject, so
that I can pass this single object around to do any user operations (create
or update user info in application DB), as well as any role/permissions
checking (shiro operations). My user model object is simple and only
includes (Username, employeeID, FirstName, LastName, email) all Strings.

I've seen comments that this can be done by adding each field as a separate
principle to the Subject using:
public SimpleAuthenticationInfo(PrincipalCollection principals, Object

or adding the user model object to the subject using:
public SimpleAuthenticationInfo(Object principal, Object credentials, String

I've also seen an article on creating a custom Subject object by providing
implementations of shiro classes: SubjectFactory and DefaultSecurityManager.
Ideally, I'd like to do the following in my code:

Subject shiroUser = SecurityUtils.getSubject();

Just wanted to know the best/easiest way to achieve this, or if there's a
best practice for this?

Thanks in advance!

View this message in context:
Sent from the Shiro User mailing list archive at

View raw message