author | juh |
Tue, 30 Jul 2013 11:04:19 -0700 | |
changeset 19069 | 1d9cb0d080e3 |
parent 14667 | 6862285acf46 |
child 21334 | c60dfce46a77 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
19069 | 2 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.net; |
|
27 |
||
28 |
import java.security.*; |
|
29 |
import java.util.Enumeration; |
|
30 |
import java.util.Hashtable; |
|
31 |
import java.util.StringTokenizer; |
|
32 |
||
33 |
/** |
|
34 |
* This class is for various network permissions. |
|
35 |
* A NetPermission contains a name (also referred to as a "target name") but |
|
36 |
* no actions list; you either have the named permission |
|
37 |
* or you don't. |
|
38 |
* <P> |
|
39 |
* The target name is the name of the network permission (see below). The naming |
|
40 |
* convention follows the hierarchical property naming convention. |
|
41 |
* Also, an asterisk |
|
42 |
* may appear at the end of the name, following a ".", or by itself, to |
|
14667
6862285acf46
7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
9035
diff
changeset
|
43 |
* signify a wildcard match. For example: "foo.*" and "*" signify a wildcard |
6862285acf46
7167056: Clarify that BasicPermission names that contain non-wildcard asterisks are not invalid
mullan
parents:
9035
diff
changeset
|
44 |
* match, while "*foo" and "a*b" do not. |
2 | 45 |
* <P> |
46 |
* The following table lists all the possible NetPermission target names, |
|
47 |
* and for each provides a description of what the permission allows |
|
48 |
* and a discussion of the risks of granting code the permission. |
|
49 |
* <P> |
|
50 |
* |
|
51 |
* <table border=1 cellpadding=5 summary="Permission target name, what the permission allows, and associated risks"> |
|
52 |
* <tr> |
|
53 |
* <th>Permission Target Name</th> |
|
54 |
* <th>What the Permission Allows</th> |
|
55 |
* <th>Risks of Allowing this Permission</th> |
|
56 |
* </tr> |
|
57 |
* <tr> |
|
6875
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
58 |
* <td>allowHttpTrace</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
59 |
* <td>The ability to use the HTTP TRACE method in HttpURLConnection.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
60 |
* <td>Malicious code using HTTP TRACE could get access to security sensitive |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
61 |
* information in the HTTP headers (such as cookies) that it might not |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
62 |
* otherwise have access to.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
63 |
* </tr> |
2 | 64 |
* |
65 |
* <tr> |
|
6875
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
66 |
* <td>getCookieHandler</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
67 |
* <td>The ability to get the cookie handler that processes highly |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
68 |
* security sensitive cookie information for an Http session.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
69 |
* <td>Malicious code can get a cookie handler to obtain access to |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
70 |
* highly security sensitive cookie information. Some web servers |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
71 |
* use cookies to save user private information such as access |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
72 |
* control information, or to track user browsing habit.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
73 |
* </tr> |
2 | 74 |
* |
75 |
* <tr> |
|
8566
e2df5f8fa082
7024264: HttpURLConnection/NetPermission doc issue
michaelm
parents:
7668
diff
changeset
|
76 |
* <td>getNetworkInformation</td> |
e2df5f8fa082
7024264: HttpURLConnection/NetPermission doc issue
michaelm
parents:
7668
diff
changeset
|
77 |
* <td>The ability to retrieve all information about local network interfaces.</td> |
e2df5f8fa082
7024264: HttpURLConnection/NetPermission doc issue
michaelm
parents:
7668
diff
changeset
|
78 |
* <td>Malicious code can read information about network hardware such as |
e2df5f8fa082
7024264: HttpURLConnection/NetPermission doc issue
michaelm
parents:
7668
diff
changeset
|
79 |
* MAC addresses, which could be used to construct local IPv6 addresses.</td> |
e2df5f8fa082
7024264: HttpURLConnection/NetPermission doc issue
michaelm
parents:
7668
diff
changeset
|
80 |
* </tr> |
e2df5f8fa082
7024264: HttpURLConnection/NetPermission doc issue
michaelm
parents:
7668
diff
changeset
|
81 |
* |
e2df5f8fa082
7024264: HttpURLConnection/NetPermission doc issue
michaelm
parents:
7668
diff
changeset
|
82 |
* <tr> |
2 | 83 |
* <td>getProxySelector</td> |
84 |
* <td>The ability to get the proxy selector used to make decisions |
|
85 |
* on which proxies to use when making network connections.</td> |
|
86 |
* <td>Malicious code can get a ProxySelector to discover proxy |
|
87 |
* hosts and ports on internal networks, which could then become |
|
88 |
* targets for attack.</td> |
|
89 |
* </tr> |
|
90 |
* |
|
91 |
* <tr> |
|
6875
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
92 |
* <td>getResponseCache</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
93 |
* <td>The ability to get the response cache that provides |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
94 |
* access to a local response cache.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
95 |
* <td>Malicious code getting access to the local response cache |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
96 |
* could access security sensitive information.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
97 |
* </tr> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
98 |
* |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
99 |
* <tr> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
100 |
* <td>requestPasswordAuthentication</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
101 |
* <td>The ability |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
102 |
* to ask the authenticator registered with the system for |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
103 |
* a password</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
104 |
* <td>Malicious code may steal this password.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
105 |
* </tr> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
106 |
* |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
107 |
* <tr> |
2 | 108 |
* <td>setCookieHandler</td> |
109 |
* <td>The ability to set the cookie handler that processes highly |
|
110 |
* security sensitive cookie information for an Http session.</td> |
|
111 |
* <td>Malicious code can set a cookie handler to obtain access to |
|
112 |
* highly security sensitive cookie information. Some web servers |
|
113 |
* use cookies to save user private information such as access |
|
114 |
* control information, or to track user browsing habit.</td> |
|
115 |
* </tr> |
|
116 |
* |
|
117 |
* <tr> |
|
6875
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
118 |
* <td>setDefaultAuthenticator</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
119 |
* <td>The ability to set the |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
120 |
* way authentication information is retrieved when |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
121 |
* a proxy or HTTP server asks for authentication</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
122 |
* <td>Malicious |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
123 |
* code can set an authenticator that monitors and steals user |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
124 |
* authentication input as it retrieves the input from the user.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
125 |
* </tr> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
126 |
* |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
127 |
* <tr> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
128 |
* <td>setProxySelector</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
129 |
* <td>The ability to set the proxy selector used to make decisions |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
130 |
* on which proxies to use when making network connections.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
131 |
* <td>Malicious code can set a ProxySelector that directs network |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
132 |
* traffic to an arbitrary network host.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
133 |
* </tr> |
2 | 134 |
* |
135 |
* <tr> |
|
136 |
* <td>setResponseCache</td> |
|
137 |
* <td>The ability to set the response cache that provides access to |
|
138 |
* a local response cache.</td> |
|
139 |
* <td>Malicious code getting access to the local response cache |
|
140 |
* could access security sensitive information, or create false |
|
141 |
* entries in the response cache.</td> |
|
142 |
* </tr> |
|
143 |
* |
|
144 |
* <tr> |
|
6875
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
145 |
* <td>specifyStreamHandler</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
146 |
* <td>The ability |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
147 |
* to specify a stream handler when constructing a URL</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
148 |
* <td>Malicious code may create a URL with resources that it would |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
149 |
normally not have access to (like file:/foo/fum/), specifying a |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
150 |
stream handler that gets the actual bytes from someplace it does |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
151 |
have access to. Thus it might be able to trick the system into |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
152 |
creating a ProtectionDomain/CodeSource for a class even though |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
153 |
that class really didn't come from that location.</td> |
81d6ec3397e5
6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents:
5506
diff
changeset
|
154 |
* </tr> |
2 | 155 |
* </table> |
156 |
* |
|
157 |
* @see java.security.BasicPermission |
|
158 |
* @see java.security.Permission |
|
159 |
* @see java.security.Permissions |
|
160 |
* @see java.security.PermissionCollection |
|
161 |
* @see java.lang.SecurityManager |
|
162 |
* |
|
163 |
* |
|
164 |
* @author Marianne Mueller |
|
165 |
* @author Roland Schemers |
|
166 |
*/ |
|
167 |
||
168 |
public final class NetPermission extends BasicPermission { |
|
169 |
private static final long serialVersionUID = -8343910153355041693L; |
|
170 |
||
171 |
/** |
|
172 |
* Creates a new NetPermission with the specified name. |
|
173 |
* The name is the symbolic name of the NetPermission, such as |
|
174 |
* "setDefaultAuthenticator", etc. An asterisk |
|
175 |
* may appear at the end of the name, following a ".", or by itself, to |
|
176 |
* signify a wildcard match. |
|
177 |
* |
|
178 |
* @param name the name of the NetPermission. |
|
179 |
* |
|
19069 | 180 |
* @throws NullPointerException if {@code name} is {@code null}. |
181 |
* @throws IllegalArgumentException if {@code name} is empty. |
|
2 | 182 |
*/ |
183 |
||
184 |
public NetPermission(String name) |
|
185 |
{ |
|
186 |
super(name); |
|
187 |
} |
|
188 |
||
189 |
/** |
|
190 |
* Creates a new NetPermission object with the specified name. |
|
191 |
* The name is the symbolic name of the NetPermission, and the |
|
192 |
* actions String is currently unused and should be null. |
|
193 |
* |
|
194 |
* @param name the name of the NetPermission. |
|
195 |
* @param actions should be null. |
|
196 |
* |
|
19069 | 197 |
* @throws NullPointerException if {@code name} is {@code null}. |
198 |
* @throws IllegalArgumentException if {@code name} is empty. |
|
2 | 199 |
*/ |
200 |
||
201 |
public NetPermission(String name, String actions) |
|
202 |
{ |
|
203 |
super(name, actions); |
|
204 |
} |
|
205 |
} |