protected SessionKey getSessionKey(SubjectContext context) {
        Serializable sessionId = context.getSessionId();
        if (sessionId != null) {
            return new DefaultSessionKey(sessionId);
        }
        return null;
    }
Attempts to resolve any associated session based on the context and returns a
context that represents this resolved {@code Session} to ensure it may be referenced if necessary by the
invoked {@link SubjectFactory} that performs actual {@link Subject} construction.
<p/>
If there is a {@code Session} already in the context because that is what the caller wants to be used for
{@code Subject} construction, or if no session is resolved, this method effectively does nothing
returns the context method argument unaltered.

@param context the subject context data that may resolve a Session instance.
@return The context to use to pass to a {@link SubjectFactory} for subject creation.
@since 1.0
core/src/main/java/org/apache/shiro/mgt/DefaultSecurityManager.java