Skip to content

Commit

Permalink
closes #18 - PrincipalForApplicationUser#toString() now returns the u…
Browse files Browse the repository at this point in the history
…ser's name....

... so that httpServletRequest.getPrincipal().getName() returns the users name when queried via Shiro.
  • Loading branch information
danhaywood committed May 8, 2015
1 parent a4fef1b commit 2b8fbe9
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Set;

import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.Permission;

import org.isisaddons.module.security.dom.permission.ApplicationPermissionValueSet;
import org.isisaddons.module.security.dom.role.ApplicationRole;
import org.isisaddons.module.security.dom.user.AccountType;
Expand All @@ -42,6 +45,9 @@
* {@link IsisModuleSecurityRealm#doGetAuthorizationInfo(org.apache.shiro.subject.PrincipalCollection) authorization} merely involves
* creating an adapter object for the appropriate Shiro API.
* </p>
*
* TODO: this should probably implement java.security.Principal so that it doesn't get wrapped in a
* ShiroHttpServletRequest.ObjectPrincipal. Such a change would need some testing to avoid regressions, though.
*/
class PrincipalForApplicationUser implements AuthorizationInfo {

Expand Down Expand Up @@ -127,4 +133,16 @@ ApplicationPermissionValueSet getPermissionSet() {
public AccountType getAccountType() {
return accountType;
}

/**
* When wrapped by ShiroHttpServletRequest.ObjectPrincipal, the principal's name is derived by calling toString().
*
* TODO: this should probably implement java.security.Principal so that it doesn't get wrapped in a
* ShiroHttpServletRequest.ObjectPrincipal. Such a change would need some testing to avoid regressions, though.
*
*/
@Override
public String toString() {
return getUsername();
}
}

0 comments on commit 2b8fbe9

Please sign in to comment.