Example usage for org.apache.shiro.session.mgt SessionKey getSessionId

List of usage examples for org.apache.shiro.session.mgt SessionKey getSessionId

Introduction

In this page you can find the example usage for org.apache.shiro.session.mgt SessionKey getSessionId.

Prototype

Serializable getSessionId();

Source Link

Document

Returns the id of the session to acquire.

Usage

From source file:br.com.criativasoft.opendevice.wsrest.RestWebSecurityManager.java

License:Open Source License

@Override
protected Session resolveContextSession(SubjectContext context) throws InvalidSessionException {
    SessionKey key = getSessionKey(context);
    if (key != null && key.getSessionId() != null) { // FIXED: check internal sessionID
        try {/*from  w  w w . j a  va 2  s  .  co m*/
            return getSession(key);
        } catch (UnknownSessionException ex) {
            log.info(ex.getMessage());
        }

    }
    return null;
}

From source file:org.ow2.proactive.workflowcatalog.security.HttpHeaderTokenSessionManager.java

License:Open Source License

@Override
public Serializable getSessionId(SessionKey sessionKey) {
    ServletRequest request = WebUtils.getRequest(sessionKey);
    if (request instanceof HttpServletRequest) {
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        String tokenKeyHeader = httpRequest.getHeader(TOKEN_KEY);
        if (tokenKeyHeader == null) {
            return sessionKey.getSessionId();
        }//from  w  w  w .ja v  a 2 s .c  o  m
        return tokenKeyHeader;
    } else {
        return sessionKey.getSessionId();
    }
}

From source file:uk.q3c.krail.core.shiro.VaadinSessionManager.java

License:Apache License

@Override
public Session getSession(SessionKey key) throws SessionException {

    // Retrieve the VaadinSession for the current user.
    VaadinSession vaadinSession = sessionProvider.get();

    String attributeName = SESSION_ATTRIBUTE_PREFIX + key.getSessionId();

    if (vaadinSession != null) {
        // If we have a valid VaadinSession, try to get the Shiro Session.
        SimpleSession shiroSession = (SimpleSession) vaadinSession.getAttribute(attributeName);

        if (shiroSession != null) {

            // Make sure the Shiro Session hasn't been stopped or expired (i.e. the
            // user logged out).
            if (shiroSession.isValid()) {
                return shiroSession;
            } else {
                // This is an invalid or expired session so we'll clean it up.
                vaadinSession.setAttribute(attributeName, null);
            }//from   w  w w . j a v a 2 s  .c o m
        }
    }

    return null;
}