shiro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tkofford <tkoff...@ku.edu>
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
credentials)

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

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();
shiroUser.hasPermission("somepermission");
shiroUser.getEmail();
shiroUser.getFirstName();
shiroUser.getLastName();

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

Thanks in advance!
Todd



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Best-Way-to-Add-Multiple-Fields-to-Subject-tp7580796.html
Sent from the Shiro User mailing list archive at Nabble.com.

Mime
View raw message