| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (version 1.7.0_21) on Thu May 30 14:51:27 PDT 2013 --> |
| <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> |
| <title>Subject.Builder (Apache Shiro 1.2.1 API)</title> |
| <meta name="date" content="2013-05-30"> |
| <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="Subject.Builder (Apache Shiro 1.2.1 API)"; |
| } |
| //--> |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar_top"> |
| <!-- --> |
| </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/Subject.Builder.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><span class="strong">Prev Class</span></a></li> |
| <li><a href="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject"><span class="strong">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?org/apache/shiro/subject/Subject.Builder.html" target="_top">Frames</a></li> |
| <li><a href="Subject.Builder.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor_summary">Constr</a> | </li> |
| <li><a href="#method_summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor_detail">Constr</a> | </li> |
| <li><a href="#method_detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip-navbar_top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle">org.apache.shiro.subject</div> |
| <h2 title="Class Subject.Builder" class="title">Class Subject.Builder</h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.shiro.subject.Subject.Builder</li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <dl> |
| <dt>Direct Known Subclasses:</dt> |
| <dd><a href="../../../../org/apache/shiro/web/subject/WebSubject.Builder.html" title="class in org.apache.shiro.web.subject">WebSubject.Builder</a></dd> |
| </dl> |
| <dl> |
| <dt>Enclosing interface:</dt> |
| <dd><a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</a></dd> |
| </dl> |
| <hr> |
| <br> |
| <pre>public static class <a href="../../../../src-html/org/apache/shiro/subject/Subject.html#line.608">Subject.Builder</a> |
| extends <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre> |
| <div class="block">Builder design pattern implementation for creating <a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><code>Subject</code></a> instances in a simplified way without |
| requiring knowledge of Shiro's construction techniques. |
| <p/> |
| <b>NOTE</b>: This is provided for framework development support only and should typically never be used by |
| application developers. <code>Subject</code> instances should generally be acquired by using |
| <code>SecurityUtils.<a href="../../../../org/apache/shiro/SecurityUtils.html#getSubject()"><code>getSubject()</code></a></code> |
| <h4>Usage</h4> |
| The simplest usage of this builder is to construct an anonymous, session-less <code>Subject</code> instance: |
| <pre> |
| Subject subject = new Subject.<code>Builder</code>().<a href="../../../../org/apache/shiro/subject/Subject.Builder.html#buildSubject()"><code>buildSubject()</code></a>;</pre> |
| The default, no-arg <code>Subject.Builder()</code> constructor shown above will use the application's |
| currently accessible <code>SecurityManager</code> via |
| <code>SecurityUtils.<a href="../../../../org/apache/shiro/SecurityUtils.html#getSecurityManager()"><code>getSecurityManager()</code></a></code>. You may also |
| specify the exact <code>SecurityManager</code> instance to be used by the additional |
| <code>Subject.<code>Builder(securityManager)</code></code> |
| constructor if desired. |
| <p/> |
| All other methods may be called before the <a href="../../../../org/apache/shiro/subject/Subject.Builder.html#buildSubject()"><code>buildSubject()</code></a> method to |
| provide context on how to construct the <code>Subject</code> instance. For example, if you have a session id and |
| want to acquire the <code>Subject</code> that 'owns' that session (assuming the session exists and is not expired): |
| <pre> |
| Subject subject = new Subject.Builder().sessionId(sessionId).buildSubject();</pre> |
| <p/> |
| Similarly, if you want a <code>Subject</code> instance reflecting a certain identity: |
| <pre> |
| PrincipalCollection principals = new SimplePrincipalCollection("username", <em>yourRealmName</em>); |
| Subject subject = new Subject.Builder().principals(principals).build();</pre> |
| <p/> |
| <b>Note*</b> that the returned <code>Subject</code> instance is <b>not</b> automatically bound to the application (thread) |
| for further use. That is, |
| <a href="../../../../org/apache/shiro/SecurityUtils.html" title="class in org.apache.shiro"><code>SecurityUtils</code></a>.<a href="../../../../org/apache/shiro/SecurityUtils.html#getSubject()"><code>getSubject()</code></a> |
| will not automatically return the same instance as what is returned by the builder. It is up to the framework |
| developer to bind the built <code>Subject</code> for continued use if desired.</div> |
| <dl><dt><span class="strong">Since:</span></dt> |
| <dd>1.0</dd></dl> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor_summary"> |
| <!-- --> |
| </a> |
| <h3>Constructor Summary</h3> |
| <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> |
| <caption><span>Constructors</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colOne" scope="col">Constructor and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colOne"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#Subject.Builder()">Subject.Builder</a></strong>()</code> |
| <div class="block">Constructs a new <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject"><code>Subject.Builder</code></a> instance, using the <code>SecurityManager</code> instance available |
| to the calling code as determined by a call to <a href="../../../../org/apache/shiro/SecurityUtils.html#getSecurityManager()"><code>SecurityUtils.getSecurityManager()</code></a> |
| to build the <code>Subject</code> instance.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colOne"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#Subject.Builder(org.apache.shiro.mgt.SecurityManager)">Subject.Builder</a></strong>(<a href="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</a> securityManager)</code> |
| <div class="block">Constructs a new <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject"><code>Subject.Builder</code></a> instance which will use the specified <code>SecurityManager</code> when |
| building the <code>Subject</code> instance.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method_summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span>Methods</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Method and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#authenticated(boolean)">authenticated</a></strong>(boolean authenticated)</code> |
| <div class="block">Ensures the <code>Subject</code> being built will be considered |
| <a href="../../../../org/apache/shiro/subject/Subject.html#isAuthenticated()"><code>authenticated</code></a>.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#buildSubject()">buildSubject</a></strong>()</code> |
| <div class="block">Creates and returns a new <code>Subject</code> instance reflecting the cumulative state acquired by the |
| other methods in this class.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#contextAttribute(java.lang.String, java.lang.Object)">contextAttribute</a></strong>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> attributeKey, |
| <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a> attributeValue)</code> |
| <div class="block">Allows custom attributes to be added to the underlying context <code>Map</code> used to construct the |
| <a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><code>Subject</code></a> instance.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>protected <a href="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject">SubjectContext</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#getSubjectContext()">getSubjectContext</a></strong>()</code> |
| <div class="block">Returns the backing context used to build the <code>Subject</code> instance, available to subclasses |
| since the <code>context</code> class attribute is marked as <code>private</code>.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#host(java.lang.String)">host</a></strong>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> host)</code> |
| <div class="block">Ensures the <code>Subject</code> being built will reflect the specified host name or IP as its originating |
| location.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>protected <a href="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject">SubjectContext</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#newSubjectContextInstance()">newSubjectContextInstance</a></strong>()</code> |
| <div class="block">Creates a new <code>SubjectContext</code> instance to be used to populate with subject contextual data that |
| will then be sent to the <code>SecurityManager</code> to create a new <code>Subject</code> instance.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#principals(org.apache.shiro.subject.PrincipalCollection)">principals</a></strong>(<a href="../../../../org/apache/shiro/subject/PrincipalCollection.html" title="interface in org.apache.shiro.subject">PrincipalCollection</a> principals)</code> |
| <div class="block">Ensures the <code>Subject</code> being built will reflect the specified principals (aka identity).</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#session(org.apache.shiro.session.Session)">session</a></strong>(<a href="../../../../org/apache/shiro/session/Session.html" title="interface in org.apache.shiro.session">Session</a> session)</code> |
| <div class="block">Ensures the <code>Subject</code> being built will use the specified <a href="../../../../org/apache/shiro/session/Session.html" title="interface in org.apache.shiro.session"><code>Session</code></a> instance.</div> |
| </td> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#sessionCreationEnabled(boolean)">sessionCreationEnabled</a></strong>(boolean enabled)</code> |
| <div class="block">Configures whether or not the created Subject instance can create a new <code>Session</code> if one does not |
| already exist.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a></code></td> |
| <td class="colLast"><code><strong><a href="../../../../org/apache/shiro/subject/Subject.Builder.html#sessionId(java.io.Serializable)">sessionId</a></strong>(<a href="http://java.sun.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a> sessionId)</code> |
| <div class="block">Enables building a <a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><code>Subject</code></a> instance that owns the <a href="../../../../org/apache/shiro/session/Session.html" title="interface in org.apache.shiro.session"><code>Session</code></a> with the |
| specified <code>sessionId</code>.</div> |
| </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods_inherited_from_class_java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3> |
| <code><a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</a></code></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor_detail"> |
| <!-- --> |
| </a> |
| <h3>Constructor Detail</h3> |
| <a name="Subject.Builder()"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>Subject.Builder</h4> |
| <pre>public <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.626">Subject.Builder</a>()</pre> |
| <div class="block">Constructs a new <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject"><code>Subject.Builder</code></a> instance, using the <code>SecurityManager</code> instance available |
| to the calling code as determined by a call to <a href="../../../../org/apache/shiro/SecurityUtils.html#getSecurityManager()"><code>SecurityUtils.getSecurityManager()</code></a> |
| to build the <code>Subject</code> instance.</div> |
| </li> |
| </ul> |
| <a name="Subject.Builder(org.apache.shiro.mgt.SecurityManager)"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>Subject.Builder</h4> |
| <pre>public <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.636">Subject.Builder</a>(<a href="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</a> securityManager)</pre> |
| <div class="block">Constructs a new <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject"><code>Subject.Builder</code></a> instance which will use the specified <code>SecurityManager</code> when |
| building the <code>Subject</code> instance.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>securityManager</code> - the <code>SecurityManager</code> to use when building the <code>Subject</code> instance.</dd></dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method_detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="newSubjectContextInstance()"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>newSubjectContextInstance</h4> |
| <pre>protected <a href="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject">SubjectContext</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.655">newSubjectContextInstance</a>()</pre> |
| <div class="block">Creates a new <code>SubjectContext</code> instance to be used to populate with subject contextual data that |
| will then be sent to the <code>SecurityManager</code> to create a new <code>Subject</code> instance.</div> |
| <dl><dt><span class="strong">Returns:</span></dt><dd>a new <code>SubjectContext</code> instance</dd></dl> |
| </li> |
| </ul> |
| <a name="getSubjectContext()"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getSubjectContext</h4> |
| <pre>protected <a href="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject">SubjectContext</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.665">getSubjectContext</a>()</pre> |
| <div class="block">Returns the backing context used to build the <code>Subject</code> instance, available to subclasses |
| since the <code>context</code> class attribute is marked as <code>private</code>.</div> |
| <dl><dt><span class="strong">Returns:</span></dt><dd>the backing context used to build the <code>Subject</code> instance, available to subclasses.</dd></dl> |
| </li> |
| </ul> |
| <a name="sessionId(java.io.Serializable)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>sessionId</h4> |
| <pre>public <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.696">sessionId</a>(<a href="http://java.sun.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a> sessionId)</pre> |
| <div class="block">Enables building a <a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><code>Subject</code></a> instance that owns the <a href="../../../../org/apache/shiro/session/Session.html" title="interface in org.apache.shiro.session"><code>Session</code></a> with the |
| specified <code>sessionId</code>. |
| <p/> |
| Usually when specifying a <code>sessionId</code>, no other <code>Builder</code> methods would be specified because |
| everything else (principals, inet address, etc) can usually be reconstructed based on the referenced |
| session alone. In other words, this is almost always sufficient: |
| <pre> |
| new Subject.Builder().sessionId(sessionId).buildSubject();</pre> |
| <p/> |
| <b>Although simple in concept, this method provides very powerful functionality previously absent in almost |
| all Java environments:</b> |
| <p/> |
| The ability to reference a <code>Subject</code> and their server-side session |
| <em>across clients of different mediums</em> such as web applications, Java applets, |
| standalone C# clients over XML-RPC and/or SOAP, and many others. This is a <em>huge</em> |
| benefit in heterogeneous enterprise applications. |
| <p/> |
| To maintain session integrity across client mediums, the <code>sessionId</code> <b>must</b> be transmitted |
| to all client mediums securely (e.g. over SSL) to prevent man-in-the-middle attacks. This |
| is nothing new - all web applications are susceptible to the same problem when transmitting |
| <code>Cookie</code>s or when using URL rewriting. As long as the |
| <code>sessionId</code> is transmitted securely, session integrity can be maintained.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>sessionId</code> - the id of the session that backs the desired Subject being acquired.</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>this <code>Builder</code> instance for method chaining.</dd></dl> |
| </li> |
| </ul> |
| <a name="host(java.lang.String)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>host</h4> |
| <pre>public <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.710">host</a>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> host)</pre> |
| <div class="block">Ensures the <code>Subject</code> being built will reflect the specified host name or IP as its originating |
| location.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>host</code> - the host name or IP address to use as the <code>Subject</code>'s originating location.</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>this <code>Builder</code> instance for method chaining.</dd></dl> |
| </li> |
| </ul> |
| <a name="session(org.apache.shiro.session.Session)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>session</h4> |
| <pre>public <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.725">session</a>(<a href="../../../../org/apache/shiro/session/Session.html" title="interface in org.apache.shiro.session">Session</a> session)</pre> |
| <div class="block">Ensures the <code>Subject</code> being built will use the specified <a href="../../../../org/apache/shiro/session/Session.html" title="interface in org.apache.shiro.session"><code>Session</code></a> instance. Note that it is |
| more common to use the <a href="../../../../org/apache/shiro/subject/Subject.Builder.html#sessionId(java.io.Serializable)"><code>sessionId</code></a> builder method rather than having to construct a |
| <code>Session</code> instance for this method.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>session</code> - the session to use as the <code>Subject</code>'s <a href="../../../../org/apache/shiro/session/Session.html" title="interface in org.apache.shiro.session"><code>Session</code></a></dd> |
| <dt><span class="strong">Returns:</span></dt><dd>this <code>Builder</code> instance for method chaining.</dd></dl> |
| </li> |
| </ul> |
| <a name="principals(org.apache.shiro.subject.PrincipalCollection)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>principals</h4> |
| <pre>public <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.756">principals</a>(<a href="../../../../org/apache/shiro/subject/PrincipalCollection.html" title="interface in org.apache.shiro.subject">PrincipalCollection</a> principals)</pre> |
| <div class="block">Ensures the <code>Subject</code> being built will reflect the specified principals (aka identity). |
| <p/> |
| For example, if your application's unique identifier for users is a <code>String</code> username, and you wanted |
| to create a <code>Subject</code> instance that reflected a user whose username is |
| '<code>jsmith</code>', and you knew the Realm that could acquire <code>jsmith</code>'s principals based on the username |
| was named "<code>myRealm</code>", you might create the '<code>jsmith</code> <code>Subject</code> instance this |
| way: |
| <pre> |
| PrincipalCollection identity = new <a href="../../../../org/apache/shiro/subject/SimplePrincipalCollection.html#SimplePrincipalCollection(java.lang.Object, java.lang.String)"><code>SimplePrincipalCollection</code></a>("jsmith", "myRealm"); |
| Subject jsmith = new Subject.Builder().principals(identity).buildSubject();</pre> |
| <p/> |
| Similarly, if your application's unique identifier for users is a <code>long</code> value (such as might be used |
| as a primary key in a relational database) and you were using a <code>JDBC</code> |
| <code>Realm</code> named, (unimaginatively) "jdbcRealm", you might create the Subject |
| instance this way: |
| <pre> |
| long userId = //get user ID from somewhere |
| PrincipalCollection userIdentity = new <a href="../../../../org/apache/shiro/subject/SimplePrincipalCollection.html#SimplePrincipalCollection(java.lang.Object, java.lang.String)"><code>SimplePrincipalCollection</code></a>(<em>userId</em>, "jdbcRealm"); |
| Subject user = new Subject.Builder().principals(identity).buildSubject();</pre></div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>principals</code> - the principals to use as the <code>Subject</code>'s identity.</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>this <code>Builder</code> instance for method chaining.</dd></dl> |
| </li> |
| </ul> |
| <a name="sessionCreationEnabled(boolean)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>sessionCreationEnabled</h4> |
| <pre>public <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.775">sessionCreationEnabled</a>(boolean enabled)</pre> |
| <div class="block">Configures whether or not the created Subject instance can create a new <code>Session</code> if one does not |
| already exist. If set to <code>false</code>, any application calls to |
| <code>subject.getSession()</code> or <code>subject.getSession(true))</code> will result in a SessionException. |
| <p/> |
| This setting is <code>true</code> by default, as most applications find value in sessions.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>enabled</code> - whether or not the created Subject instance can create a new <code>Session</code> if one does not |
| already exist.</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>this <code>Builder</code> instance for method chaining.</dd><dt><span class="strong">Since:</span></dt> |
| <dd>1.2</dd></dl> |
| </li> |
| </ul> |
| <a name="authenticated(boolean)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>authenticated</h4> |
| <pre>public <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.791">authenticated</a>(boolean authenticated)</pre> |
| <div class="block">Ensures the <code>Subject</code> being built will be considered |
| <a href="../../../../org/apache/shiro/subject/Subject.html#isAuthenticated()"><code>authenticated</code></a>. Per the |
| <a href="../../../../org/apache/shiro/subject/Subject.html#isAuthenticated()"><code>isAuthenticated()</code></a> JavaDoc, be careful |
| when specifying <code>true</code> - you should know what you are doing and have a good reason for ignoring Shiro's |
| default authentication state mechanisms.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>authenticated</code> - whether or not the built <code>Subject</code> will be considered authenticated.</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>this <code>Builder</code> instance for method chaining.</dd><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../org/apache/shiro/subject/Subject.html#isAuthenticated()"><code>Subject.isAuthenticated()</code></a></dd></dl> |
| </li> |
| </ul> |
| <a name="contextAttribute(java.lang.String, java.lang.Object)"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>contextAttribute</h4> |
| <pre>public <a href="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.814">contextAttribute</a>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> attributeKey, |
| <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a> attributeValue)</pre> |
| <div class="block">Allows custom attributes to be added to the underlying context <code>Map</code> used to construct the |
| <a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><code>Subject</code></a> instance. |
| <p/> |
| A <code>null</code> key throws an <a href="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang"><code>IllegalArgumentException</code></a>. A <code>null</code> value effectively removes |
| any previously stored attribute under the given key from the context map. |
| <p/> |
| <b>*NOTE*:</b> This method is only useful when configuring Shiro with a custom <a href="../../../../org/apache/shiro/mgt/SubjectFactory.html" title="interface in org.apache.shiro.mgt"><code>SubjectFactory</code></a> |
| implementation. This method allows end-users to append additional data to the context map which the |
| <code>SubjectFactory</code> implementation can use when building custom Subject instances. As such, this method |
| is only useful when a custom <code>SubjectFactory</code> implementation has been configured.</div> |
| <dl><dt><span class="strong">Parameters:</span></dt><dd><code>attributeKey</code> - the key under which the corresponding value will be stored in the context <code>Map</code>.</dd><dd><code>attributeValue</code> - the value to store in the context map under the specified <code>attributeKey</code>.</dd> |
| <dt><span class="strong">Returns:</span></dt><dd>this <code>Builder</code> instance for method chaining.</dd> |
| <dt><span class="strong">Throws:</span></dt> |
| <dd><code><a href="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the <code>attributeKey</code> is <code>null</code>.</dd><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../org/apache/shiro/mgt/SubjectFactory.html#createSubject(org.apache.shiro.subject.SubjectContext)"><code>SubjectFactory.createSubject(SubjectContext)</code></a></dd></dl> |
| </li> |
| </ul> |
| <a name="buildSubject()"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>buildSubject</h4> |
| <pre>public <a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</a> <a href="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.845">buildSubject</a>()</pre> |
| <div class="block">Creates and returns a new <code>Subject</code> instance reflecting the cumulative state acquired by the |
| other methods in this class. |
| <p/> |
| This <code>Builder</code> instance will still retain the underlying state after this method is called - it |
| will not clear it; repeated calls to this method will return multiple <a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><code>Subject</code></a> instances, all |
| reflecting the exact same state. If a new (different) <code>Subject</code> is to be constructed, a new |
| <code>Builder</code> instance must be created. |
| <p/> |
| <b>Note</b> that the returned <code>Subject</code> instance is <b>not</b> automatically bound to the application |
| (thread) for further use. That is, |
| <a href="../../../../org/apache/shiro/SecurityUtils.html" title="class in org.apache.shiro"><code>SecurityUtils</code></a>.<a href="../../../../org/apache/shiro/SecurityUtils.html#getSubject()"><code>getSubject()</code></a> |
| will not automatically return the same instance as what is returned by the builder. It is up to the |
| framework developer to bind the returned <code>Subject</code> for continued use if desired.</div> |
| <dl><dt><span class="strong">Returns:</span></dt><dd>a new <code>Subject</code> instance reflecting the cumulative state acquired by the |
| other methods in this class.</dd></dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar_bottom"> |
| <!-- --> |
| </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/Subject.Builder.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><span class="strong">Prev Class</span></a></li> |
| <li><a href="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject"><span class="strong">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?org/apache/shiro/subject/Subject.Builder.html" target="_top">Frames</a></li> |
| <li><a href="Subject.Builder.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor_summary">Constr</a> | </li> |
| <li><a href="#method_summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor_detail">Constr</a> | </li> |
| <li><a href="#method_detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip-navbar_bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| <p class="legalCopy"><small>Copyright © 2004-2013 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.</small></p> |
| </body> |
| </html> |
| |