List of usage examples for org.apache.shiro.authc Account getRoles
Collection<String> getRoles();
From source file:net.swigg.security.example.ExampleRealm.java
License:Open Source License
@Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { UsernamePasswordToken upToken = UsernamePasswordToken.class.cast(token); String principal = upToken.getUsername(); Account account = this.accountRepository.get(principal); // no account matches that principal if (null == account) { throw new UnknownAccountException(); }//from w ww . j ava 2s . com Set<Object> principals = Sets.newHashSet(account.getName(), account); principals.addAll(account.getRoles()); PrincipalCollection principalCollection = new SimplePrincipalCollection(principals, getName()); return new SimpleAuthenticationInfo(principalCollection, account.getPassword()); }