subject.html

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

HTML
877
字号
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#isReadOnly()">isReadOnly</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Query whether this <code>Subject</code> is read-only.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#setReadOnly()">setReadOnly</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set this <code>Subject</code> to be read-only.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#toString()">toString</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return the String representation of this <code>Subject</code>.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.Object</B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, finalize, getClass, notify, notifyAll, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ============ FIELD DETAIL =========== -->


<!-- ========= CONSTRUCTOR DETAIL ======== -->

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

<A NAME="Subject()"><!-- --></A><H3>
Subject</H3>
<PRE>
public <B>Subject</B>()</PRE>
<DL>
<DD>Create an instance of a <code>Subject</code>
 with an empty <code>Set</code> of Principals and empty
 Sets of public and private credentials.

 <p> The newly constructed Sets check whether this <code>Subject</code>
 has been set read-only before permitting subsequent modifications.
 The newly created Sets also prevent illegal modifications
 by ensuring that callers have sufficient permissions
 (to modify the Principals Set, the caller must have
 <code>AuthPermission("modifyPrincipals")</code>, for example).</DL>
<HR>

<A NAME="Subject(boolean, java.util.Set, java.util.Set, java.util.Set)"><!-- --></A><H3>
Subject</H3>
<PRE>
public <B>Subject</B>(boolean&nbsp;readOnly,
               java.util.Set&nbsp;principals,
               java.util.Set&nbsp;pubCredentials,
               java.util.Set&nbsp;privCredentials)</PRE>
<DL>
<DD>Create an instance of a <code>Subject</code> with
 the specified Sets of Principals and credentials.

 <p> The specified Sets must check whether this <code>Subject</code>
 has been set read-only before permitting subsequent modifications.
 The specified Sets must also prevent illegal modifications
 by ensuring that callers have sufficient permissions.

 <p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>readOnly</CODE> - true if the <code>Subject</code> is to be read-only,
		and false otherwise. <p><DD><CODE>principals</CODE> - the <code>Set</code> of Principals
		to be associated with this <code>Subject</code>. <p><DD><CODE>pubCredentials</CODE> - the <code>Set</code> of public credentials
		to be associated with this <code>Subject</code>. <p><DD><CODE>privCredentials</CODE> - the <code>Set</code> of private credentials
		to be associated with this <code>Subject</code>.<DT><B>Throws:</B><DD><CODE>java.lang.NullPointerException</CODE> - if the specified
		<code>principals</code>, <code>pubCredentials</code>,
		or <code>privCredentials</code> are <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="setReadOnly()"><!-- --></A><H3>
setReadOnly</H3>
<PRE>
public void <B>setReadOnly</B>()</PRE>
<DL>
<DD>Set this <code>Subject</code> to be read-only.

 <p> Modifications (additions and removals) to this Subject's
 <code>Principal</code> <code>Set</code> and
 credential Sets will be disallowed.
 The <code>destroy</code> operation on this Subject's credentials will
 still be permitted.

 <p> Subsequent attempts to modify the Subject's <code>Principal</code>
 and credential Sets will result in an
 <code>IllegalStateException</code> being thrown.
 Also, once a <code>Subject</code> is read-only,
 it can not be reset to being writable again.

 <p><DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Throws:</B><DD><CODE>java.lang.SecurityException</CODE> - if the caller does not have permission
		to set this <code>Subject</code> to be read-only.</DL>
</DD>
</DL>
<HR>

<A NAME="isReadOnly()"><!-- --></A><H3>
isReadOnly</H3>
<PRE>
public boolean <B>isReadOnly</B>()</PRE>
<DL>
<DD>Query whether this <code>Subject</code> is read-only.

 <p><DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>true if this <code>Subject</code> is read-only, false otherwise.</DL>
</DD>
</DL>
<HR>

<A NAME="getSubject(java.security.AccessControlContext)"><!-- --></A><H3>
getSubject</H3>
<PRE>
public static <A HREF="../../../javax/security/auth/Subject.html">Subject</A> <B>getSubject</B>(java.security.AccessControlContext&nbsp;acc)</PRE>
<DL>
<DD>Get the <code>Subject</code> associated with the provided
 <code>AccessControlContext</code>.

 <p> The <code>AccessControlContext</code> may contain many
 Subjects (from nested <code>doAs</code> calls).
 In this situation, the most recent <code>Subject</code> associated
 with the <code>AccessControlContext</code> is returned.

 <p><DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>acc</CODE> - the <code>AccessControlContext</code> from which to retrieve
		the <code>Subject</code>.<DT><B>Returns:</B><DD>the <code>Subject</code> associated with the provided
		<code>AccessControlContext</code>, or <code>null</code>
		if no <code>Subject</code> is associated
		with the provided <code>AccessControlContext</code>.<DT><B>Throws:</B><DD><CODE>java.lang.SecurityException</CODE> - if the caller does not have permission
		to get the <code>Subject</code>. <p><DD><CODE>java.lang.NullPointerException</CODE> - if the provided
		<code>AccessControlContext</code> is <code>null</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="doAs(javax.security.auth.Subject, java.security.PrivilegedAction)"><!-- --></A><H3>
doAs</H3>
<PRE>
public static java.lang.Object <B>doAs</B>(<A HREF="../../../javax/security/auth/Subject.html">Subject</A>&nbsp;subject,
                                    java.security.PrivilegedAction&nbsp;action)</PRE>
