Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/net/NetPermission.java
38829 views
1
/*
2
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
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
*
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.
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
43
* signify a wildcard match. For example: "foo.*" and "*" signify a wildcard
44
* match, while "*foo" and "a*b" do not.
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
*
50
* <table border=1 cellpadding=5 summary="Permission target name, what the permission allows, and associated risks">
51
* <tr>
52
* <th>Permission Target Name</th>
53
* <th>What the Permission Allows</th>
54
* <th>Risks of Allowing this Permission</th>
55
* </tr>
56
* <tr>
57
* <td>allowHttpTrace</td>
58
* <td>The ability to use the HTTP TRACE method in HttpURLConnection.</td>
59
* <td>Malicious code using HTTP TRACE could get access to security sensitive
60
* information in the HTTP headers (such as cookies) that it might not
61
* otherwise have access to.</td>
62
* </tr>
63
*
64
* <tr>
65
* <td>getCookieHandler</td>
66
* <td>The ability to get the cookie handler that processes highly
67
* security sensitive cookie information for an Http session.</td>
68
* <td>Malicious code can get a cookie handler to obtain access to
69
* highly security sensitive cookie information. Some web servers
70
* use cookies to save user private information such as access
71
* control information, or to track user browsing habit.</td>
72
* </tr>
73
*
74
* <tr>
75
* <td>getNetworkInformation</td>
76
* <td>The ability to retrieve all information about local network interfaces.</td>
77
* <td>Malicious code can read information about network hardware such as
78
* MAC addresses, which could be used to construct local IPv6 addresses.</td>
79
* </tr>
80
*
81
* <tr>
82
* <td>getProxySelector</td>
83
* <td>The ability to get the proxy selector used to make decisions
84
* on which proxies to use when making network connections.</td>
85
* <td>Malicious code can get a ProxySelector to discover proxy
86
* hosts and ports on internal networks, which could then become
87
* targets for attack.</td>
88
* </tr>
89
*
90
* <tr>
91
* <td>getResponseCache</td>
92
* <td>The ability to get the response cache that provides
93
* access to a local response cache.</td>
94
* <td>Malicious code getting access to the local response cache
95
* could access security sensitive information.</td>
96
* </tr>
97
*
98
* <tr>
99
* <td>requestPasswordAuthentication</td>
100
* <td>The ability
101
* to ask the authenticator registered with the system for
102
* a password</td>
103
* <td>Malicious code may steal this password.</td>
104
* </tr>
105
*
106
* <tr>
107
* <td>setCookieHandler</td>
108
* <td>The ability to set the cookie handler that processes highly
109
* security sensitive cookie information for an Http session.</td>
110
* <td>Malicious code can set a cookie handler to obtain access to
111
* highly security sensitive cookie information. Some web servers
112
* use cookies to save user private information such as access
113
* control information, or to track user browsing habit.</td>
114
* </tr>
115
*
116
* <tr>
117
* <td>setDefaultAuthenticator</td>
118
* <td>The ability to set the
119
* way authentication information is retrieved when
120
* a proxy or HTTP server asks for authentication</td>
121
* <td>Malicious
122
* code can set an authenticator that monitors and steals user
123
* authentication input as it retrieves the input from the user.</td>
124
* </tr>
125
*
126
* <tr>
127
* <td>setProxySelector</td>
128
* <td>The ability to set the proxy selector used to make decisions
129
* on which proxies to use when making network connections.</td>
130
* <td>Malicious code can set a ProxySelector that directs network
131
* traffic to an arbitrary network host.</td>
132
* </tr>
133
*
134
* <tr>
135
* <td>setResponseCache</td>
136
* <td>The ability to set the response cache that provides access to
137
* a local response cache.</td>
138
* <td>Malicious code getting access to the local response cache
139
* could access security sensitive information, or create false
140
* entries in the response cache.</td>
141
* </tr>
142
*
143
* <tr>
144
* <td>specifyStreamHandler</td>
145
* <td>The ability
146
* to specify a stream handler when constructing a URL</td>
147
* <td>Malicious code may create a URL with resources that it would
148
normally not have access to (like file:/foo/fum/), specifying a
149
stream handler that gets the actual bytes from someplace it does
150
have access to. Thus it might be able to trick the system into
151
creating a ProtectionDomain/CodeSource for a class even though
152
that class really didn't come from that location.</td>
153
* </tr>
154
*
155
* <tr>
156
* <th scope="row">setSocketImpl</th>
157
* <td>The ability to create a sub-class of Socket or ServerSocket with a
158
* user specified SocketImpl.</td>
159
* <td>Malicious user-defined SocketImpls can change the behavior of
160
* Socket and ServerSocket in surprising ways, by virtue of their
161
* ability to access the protected fields of SocketImpl.</td>
162
* </tr>
163
* </table>
164
*
165
* @see java.security.BasicPermission
166
* @see java.security.Permission
167
* @see java.security.Permissions
168
* @see java.security.PermissionCollection
169
* @see java.lang.SecurityManager
170
*
171
*
172
* @author Marianne Mueller
173
* @author Roland Schemers
174
*/
175
176
public final class NetPermission extends BasicPermission {
177
private static final long serialVersionUID = -8343910153355041693L;
178
179
/**
180
* Creates a new NetPermission with the specified name.
181
* The name is the symbolic name of the NetPermission, such as
182
* "setDefaultAuthenticator", etc. An asterisk
183
* may appear at the end of the name, following a ".", or by itself, to
184
* signify a wildcard match.
185
*
186
* @param name the name of the NetPermission.
187
*
188
* @throws NullPointerException if {@code name} is {@code null}.
189
* @throws IllegalArgumentException if {@code name} is empty.
190
*/
191
192
public NetPermission(String name)
193
{
194
super(name);
195
}
196
197
/**
198
* Creates a new NetPermission object with the specified name.
199
* The name is the symbolic name of the NetPermission, and the
200
* actions String is currently unused and should be null.
201
*
202
* @param name the name of the NetPermission.
203
* @param actions should be null.
204
*
205
* @throws NullPointerException if {@code name} is {@code null}.
206
* @throws IllegalArgumentException if {@code name} is empty.
207
*/
208
209
public NetPermission(String name, String actions)
210
{
211
super(name, actions);
212
}
213
}
214
215