/** * Actually creates a {@code Subject} instance by delegating to the internal * {@link #getSubjectFactory() subjectFactory}. By the time this method is invoked, all possible * {@code SubjectContext} data (session, principals, et. al.) has been made accessible using all known heuristics * and will be accessible to the {@code subjectFactory} via the {@code subjectContext.resolve*} methods. * * @param context the populated context (data map) to be used by the {@code SubjectFactory} when creating a * {@code Subject} instance. * @return a {@code Subject} instance reflecting the data in the specified {@code SubjectContext} data map. * @see #getSubjectFactory() * @see SubjectFactory#createSubject(org.apache.shiro.subject.SubjectContext) * @since 1.2 */ protected Subject doCreateSubject(SubjectContext context) { return getSubjectFactory().createSubject(context); }
/** * Actually creates a {@code Subject} instance by delegating to the internal * {@link #getSubjectFactory() subjectFactory}. By the time this method is invoked, all possible * {@code SubjectContext} data (session, principals, et. al.) has been made accessible using all known heuristics * and will be accessible to the {@code subjectFactory} via the {@code subjectContext.resolve*} methods. * * @param context the populated context (data map) to be used by the {@code SubjectFactory} when creating a * {@code Subject} instance. * @return a {@code Subject} instance reflecting the data in the specified {@code SubjectContext} data map. * @see #getSubjectFactory() * @see SubjectFactory#createSubject(org.apache.shiro.subject.SubjectContext) * @since 1.2 */ protected Subject doCreateSubject(SubjectContext context) { return getSubjectFactory().createSubject(context); }
protected Subject doCreateSubject(SubjectContext context) { PrincipalCollection principals = context.resolvePrincipals(); UserPrincipal userPrincipal = getUserPrincipal(principals); Subject result; if (userPrincipal == null) { result = getSubjectFactory().createSubject(context); } else { // TODO the different realm names isn't solved yet :) if (principals instanceof MutablePrincipalCollection && ssoPrincipalProvider != null) { ((MutablePrincipalCollection) principals).add(ssoPrincipalProvider.createSSOPrincipal(userPrincipal), DEFAULT_REALM); } if (userPrincipal.needsTwoStepAuthentication()) { result = twoStepSubjectFactory.createSubject(context); } else { result = getSubjectFactory().createSubject(context); } } return result; }
/** * This implementation attempts to resolve any session ID that may exist in the context by * passing it to the {@link #resolveSession(SubjectContext)} method. The * return value from that call is then used to attempt to resolve the subject identity via the * {@link #resolvePrincipals(SubjectContext)} method. The return value from that call is then used to create * the {@code Subject} instance by calling * <code>{@link #getSubjectFactory() getSubjectFactory()}.{@link SubjectFactory#createSubject createSubject}(resolvedContext);</code> * * @param subjectContext any data needed to direct how the Subject should be constructed. * @return the {@code Subject} instance reflecting the specified initialization data. * @see SubjectFactory#createSubject * @since 1.0 */ public Subject createSubject(SubjectContext subjectContext) { //create a copy so we don't modify the argument's backing map: SubjectContext context = copy(subjectContext); //ensure that the context has a SecurityManager instance, and if not, add one: context = ensureSecurityManager(context); //Resolve an associated Session (usually based on a referenced session ID), and place it in the context before //sending to the SubjectFactory. The SubjectFactory should not need to know how to acquire sessions as the //process is often environment specific - better to shield the SF from these details: context = resolveSession(context); //Similarly, the SubjectFactory should not require any concept of RememberMe - translate that here first //if possible before handing off to the SubjectFactory: context = resolvePrincipals(context); return getSubjectFactory().createSubject(context); }