Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,9 @@ public Subject createSubject(SubjectContext subjectContext) {
//(this is needed here in case rememberMe principals were resolved and they need to be stored in the
//session, so we don't constantly rehydrate the rememberMe PrincipalCollection on every operation).
//Added in 1.2:
save(subject);
if (subjectContext.isSessionCreationEnabled()) {
save(subject);
}

return subject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.shiro.session.ExpiredSessionException;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.AbstractValidatingSessionManager;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.subject.support.DelegatingSubject;
import org.apache.shiro.util.ThreadContext;
Expand Down Expand Up @@ -187,4 +188,12 @@ void testNewSubjectWithoutThreadSecurityManager() {
subject.login(token);
assertEquals(sm, subject.getSecurityManager());
}

@Test
void testNewSubjectWithoutSessionCreationEnabled() {
SimplePrincipalCollection principals = new SimplePrincipalCollection("guest", "asd");
Subject subject = new Subject.Builder().principals(principals).sessionCreationEnabled(false).buildSubject();

assertEquals(subject.getPrincipal(), "guest");
}
}