Java Code Examples for com.ruoyi.framework.shiro.session.OnlineSession#markAttributeChanged()

The following examples show how to use com.ruoyi.framework.shiro.session.OnlineSession#markAttributeChanged() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OnlineWebSessionManager.java    From supplierShop with MIT License 5 votes vote down vote up
@Override
public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) throws InvalidSessionException
{
    super.setAttribute(sessionKey, attributeKey, value);
    if (value != null && needMarkAttributeChanged(attributeKey))
    {
        OnlineSession session = getOnlineSession(sessionKey);
        session.markAttributeChanged();
    }
}
 
Example 2
Source File: OnlineWebSessionManager.java    From supplierShop with MIT License 5 votes vote down vote up
@Override
public Object removeAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException
{
    Object removed = super.removeAttribute(sessionKey, attributeKey);
    if (removed != null)
    {
        OnlineSession s = getOnlineSession(sessionKey);
        s.markAttributeChanged();
    }

    return removed;
}
 
Example 3
Source File: OnlineSessionFilter.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 表示是否允许访问;mappedValue就是[urls]配置中拦截器参数部分,如果允许访问返回true,否则false;
 */
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
        throws Exception
{
    Subject subject = getSubject(request, response);
    if (subject == null || subject.getSession() == null)
    {
        return true;
    }
    Session session = onlineSessionDAO.readSession(subject.getSession().getId());
    if (session != null && session instanceof OnlineSession)
    {
        OnlineSession onlineSession = (OnlineSession) session;
        request.setAttribute(ShiroConstants.ONLINE_SESSION, onlineSession);
        // 把user对象设置进去
        boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L;
        if (isGuest == true)
        {
            SysUser user = ShiroUtils.getSysUser();
            if (user != null)
            {
                onlineSession.setUserId(user.getUserId());
                onlineSession.setLoginName(user.getLoginName());
	onlineSession.setAvatar(user.getAvatar());
                onlineSession.setDeptName(user.getDept().getDeptName());
                onlineSession.markAttributeChanged();
            }
        }

        if (onlineSession.getStatus() == OnlineStatus.off_line)
        {
            return false;
        }
    }
    return true;
}
 
Example 4
Source File: OnlineWebSessionManager.java    From ruoyiplus with MIT License 5 votes vote down vote up
@Override
public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) throws InvalidSessionException
{
    super.setAttribute(sessionKey, attributeKey, value);
    if (value != null && needMarkAttributeChanged(attributeKey))
    {
        OnlineSession s = (OnlineSession) doGetSession(sessionKey);
        s.markAttributeChanged();
    }
}
 
Example 5
Source File: OnlineWebSessionManager.java    From ruoyiplus with MIT License 5 votes vote down vote up
@Override
public Object removeAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException
{
    Object removed = super.removeAttribute(sessionKey, attributeKey);
    if (removed != null)
    {
        OnlineSession s = (OnlineSession) doGetSession(sessionKey);
        s.markAttributeChanged();
    }

    return removed;
}
 
Example 6
Source File: OnlineSessionFilter.java    From ruoyiplus with MIT License 5 votes vote down vote up
/**
 * 表示是否允许访问;mappedValue就是[urls]配置中拦截器参数部分,如果允许访问返回true,否则false;
 */
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue)
        throws Exception
{
    Subject subject = getSubject(request, response);
    if (subject == null || subject.getSession() == null)
    {
        return true;
    }
    Session session = onlineSessionDAO.readSession(subject.getSession().getId());
    if (session != null && session instanceof OnlineSession)
    {
        OnlineSession onlineSession = (OnlineSession) session;
        request.setAttribute(ShiroConstants.ONLINE_SESSION, onlineSession);
        // 把user对象设置进去
        boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L;
        if (isGuest == true)
        {
            SysUser user = ShiroUtils.getSysUser();
            if (user != null)
            {
                onlineSession.setUserId(user.getUserId());
                onlineSession.setLoginName(user.getLoginName());
                onlineSession.setDeptName(user.getDept().getDeptName());
                onlineSession.markAttributeChanged();
            }
        }

        if (onlineSession.getStatus() == OnlineStatus.off_line)
        {
            return false;
        }
    }
    return true;
}
 
Example 7
Source File: OnlineWebSessionManager.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
@Override
public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value){
    super.setAttribute(sessionKey, attributeKey, value);
    if (value != null && needMarkAttributeChanged(attributeKey)) {
        OnlineSession s = (OnlineSession) doGetSession(sessionKey);
        s.markAttributeChanged();
    }
}
 
Example 8
Source File: OnlineWebSessionManager.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
@Override
public Object removeAttribute(SessionKey sessionKey, Object attributeKey){
    Object removed = super.removeAttribute(sessionKey, attributeKey);
    if (removed != null) {
        OnlineSession s = (OnlineSession) doGetSession(sessionKey);
        s.markAttributeChanged();
    }

    return removed;
}
 
Example 9
Source File: OnlineSessionFilter.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
/**
 * 表示是否允许访问;mappedValue就是[urls]配置中拦截器参数部分,如果允许访问返回true,否则false;
 */
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue){
    Subject subject = getSubject(request, response);
    if (subject == null || subject.getSession() == null) {
        return true;
    }
    Session session = onlineSessionDAO.readSession(subject.getSession().getId());
    if (session instanceof OnlineSession) {
        OnlineSession onlineSession = (OnlineSession) session;
        request.setAttribute(ShiroConstants.ONLINE_SESSION, onlineSession);
        // 把user对象设置进去
        boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == 0L;
        if (isGuest) {
            SysUser user = ShiroUtils.getSysUser();
            if (user != null) {
                onlineSession.setUserId(user.getUserId());
                onlineSession.setLoginName(user.getLoginName());
                onlineSession.setAvatar(user.getAvatar());
                onlineSession.setDeptName(user.getDept().getDeptName());
                onlineSession.markAttributeChanged();
            }
        }

        return onlineSession.getStatus() != OnlineStatus.OFF_LINE;
    }
    return true;
}