package com.lightinit.hsdataportal.common;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Component;

/**
 * Created by Mr.Yao on 2017/7/6.
 */
@Component
public class PermissionUtilsPro {
    /***
     * 是否有超级权限
     * @return
     */
    public boolean IsSuperPermission(){
        Subject user = SecurityUtils.getSubject();
        if (null == user)
            return false;
        Object objectUserName = user.getPrincipal();
        if(objectUserName==null)
            return false;
        String currentUsername = (String) user.getPrincipal();
        return "admin".contains(currentUsername.toLowerCase());
    }

    public String CurrentName(){
        Subject user = SecurityUtils.getSubject();
        if (null == user)
            return "";
        Object objectUserName = user.getPrincipal();
        if(objectUserName==null)
            return "";
        return (String) user.getPrincipal();
    }
}
