blob: abc97bf289155efc8df5c9fa0ef2c62b785285db [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Tue Feb 25 18:15:51 EST 2014 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
Subject.Builder (Apache Shiro 1.2.3 API)
</TITLE>
<META NAME="date" CONTENT="2014-02-25">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Subject.Builder (Apache Shiro 1.2.3 API)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Subject.Builder.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/apache/shiro/subject/Subject.Builder.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="Subject.Builder.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.shiro.subject</FONT>
<BR>
Class Subject.Builder</H2>
<PRE>
<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>
<IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.shiro.subject.Subject.Builder</B>
</PRE>
<DL>
<DT><B>Direct Known Subclasses:</B> <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><B>Enclosing interface:</B><DD><A HREF="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</A></DD>
</DL>
<HR>
<DL>
<DT><PRE>public static class <A HREF="../../../../src-html/org/apache/shiro/subject/Subject.html#line.608"><B>Subject.Builder</B></A><DT>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></DL>
</PRE>
<P>
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.
<P>
<P>
<DL>
<DT><B>Since:</B></DT>
<DD>1.0</DD>
</DL>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#Subject.Builder()">Subject.Builder</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#Subject.Builder(org.apache.shiro.mgt.SecurityManager)">Subject.Builder</A></B>(<A HREF="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</A>&nbsp;securityManager)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#authenticated(boolean)">authenticated</A></B>(boolean&nbsp;authenticated)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ensures the <code>Subject</code> being built will be considered
<A HREF="../../../../org/apache/shiro/subject/Subject.html#isAuthenticated()"><CODE>authenticated</CODE></A>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject">Subject</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#buildSubject()">buildSubject</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates and returns a new <code>Subject</code> instance reflecting the cumulative state acquired by the
other methods in this class.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#contextAttribute(java.lang.String, java.lang.Object)">contextAttribute</A></B>(<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>&nbsp;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>&nbsp;attributeValue)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject">SubjectContext</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#getSubjectContext()">getSubjectContext</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#host(java.lang.String)">host</A></B>(<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>&nbsp;host)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ensures the <code>Subject</code> being built will reflect the specified host name or IP as its originating
location.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;<A HREF="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject">SubjectContext</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#newSubjectContextInstance()">newSubjectContextInstance</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#principals(org.apache.shiro.subject.PrincipalCollection)">principals</A></B>(<A HREF="../../../../org/apache/shiro/subject/PrincipalCollection.html" title="interface in org.apache.shiro.subject">PrincipalCollection</A>&nbsp;principals)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ensures the <code>Subject</code> being built will reflect the specified principals (aka identity).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#session(org.apache.shiro.session.Session)">session</A></B>(<A HREF="../../../../org/apache/shiro/session/Session.html" title="interface in org.apache.shiro.session">Session</A>&nbsp;session)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#sessionCreationEnabled(boolean)">sessionCreationEnabled</A></B>(boolean&nbsp;enabled)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Configures whether or not the created Subject instance can create a new <code>Session</code> if one does not
already exist.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html" title="class in org.apache.shiro.subject">Subject.Builder</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/subject/Subject.Builder.html#sessionId(java.io.Serializable)">sessionId</A></B>(<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>&nbsp;sessionId)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>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></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><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></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="Subject.Builder()"><!-- --></A><H3>
Subject.Builder</H3>
<PRE>
public <A HREF="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.626"><B>Subject.Builder</B></A>()</PRE>
<DL>
<DD>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.
<P>
</DL>
<HR>
<A NAME="Subject.Builder(org.apache.shiro.mgt.SecurityManager)"><!-- --></A><H3>
Subject.Builder</H3>
<PRE>
public <A HREF="../../../../src-html/org/apache/shiro/subject/Subject.Builder.html#line.636"><B>Subject.Builder</B></A>(<A HREF="../../../../org/apache/shiro/mgt/SecurityManager.html" title="interface in org.apache.shiro.mgt">SecurityManager</A>&nbsp;securityManager)</PRE>
<DL>
<DD>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.
<P>
<DL>
<DT><B>Parameters:</B><DD><CODE>securityManager</CODE> - the <code>SecurityManager</code> to use when building the <code>Subject</code> instance.</DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="newSubjectContextInstance()"><!-- --></A><H3>
newSubjectContextInstance</H3>
<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"><B>newSubjectContextInstance</B></A>()</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a new <code>SubjectContext</code> instance</DL>
</DD>
</DL>
<HR>
<A NAME="getSubjectContext()"><!-- --></A><H3>
getSubjectContext</H3>
<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"><B>getSubjectContext</B></A>()</PRE>
<DL>
<DD>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>.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the backing context used to build the <code>Subject</code> instance, available to subclasses.</DL>
</DD>
</DL>
<HR>
<A NAME="sessionId(java.io.Serializable)"><!-- --></A><H3>
sessionId</H3>
<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"><B>sessionId</B></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>&nbsp;sessionId)</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>sessionId</CODE> - the id of the session that backs the desired Subject being acquired.
<DT><B>Returns:</B><DD>this <code>Builder</code> instance for method chaining.</DL>
</DD>
</DL>
<HR>
<A NAME="host(java.lang.String)"><!-- --></A><H3>
host</H3>
<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"><B>host</B></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>&nbsp;host)</PRE>
<DL>
<DD>Ensures the <code>Subject</code> being built will reflect the specified host name or IP as its originating
location.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>host</CODE> - the host name or IP address to use as the <code>Subject</code>'s originating location.
<DT><B>Returns:</B><DD>this <code>Builder</code> instance for method chaining.</DL>
</DD>
</DL>
<HR>
<A NAME="session(org.apache.shiro.session.Session)"><!-- --></A><H3>
session</H3>
<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"><B>session</B></A>(<A HREF="../../../../org/apache/shiro/session/Session.html" title="interface in org.apache.shiro.session">Session</A>&nbsp;session)</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
<DT><B>Parameters:</B><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>
<DT><B>Returns:</B><DD>this <code>Builder</code> instance for method chaining.</DL>
</DD>
</DL>
<HR>
<A NAME="principals(org.apache.shiro.subject.PrincipalCollection)"><!-- --></A><H3>
principals</H3>
<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"><B>principals</B></A>(<A HREF="../../../../org/apache/shiro/subject/PrincipalCollection.html" title="interface in org.apache.shiro.subject">PrincipalCollection</A>&nbsp;principals)</PRE>
<DL>
<DD>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 &quot;<code>myRealm</code>&quot;, 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>(&quot;jsmith&quot;, &quot;myRealm&quot;);
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) &quot;jdbcRealm&quot;, 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>, &quot;jdbcRealm&quot;);
Subject user = new Subject.Builder().principals(identity).buildSubject();</pre>
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>principals</CODE> - the principals to use as the <code>Subject</code>'s identity.
<DT><B>Returns:</B><DD>this <code>Builder</code> instance for method chaining.</DL>
</DD>
</DL>
<HR>
<A NAME="sessionCreationEnabled(boolean)"><!-- --></A><H3>
sessionCreationEnabled</H3>
<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"><B>sessionCreationEnabled</B></A>(boolean&nbsp;enabled)</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>enabled</CODE> - whether or not the created Subject instance can create a new <code>Session</code> if one does not
already exist.
<DT><B>Returns:</B><DD>this <code>Builder</code> instance for method chaining.<DT><B>Since:</B></DT>
<DD>1.2</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="authenticated(boolean)"><!-- --></A><H3>
authenticated</H3>
<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"><B>authenticated</B></A>(boolean&nbsp;authenticated)</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>authenticated</CODE> - whether or not the built <code>Subject</code> will be considered authenticated.
<DT><B>Returns:</B><DD>this <code>Builder</code> instance for method chaining.<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/shiro/subject/Subject.html#isAuthenticated()"><CODE>Subject.isAuthenticated()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="contextAttribute(java.lang.String, java.lang.Object)"><!-- --></A><H3>
contextAttribute</H3>
<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"><B>contextAttribute</B></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>&nbsp;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>&nbsp;attributeValue)</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>attributeKey</CODE> - the key under which the corresponding value will be stored in the context <code>Map</code>.<DD><CODE>attributeValue</CODE> - the value to store in the context map under the specified <code>attributeKey</code>.
<DT><B>Returns:</B><DD>this <code>Builder</code> instance for method chaining.
<DT><B>Throws:</B>
<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>.<DT><B>See Also:</B><DD><A HREF="../../../../org/apache/shiro/mgt/SubjectFactory.html#createSubject(org.apache.shiro.subject.SubjectContext)"><CODE>SubjectFactory.createSubject(SubjectContext)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="buildSubject()"><!-- --></A><H3>
buildSubject</H3>
<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"><B>buildSubject</B></A>()</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>a new <code>Subject</code> instance reflecting the cumulative state acquired by the
other methods in this class.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Subject.Builder.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../org/apache/shiro/subject/Subject.html" title="interface in org.apache.shiro.subject"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../org/apache/shiro/subject/SubjectContext.html" title="interface in org.apache.shiro.subject"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/apache/shiro/subject/Subject.Builder.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="Subject.Builder.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
Copyright &#169; 2004-2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.
</BODY>
</HTML>