policy.html
来自「SUN公司官方J2EE中文帮助文档 应该不错 有兴趣的下来看看 html格式的」· HTML 代码 · 共 415 行 · 第 1/2 页
HTML
415 行
<!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 Policy
</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/AuthPermission.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/security/auth/PrivateCredentialPermission.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="Policy.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 Policy</H2>
<PRE>
java.lang.Object
|
+--<B>javax.security.auth.Policy</B>
</PRE>
<HR>
<DL>
<DT>public abstract class <B>Policy</B><DT>extends java.lang.Object</DL>
<P>
<p> This is an abstract class for representing the system policy for
Subject-based authorization. A subclass implementation
of this class provides a means to specify a Subject-based
access control <code>Policy</code>.
<p> A <code>Policy</code> object can be queried for the set of
Permissions granted to code running as a
<code>Principal</code> in the following manner:
<pre>
policy = Policy.getPolicy();
PermissionCollection perms = policy.getPermissions(subject,
codeSource);
</pre>
The <code>Policy</code> object consults the local policy and returns
and appropriate <code>Permissions</code> object with the
Permissions granted to the Principals associated with the
provided <i>subject</i>, and granted to the code specified
by the provided <i>codeSource</i>.
<p> A <code>Policy</code> contains the following information.
Note that this example only represents the syntax for the default
<code>Policy</code> implementation. Subclass implementations of this class
may implement alternative syntaxes and may retrieve the
<code>Policy</code> from any source such as files, databases,
or servers.
<p> Each entry in the <code>Policy</code> is represented as
a <b><i>grant</i></b> entry. Each <b><i>grant</i></b> entry
specifies a codebase, code signers, and Principals triplet,
as well as the Permissions granted to that triplet.
<pre>
grant CodeBase ["URL"], Signedby ["signers"],
Principal [Principal_Class] "Principal_Name" {
Permission Permission_Class ["Target_Name"]
[, "Permission_Actions"]
[, signedBy "SignerName"];
};
</pre>
The CodeBase and Signedby components of the triplet name/value pairs
are optional. If they are not present, then any any codebase will match,
and any signer (including unsigned code) will match.
For Example,
<pre>
grant CodeBase "foo.com", Signedby "foo",
Principal com.sun.security.auth.SolarisPrincipal "duke" {
permission java.io.FilePermission "/home/duke", "read, write";
};
</pre>
This <b><i>grant</i></b> entry specifies that code from "foo.com",
signed by "foo', and running as a <code>SolarisPrincipal</code> with the
name, duke, has one <code>Permission</code>. This <code>Permission</code>
permits the executing code to read and write files in the directory,
"/home/duke".
<p> To "run" as a particular <code>Principal</code>,
code invokes the <code>Subject.doAs(subject, ...)</code> method.
After invoking that method, the code runs as all the Principals
associated with the specified <code>Subject</code>.
Note that this <code>Policy</code> (and the Permissions
granted in this <code>Policy</code>) only become effective
after the call to <code>Subject.doAs</code> has occurred.
<p> Multiple Principals may be listed within one <b><i>grant</i></b> entry.
All the Principals in the grant entry must be associated with
the <code>Subject</code> provided to <code>Subject.doAs</code>
for that <code>Subject</code> to be granted the specified Permissions.
<pre>
grant Principal com.sun.security.auth.SolarisPrincipal "duke",
Principal com.sun.security.auth.SolarisNumericUserPrincipal "0" {
permission java.io.FilePermission "/home/duke", "read, write";
permission java.net.SocketPermission "duke.com", "connect";
};
</pre>
This entry grants any code running as both "duke" and "0"
permission to read and write files in duke's home directory,
as well as permission to make socket connections to "duke.com".
<p> Note that non Principal-based grant entries are not permitted
in this <code>Policy</code>. Therefore, grant entries such as:
<pre>
grant CodeBase "foo.com", Signedby "foo" {
permission java.io.FilePermission "/tmp/scratch", "read, write";
};
</pre>
are rejected. Such permission must be listed in the
<code>java.security.Policy</code>.
<p> The default <code>Policy</code> implementation can be changed by
setting the value of the "auth.policy.provider" security property
(in the Java security properties file) to the fully qualified name of
the desired <code>Policy</code> implementation class.
The Java security properties file is located in the file named
<JAVA_HOME>/lib/security/java.security, where <JAVA_HOME>
refers to the directory where the JDK was installed.
<P>
<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 ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected </CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/security/auth/Policy.html#Policy()">Policy</A></B>()</CODE>
<BR>
Sole constructor.</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>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?