<DL>
<DD>Perform work as a particular <code>Subject</code>.

 <p> This method first retrieves the current Thread's
 <code>AccessControlContext</code> via
 <code>AccessController.getContext</code>,
 and then instantiates a new <code>AccessControlContext</code>
 using the retrieved context along with a new
 <code>SubjectDomainCombiner</code> (constructed using
 the provided <code>Subject</code>).
 Finally, this method invokes <code>AccessController.doPrivileged</code>,
 passing it the provided <code>PrivilegedAction</code>,
 as well as the newly constructed <code>AccessControlContext</code>.

 <p><DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>subject</CODE> - the <code>Subject</code> that the specified
			<code>action</code> will run as.  This parameter
			may be <code>null</code>. <p><DD><CODE>action</CODE> - the code to be run as the specified
			<code>Subject</code>. <p><DT><B>Returns:</B><DD>the <code>Object</code> returned by the PrivilegedAction's
			<code>run</code> method.<DT><B>Throws:</B><DD><CODE>java.lang.NullPointerException</CODE> - if the <code>PrivilegedAction</code>
			is <code>null</code>. <p><DD><CODE>java.lang.SecurityException</CODE> - if the caller does not have permission
			to invoke this method.</DL>
</DD>
</DL>
<HR>

<A NAME="doAs(javax.security.auth.Subject, java.security.PrivilegedExceptionAction)"><!-- --></A><H3>
doAs</H3>
<PRE>
public static java.lang.Object <B>doAs</B>(<A HREF="../../../javax/security/auth/Subject.html">Subject</A>&nbsp;subject,
                                    java.security.PrivilegedExceptionAction&nbsp;action)
                             throws java.security.PrivilegedActionException</PRE>
<DL>
<DD>Perform work as a particular <code>Subject</code>.

 <p> This method first retrieves the current Thread's
 <code>AccessControlContext</code> via
 <code>AccessController.getContext</code>,
 and then instantiates a new <code>AccessControlContext</code>
 using the retrieved context along with a new
 <code>SubjectDomainCombiner</code> (constructed using
 the provided <code>Subject</code>).
 Finally, this method invokes <code>AccessController.doPrivileged</code>,
 passing it the provided <code>PrivilegedExceptionAction</code>,
 as well as the newly constructed <code>AccessControlContext</code>.

 <p><DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>subject</CODE> - the <code>Subject</code> that the specified
			<code>action</code> will run as.  This parameter
			may be <code>null</code>. <p><DD><CODE>action</CODE> - the code to be run as the specified
			<code>Subject</code>. <p><DT><B>Returns:</B><DD>the <code>Object</code> returned by the
			PrivilegedExceptionAction's <code>run</code> method.<DT><B>Throws:</B><DD><CODE>java.security.PrivilegedActionException</CODE> - if the
			<code>PrivilegedExceptionAction.run</code>
			method throws a checked exception. <p><DD><CODE>java.lang.NullPointerException</CODE> - if the specified
			<code>PrivilegedExceptionAction</code> is
			<code>null</code>. <p><DD><CODE>java.lang.SecurityException</CODE> - if the caller does not have permission
			to invoke this method.</DL>
</DD>
</DL>
<HR>

<A NAME="doAsPrivileged(javax.security.auth.Subject, java.security.PrivilegedAction, java.security.AccessControlContext)"><!-- --></A><H3>
doAsPrivileged</H3>
<PRE>
public static java.lang.Object <B>doAsPrivileged</B>(<A HREF="../../../javax/security/auth/Subject.html">Subject</A>&nbsp;subject,
                                              java.security.PrivilegedAction&nbsp;action,
                                              java.security.AccessControlContext&nbsp;acc)</PRE>
<DL>
<DD>Perform privileged work as a particular <code>Subject</code>.

 <p> This method behaves exactly as <code>Subject.doAs</code>,
 except that instead of retrieving the current Thread's
 <code>AccessControlContext</code>, it uses the provided
 <code>AccessControlContext</code>.  If the provided
 <code>AccessControlContext</code> is <code>null</code>,
 this method instantiates a new <code>AccessControlContext</code>
 with an empty collection of ProtectionDomains.

 <p><DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>subject</CODE> - the <code>Subject</code> that the specified
			<code>action</code> will run as.  This parameter
			may be <code>null</code>. <p><DD><CODE>action</CODE> - the code to be run as the specified
			<code>Subject</code>. <p><DD><CODE>acc</CODE> - the <code>AccessControlContext</code> to be tied to the
			specified <i>subject</i> and <i>action</i>. <p><DT><B>Returns:</B><DD>the <code>Object</code> returned by the PrivilegedAction's
			<code>run</code> method.<DT><B>Throws:</B><DD><CODE>java.lang.NullPointerException</CODE> - if the <code>PrivilegedAction</code>
			is <code>null</code>. <p><DD><CODE>java.lang.SecurityException</CODE> - if the caller does not have permission
			to invoke this method.</DL>
</DD>
</DL>
<HR>

<A NAME="doAsPrivileged(javax.security.auth.Subject, java.security.PrivilegedExceptionAction, java.security.AccessControlContext)"><!-- --></A><H3>
doAsPrivileged</H3>
<PRE>
public static java.lang.Object <B>doAsPrivileged</B>(<A HREF="../../../javax/security/auth/Subject.html">Subject</A>&nbsp;subject,
                                              java.security.PrivilegedExceptionAction&nbsp;action,
                                              java.security.AccessControlContext&nbsp;acc)
                                       throws java.security.PrivilegedActionException</PRE>
<DL>
<DD>Perform privileged work as a particular <code>Subject</code>.

 <p> This method behaves exactly as <code>Subject.doAs</code>,

⌨️ 快捷键说明

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