subject.html
来自「SUN公司官方J2EE中文帮助文档 应该不错 有兴趣的下来看看 html格式的」· HTML 代码 · 共 877 行 · 第 1/3 页
HTML
877 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Thu Jan 17 03:51:37 PST 2002 -->
<TITLE>
Java 2 Platform EE v1.3: Class Subject
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_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> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../javax/security/auth/PrivateCredentialPermission.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/security/auth/SubjectDomainCombiner.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="Subject.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.security.auth</FONT>
<BR>
Class Subject</H2>
<PRE>
java.lang.Object
|
+--<B>javax.security.auth.Subject</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD>java.io.Serializable</DD>
</DL>
<HR>
<DL>
<DT>public final class <B>Subject</B><DT>extends java.lang.Object<DT>implements java.io.Serializable</DL>
<P>
<p> A <code>Subject</code> represents a grouping of related information
for a single entity, such as a person.
Such information includes the Subject's identities as well as
its security-related attributes
(passwords and cryptographic keys, for example).
<p> Subjects may potentially have multiple identities.
Each identity is represented as a <code>Principal</code>
within the <code>Subject</code>. Principals simply bind names to a
<code>Subject</code>. For example, a <code>Subject</code> that happens
to be a person, Alice, might have two Principals:
one which binds "Alice Bar", the name on her driver license,
to the <code>Subject</code>, and another which binds,
"999-99-9999", the number on her student identification card,
to the <code>Subject</code>. Both Principals refer to the same
<code>Subject</code> even though each has a different name.
<p> A <code>Subject</code> may also own security-related attributes,
which are referred to as credentials.
Sensitive credentials that require special protection, such as
private cryptographic keys, are stored within a private credential
<code>Set</code>. Credentials intended to be shared, such as
public key certificates or Kerberos server tickets are stored
within a public credential <code>Set</code>. Different permissions
are required to access and modify the different credential Sets.
<p> To retrieve all the Principals associated with a <code>Subject</code>,
invoke the <code>getPrincipals</code> method. To retrieve
all the public or private credentials belonging to a <code>Subject</code>,
invoke the <code>getPublicCredentials</code> method or
<code>getPrivateCredentials</code> method, respectively.
To modify the returned <code>Set</code> of Principals and credentials,
use the methods defined in the <code>Set</code> class.
For example:
<pre>
Subject subject;
Principal principal;
Object credential;
// add a Principal and credential to the Subject
subject.getPrincipals().add(principal);
subject.getPublicCredentials().add(credential);
</pre>
<p> This <code>Subject</code> class implements <code>Serializable</code>.
While the Principals associated with the <code>Subject</code> are serialized,
the credentials associated with the <code>Subject</code> are not.
Note that the <code>java.security.Principal</code> class
does not implement <code>Serializable</code>. Therefore all concrete
<code>Principal</code> implementations associated with Subjects
must implement <code>Serializable</code>.
<P>
<DL>
<DT><B>See Also: </B><DD><CODE>Principal</CODE>,
<CODE>DomainCombiner</CODE>, <A HREF="../../../serialized-form.html#javax.security.auth.Subject">Serialized Form</A></DL>
<HR>
<P>
<!-- ======== INNER CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#Subject()">Subject</A></B>()</CODE>
<BR>
Create an instance of a <code>Subject</code>
with an empty <code>Set</code> of Principals and empty
Sets of public and private credentials.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#Subject(boolean, java.util.Set, java.util.Set, java.util.Set)">Subject</A></B>(boolean readOnly,
java.util.Set principals,
java.util.Set pubCredentials,
java.util.Set privCredentials)</CODE>
<BR>
Create an instance of a <code>Subject</code> with
the specified Sets of Principals and credentials.</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#doAs(javax.security.auth.Subject, java.security.PrivilegedAction)">doAs</A></B>(<A HREF="../../../javax/security/auth/Subject.html">Subject</A> subject,
java.security.PrivilegedAction action)</CODE>
<BR>
Perform work as a particular <code>Subject</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#doAs(javax.security.auth.Subject, java.security.PrivilegedExceptionAction)">doAs</A></B>(<A HREF="../../../javax/security/auth/Subject.html">Subject</A> subject,
java.security.PrivilegedExceptionAction action)</CODE>
<BR>
Perform work as a particular <code>Subject</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#doAsPrivileged(javax.security.auth.Subject, java.security.PrivilegedAction, java.security.AccessControlContext)">doAsPrivileged</A></B>(<A HREF="../../../javax/security/auth/Subject.html">Subject</A> subject,
java.security.PrivilegedAction action,
java.security.AccessControlContext acc)</CODE>
<BR>
Perform privileged work as a particular <code>Subject</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.lang.Object</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#doAsPrivileged(javax.security.auth.Subject, java.security.PrivilegedExceptionAction, java.security.AccessControlContext)">doAsPrivileged</A></B>(<A HREF="../../../javax/security/auth/Subject.html">Subject</A> subject,
java.security.PrivilegedExceptionAction action,
java.security.AccessControlContext acc)</CODE>
<BR>
Perform privileged work as a particular <code>Subject</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#equals(java.lang.Object)">equals</A></B>(java.lang.Object o)</CODE>
<BR>
Compares the specified Object with this <code>Subject</code>
for equality.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Set</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#getPrincipals()">getPrincipals</A></B>()</CODE>
<BR>
Return the <code>Set</code> of Principals associated with this
<code>Subject</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Set</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#getPrincipals(java.lang.Class)">getPrincipals</A></B>(java.lang.Class c)</CODE>
<BR>
Return a <code>Set</code> of Principals associated with this
<code>Subject</code> that are instances or subclasses of the specified
<code>Class</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Set</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#getPrivateCredentials()">getPrivateCredentials</A></B>()</CODE>
<BR>
Return the <code>Set</code> of private credentials held by this
<code>Subject</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Set</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#getPrivateCredentials(java.lang.Class)">getPrivateCredentials</A></B>(java.lang.Class c)</CODE>
<BR>
Return a <code>Set</code> of private credentials associated with this
<code>Subject</code> that are instances or subclasses of the specified
<code>Class</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Set</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#getPublicCredentials()">getPublicCredentials</A></B>()</CODE>
<BR>
Return the <code>Set</code> of public credentials held by this
<code>Subject</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.Set</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#getPublicCredentials(java.lang.Class)">getPublicCredentials</A></B>(java.lang.Class c)</CODE>
<BR>
Return a <code>Set</code> of public credentials associated with this
<code>Subject</code> that are instances or subclasses of the specified
<code>Class</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static <A HREF="../../../javax/security/auth/Subject.html">Subject</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#getSubject(java.security.AccessControlContext)">getSubject</A></B>(java.security.AccessControlContext acc)</CODE>
<BR>
Get the <code>Subject</code> associated with the provided
<code>AccessControlContext</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Subject.html#hashCode()">hashCode</A></B>()</CODE>
<BR>
Returns a hashcode for this <code>Subject</code>.</TD>
</TR>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?