Example usage for org.apache.shiro.subject SimplePrincipalCollection clear

List of usage examples for org.apache.shiro.subject SimplePrincipalCollection clear

Introduction

In this page you can find the example usage for org.apache.shiro.subject SimplePrincipalCollection clear.

Prototype

public void clear() 

Source Link

Usage

From source file:io.github.howiefh.jeews.modules.sys.security.realm.StatelessRealm.java

License:Apache License

@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    // ????//  ww w .  j a  v a  2s .com
    String username = (String) principals.getPrimaryPrincipal();

    User user = userService.findByName(username);
    SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();

    SimplePrincipalCollection principalCollection = (SimplePrincipalCollection) principals;
    principalCollection.clear();
    principalCollection.add(user, getName());

    RolePermission rolePermission = user.new RolePermission();
    authorizationInfo.setRoles(rolePermission.getRoleSet());
    authorizationInfo.setStringPermissions(rolePermission.getPermissionSet());
    return authorizationInfo;
}