Package org.apache.shiro.web.subject
Class WebSubject.Builder
java.lang.Object
org.apache.shiro.subject.Subject.Builder
org.apache.shiro.web.subject.WebSubject.Builder
- Enclosing interface:
WebSubject
A
WebSubject.Builder performs the same function as a Subject.Builder, but
additionally ensures that the Servlet request/response pair that is triggering the Subject instance's creation
is retained for use by internal Shiro components as necessary.-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) Constructs a newWeb.Builderinstance using theSecurityManagerobtained by callingSecurityUtils.getSecurityManager().Builder(org.apache.shiro.mgt.SecurityManager securityManager, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) Constructs a newWeb.Builderinstance using the specifiedSecurityManagerinstance to create theWebSubjectinstance. -
Method Summary
Modifier and TypeMethodDescriptionReturnssuper.buildSubject(), but additionally ensures that the returned instance is aninstanceofWebSubjectand to support a type-safe method so a caller does not have to cast.protected org.apache.shiro.subject.SubjectContextOverrides the parent implementation to return a new instance of aDefaultWebSubjectContextto account for the additional request/response pair.protected WebSubject.BuildersetRequest(javax.servlet.ServletRequest request) Called by theWebSubject.Builderconstructor, this method places the request object in the context map for later retrieval.protected WebSubject.BuildersetResponse(javax.servlet.ServletResponse response) Called by theWebSubject.Builderconstructor, this method places the response object in the context map for later retrieval.Methods inherited from class org.apache.shiro.subject.Subject.Builder
authenticated, buildSubject, contextAttribute, getSubjectContext, host, principals, session, sessionCreationEnabled, sessionId
-
Constructor Details
-
Builder
Constructs a newWeb.Builderinstance using theSecurityManagerobtained by callingSecurityUtils.getSecurityManager(). If you want to specify your own SecurityManager instance, use theBuilder(SecurityManager, ServletRequest, ServletResponse)constructor instead.- Parameters:
request- the incoming ServletRequest that will be associated with the builtWebSubjectinstance.response- the outgoing ServletRequest paired with the ServletRequest that will be associated with the builtWebSubjectinstance.
-
Builder
public Builder(org.apache.shiro.mgt.SecurityManager securityManager, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) Constructs a newWeb.Builderinstance using the specifiedSecurityManagerinstance to create theWebSubjectinstance.- Parameters:
securityManager- theSecurityManager SecurityManagerinstance to use to build theWebSubjectinstance.request- the incoming ServletRequest that will be associated with the builtWebSubjectinstance.response- the outgoing ServletRequest paired with the ServletRequest that will be associated with the builtWebSubjectinstance.
-
-
Method Details
-
newSubjectContextInstance
Overrides the parent implementation to return a new instance of aDefaultWebSubjectContextto account for the additional request/response pair.- Overrides:
newSubjectContextInstancein classorg.apache.shiro.subject.Subject.Builder- Returns:
- a new instance of a
DefaultWebSubjectContextto account for the additional request/response pair.
-
setRequest
Called by theWebSubject.Builderconstructor, this method places the request object in the context map for later retrieval.- Parameters:
request- the incoming ServletRequest that triggered the creation of theWebSubjectinstance.- Returns:
- 'this' for method chaining.
-
setResponse
Called by theWebSubject.Builderconstructor, this method places the response object in the context map for later retrieval.- Parameters:
response- the outgoing ServletRequest paired with the ServletRequest that triggered the creation of theWebSubjectinstance.- Returns:
- 'this' for method chaining.
-
buildWebSubject
Returnssuper.buildSubject(), but additionally ensures that the returned instance is aninstanceofWebSubjectand to support a type-safe method so a caller does not have to cast. Per the parent class's method JavaDoc, this method will return a new instance each time it is called.- Returns:
- a new
WebSubjectinstance built by thisBuilder.
-