|
|
@ -19,7 +19,7 @@ import com.ruoyi.system.domain.SysUser;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ShiroUtils
|
|
|
|
public class ShiroUtils
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public static Subject getSubjct()
|
|
|
|
public static Subject getSubject()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return SecurityUtils.getSubject();
|
|
|
|
return SecurityUtils.getSubject();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -31,13 +31,13 @@ public class ShiroUtils
|
|
|
|
|
|
|
|
|
|
|
|
public static void logout()
|
|
|
|
public static void logout()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
getSubjct().logout();
|
|
|
|
getSubject().logout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static SysUser getSysUser()
|
|
|
|
public static SysUser getSysUser()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SysUser user = null;
|
|
|
|
SysUser user = null;
|
|
|
|
Object obj = getSubjct().getPrincipal();
|
|
|
|
Object obj = getSubject().getPrincipal();
|
|
|
|
if (StringUtils.isNotNull(obj))
|
|
|
|
if (StringUtils.isNotNull(obj))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
user = new SysUser();
|
|
|
|
user = new SysUser();
|
|
|
@ -48,7 +48,7 @@ public class ShiroUtils
|
|
|
|
|
|
|
|
|
|
|
|
public static void setSysUser(SysUser user)
|
|
|
|
public static void setSysUser(SysUser user)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Subject subject = getSubjct();
|
|
|
|
Subject subject = getSubject();
|
|
|
|
PrincipalCollection principalCollection = subject.getPrincipals();
|
|
|
|
PrincipalCollection principalCollection = subject.getPrincipals();
|
|
|
|
String realmName = principalCollection.getRealmNames().iterator().next();
|
|
|
|
String realmName = principalCollection.getRealmNames().iterator().next();
|
|
|
|
PrincipalCollection newPrincipalCollection = new SimplePrincipalCollection(user, realmName);
|
|
|
|
PrincipalCollection newPrincipalCollection = new SimplePrincipalCollection(user, realmName);
|
|
|
@ -75,12 +75,12 @@ public class ShiroUtils
|
|
|
|
|
|
|
|
|
|
|
|
public static String getIp()
|
|
|
|
public static String getIp()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSubjct().getSession().getHost();
|
|
|
|
return getSubject().getSession().getHost();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String getSessionId()
|
|
|
|
public static String getSessionId()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return String.valueOf(getSubjct().getSession().getId());
|
|
|
|
return String.valueOf(getSubject().getSession().getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|