All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nutz.integration.shiro.realm.bean.User Maven / Gradle / Ivy

There is a newer version: 1.r.69.v20220215
Show newest version
package org.nutz.integration.shiro.realm.bean;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.ManyMany;
import org.nutz.dao.entity.annotation.Table;

@Table("users")
public class User extends AbstractShiroBean {
    
    public User() {}

	public User(String name, String passwd, String slat) {
        setName(name);
        this.passwd = passwd;
        this.salt = slat;
    }
	
	@Column
	private transient String passwd;
	
	@Column
	private transient String salt;
	
	@ManyMany(from="uid", relation="user_role", target=Role.class, to="role_id")
	private List roles;
	
	@ManyMany(from="uid", relation="user_permission", target=Permission.class, to="permission_id")
	private List permissions;

	public String getPasswd() {
		return passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

	public List getRoles() {
		return roles;
	}

	public void setRoles(List roles) {
		this.roles = roles;
	}

	public List getPermissions() {
		return permissions;
	}

	public void setPermissions(List permissions) {
		this.permissions = permissions;
	}
	
	public String getSalt() {
        return salt;
    }
	
	public void setSalt(String salt) {
        this.salt = salt;
    }
	
	

	//------------------------------------------
	public Set getRoleStrSet() {
		Set roleStrs = new HashSet();
		if (roles != null) {
			for (Role role : roles) {
				roleStrs.add(role.getName());
			}
		}
		return roleStrs;
	}
	
	public Set getPermissionStrSet() {
		Set permissionStrs = new HashSet();
		if (permissions != null) {
			for (Permission permission : permissions) {
				permissionStrs.add(permission.getName());
			}
		}
		return permissionStrs;
	}
	
	public Set getRolePermissionStrSet() {
	    Set permissionStrs = new HashSet();
	    if (roles != null) {
	        for (Role role : roles) {
                if (role.getPermissions() == null)
                    continue;
                for (Permission permission : role.getPermissions()) {
                    permissionStrs.add(permission.getName());
                }
            }
	    }
	    return permissionStrs;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy