logincontext.html

来自「SUN公司官方J2EE中文帮助文档 应该不错 有兴趣的下来看看 html格式的」· HTML 代码 · 共 613 行 · 第 1/2 页

HTML
613
字号
		does not appear in the <code>Configuration</code>
		and there is no <code>Configuration</code> entry
		for "<i>other</i>".</DL>
</DD>
</DL>
<HR>

<A NAME="LoginContext(java.lang.String, javax.security.auth.Subject)"><!-- --></A><H3>
LoginContext</H3>
<PRE>
public <B>LoginContext</B>(java.lang.String&nbsp;name,
                    <A HREF="../../../../javax/security/auth/Subject.html">Subject</A>&nbsp;subject)
             throws <A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></PRE>
<DL>
<DD>Constructor for the <code>LoginContext</code> class.

 <p> Initialize the new <code>LoginContext</code> object with a name
 and a <code>Subject</code> object.

 <p> <code>LoginContext</code> uses the name as the index
 into the <code>Configuration</code> to determine which LoginModules
 should be used.  If the provided name does not match any in the
 <code>Configuration</code>, then the <code>LoginContext</code>
 uses the default <code>Configuration</code> entry, "<i>other</i>".
 If there is no <code>Configuration</code> entry for "<i>other</i>",
 then a <code>LoginException</code> is thrown.

 <p> This constructor does not allow for a
 <code>CallbackHandler</code>.  Therefore the underlying LoginModules
 will not have a <code>CallbackHandler</code> for use in communicating
 with users.  The caller thus assumes that the configured
 LoginModules have alternative means for authenticating the user.

 <p> <code>LoginContext</code> passes the <code>Subject</code>
 object to configured LoginModules so they may perform additional
 authentication and update the <code>Subject</code> with new
 Principals and Credentials.

 <p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - the name used as the index into the
		<code>Configuration</code>. <p><DD><CODE>subject</CODE> - the <code>Subject</code> to authenticate.<DT><B>Throws:</B><DD><CODE><A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></CODE> - if the specified <code>name</code>
		does not appear in the <code>Configuration</code>
          and there is no <code>Configuration</code> entry
          for "<i>other</i>", or if the specified <code>subject</code>
		is <code>null</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="LoginContext(java.lang.String, javax.security.auth.callback.CallbackHandler)"><!-- --></A><H3>
LoginContext</H3>
<PRE>
public <B>LoginContext</B>(java.lang.String&nbsp;name,
                    <A HREF="../../../../javax/security/auth/callback/CallbackHandler.html">CallbackHandler</A>&nbsp;callbackHandler)
             throws <A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></PRE>
<DL>
<DD>Constructor for the <code>LoginContext</code> class.

 <p> Initialize the new <code>LoginContext</code> object with a name
 and a <code>CallbackHandler</code> object.

 <p> <code>LoginContext</code> uses the name as the index
 into the <code>Configuration</code> to determine which LoginModules
 should be used.  If the provided name does not match any in the
 <code>Configuration</code>, then the <code>LoginContext</code>
 uses the default <code>Configuration</code> entry, "<i>other</i>".
 If there is no <code>Configuration</code> entry for "<i>other</i>",
 then a <code>LoginException</code> is thrown.

 <p> <code>LoginContext</code> passes the <code>CallbackHandler</code>
 object to configured LoginModules so they may communicate with the user.
 The <code>CallbackHandler</code> object therefore allows LoginModules to
 remain independent of the different ways applications interact with
 users.  This <code>LoginContext</code> must wrap the
 application-provided <code>CallbackHandler</code> in a new
 <code>CallbackHandler</code> implementation, whose <code>handle</code>
 method implementation invokes the application-provided
 CallbackHandler's <code>handle</code> method in a
 <code>java.security.AccessController.doPrivileged</code> call
 constrained by the caller's current <code>AccessControlContext</code>.

 <p> Since no <code>Subject</code> can be specified to this constructor,
 it instantiates a <code>Subject</code> itself.

 <p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - the name used as the index into the
		<code>Configuration</code>. <p><DD><CODE>callbackHandler</CODE> - the <code>CallbackHandler</code> object used by
		LoginModules to communicate with the user.<DT><B>Throws:</B><DD><CODE><A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></CODE> - if the specified <code>name</code>
          does not appear in the <code>Configuration</code>
          and there is no <code>Configuration</code> entry
          for "<i>other</i>", or if the specified
		<code>callbackHandler</code> is <code>null</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="LoginContext(java.lang.String, javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler)"><!-- --></A><H3>
LoginContext</H3>
<PRE>
public <B>LoginContext</B>(java.lang.String&nbsp;name,
                    <A HREF="../../../../javax/security/auth/Subject.html">Subject</A>&nbsp;subject,
                    <A HREF="../../../../javax/security/auth/callback/CallbackHandler.html">CallbackHandler</A>&nbsp;callbackHandler)
             throws <A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></PRE>
<DL>
<DD>Constructor for the <code>LoginContext</code> class.

 <p> Initialize the new <code>LoginContext</code> object with a name,
 a <code>Subject</code> to be authenticated, and a
 <code>CallbackHandler</code> object.

 <p> <code>LoginContext</code> uses the name as the index
 into the <code>Configuration</code> to determine which LoginModules
 should be used.  If the provided name does not match any in the
 <code>Configuration</code>, then the <code>LoginContext</code>
 uses the default <code>Configuration</code> entry, "<i>other</i>".
 If there is no <code>Configuration</code> entry for "<i>other</i>",
 then a <code>LoginException</code> is thrown.

 <p> <code>LoginContext</code> passes the <code>Subject</code>
 object to configured LoginModules so they may perform additional
 authentication and update the <code>Subject</code> with new
 Principals and Credentials.

 <p> <code>LoginContext</code> passes the <code>CallbackHandler</code>
 object to configured LoginModules so they may communicate with the user.
 The <code>CallbackHandler</code> object therefore allows LoginModules to
 remain independent of the different ways applications interact with
 users.  This <code>LoginContext</code> must wrap the
 application-provided <code>CallbackHandler</code> in a new
 <code>CallbackHandler</code> implementation, whose <code>handle</code>
 method implementation invokes the application-provided
 CallbackHandler's <code>handle</code> method in a
 <code>java.security.AccessController.doPrivileged</code> call
 constrained by the caller's current <code>AccessControlContext</code>.


 <p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>name</CODE> - the name used as the index into the
		<code>Configuration</code>. <p><DD><CODE>subject</CODE> - the <code>Subject</code> to authenticate. <p><DD><CODE>callbackHandler</CODE> - the <code>CallbackHandler</code> object used by
		LoginModules to communicate with the user.<DT><B>Throws:</B><DD><CODE><A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></CODE> - if the specified <code>name</code>
          does not appear in the <code>Configuration</code>
          and there is no <code>Configuration</code> entry
          for "<i>other</i>", or if the specified <code>subject</code>
          is <code>null</code>, or if the specified
		<code>callbackHandler</code> is <code>null</code>.</DL>
</DD>
</DL>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>

<A NAME="login()"><!-- --></A><H3>
login</H3>
<PRE>
public void <B>login</B>()
           throws <A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></PRE>
<DL>
<DD>Perform the authentication and, if successful,
 associate Principals and Credentials with the authenticated
 <code>Subject</code>.

 <p> This method invokes the <code>login</code> method for each
 LoginModule configured for the <i>name</i> provided to the
 <code>LoginContext</code> constructor, as determined by the login
 <code>Configuration</code>.  Each <code>LoginModule</code>
 then performs its respective type of authentication
 (username/password, smart card pin verification, etc.).

 <p> This method completes a 2-phase authentication process by
 calling each configured LoginModule's <code>commit</code> method
 if the overall authentication succeeded (the relevant REQUIRED,
 REQUISITE, SUFFICIENT, and OPTIONAL LoginModules succeeded),
 or by calling each configured LoginModule's <code>abort</code> method
 if the overall authentication failed.  If authentication succeeded,
 each successful LoginModule's <code>commit</code> method associates
 the relevant Principals and Credentials with the <code>Subject</code>.
 If authentication failed, each LoginModule's <code>abort</code> method
 removes/destroys any previously stored state.

 <p> If the <code>commit</code> phase of the authentication process
 fails, then the overall authentication fails and this method
 invokes the <code>abort</code> method for each configured
 <code>LoginModule</code>.

 <p> If the <code>abort</code> phase
 fails for any reason, then this method propagates the
 original exception thrown either during the <code>login</code> phase
 or the <code>commit</code> phase.  In either case, the overall
 authentication fails.

 <p> In the case where multiple LoginModules fail,
 this method propagates the exception raised by the first
 <code>LoginModule</code> which failed.

 <p> Note that if this method enters the <code>abort</code> phase
 (either the <code>login</code> or <code>commit</code> phase failed),
 this method invokes all LoginModules configured for the specified
 application regardless of their respective <code>Configuration</code>
 flag parameters.  Essentially this means that <code>Requisite</code>
 and <code>Sufficient</code> semantics are ignored during the
 <code>abort</code> phase.  This guarantees that proper cleanup
 and state restoration can take place.
 
 <p><DD><DL>
<DT><B>Throws:</B><DD><CODE><A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></CODE> - if the authentication fails.</DL>
</DD>
</DL>
<HR>

<A NAME="logout()"><!-- --></A><H3>
logout</H3>
<PRE>
public void <B>logout</B>()
            throws <A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></PRE>
<DL>
<DD>Logout the <code>Subject</code>.

 <p> This method invokes the <code>logout</code> method for each
 <code>LoginModule</code> configured for this <code>LoginContext</code>.
 Each <code>LoginModule</code> performs its respective logout procedure
 which may include removing/destroying
 <code>Principal</code> and <code>Credential</code> information
 from the <code>Subject</code> and state cleanup.

 <p> Note that this method invokes all LoginModules configured for the
 specified application regardless of their respective
 <code>Configuration</code> flag parameters.  Essentially this means
 that <code>Requisite</code> and <code>Sufficient</code> semantics are
 ignored for this method.  This guarantees that proper cleanup
 and state restoration can take place.
 
 <p><DD><DL>
<DT><B>Throws:</B><DD><CODE><A HREF="../../../../javax/security/auth/login/LoginException.html">LoginException</A></CODE> - if the logout fails.</DL>
</DD>
</DL>
<HR>

<A NAME="getSubject()"><!-- --></A><H3>
getSubject</H3>
<PRE>
public <A HREF="../../../../javax/security/auth/Subject.html">Subject</A> <B>getSubject</B>()</PRE>
<DL>
<DD>Return the authenticated Subject.

 <p><DD><DL>
<DT><B>Returns:</B><DD>the authenticated Subject.  If authentication fails
		and a Subject was not provided to this LoginContext's
		constructor, this method returns <code>null</code>.
		Otherwise, this method returns the provided Subject.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>

<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
  <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="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="../../../../javax/security/auth/login/Configuration.html"><B>PREV CLASS</B></A>&nbsp;
&nbsp;NEXT CLASS</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="LoginContext.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY: &nbsp;INNER&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>
<!-- =========== END OF NAVBAR =========== -->

<HR>

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?