001 /*
002 * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package java.net;
027
028 import java.security.*;
029 import java.util.Enumeration;
030 import java.util.Hashtable;
031 import java.util.StringTokenizer;
032
033 /**
034 * This class is for various network permissions.
035 * A NetPermission contains a name (also referred to as a "target name") but
036 * no actions list; you either have the named permission
037 * or you don't.
038 * <P>
039 * The target name is the name of the network permission (see below). The naming
040 * convention follows the hierarchical property naming convention.
041 * Also, an asterisk
042 * may appear at the end of the name, following a ".", or by itself, to
043 * signify a wildcard match. For example: "foo.*" or "*" is valid,
044 * "*foo" or "a*b" is not valid.
045 * <P>
046 * The following table lists all the possible NetPermission target names,
047 * and for each provides a description of what the permission allows
048 * and a discussion of the risks of granting code the permission.
049 * <P>
050 *
051 * <table border=1 cellpadding=5 summary="Permission target name, what the permission allows, and associated risks">
052 * <tr>
053 * <th>Permission Target Name</th>
054 * <th>What the Permission Allows</th>
055 * <th>Risks of Allowing this Permission</th>
056 * </tr>
057 *
058 * <tr>
059 * <td>setDefaultAuthenticator</td>
060 * <td>The ability to set the
061 * way authentication information is retrieved when
062 * a proxy or HTTP server asks for authentication</td>
063 * <td>Malicious
064 * code can set an authenticator that monitors and steals user
065 * authentication input as it retrieves the input from the user.</td>
066 * </tr>
067 *
068 * <tr>
069 * <td>requestPasswordAuthentication</td>
070 * <td>The ability
071 * to ask the authenticator registered with the system for
072 * a password</td>
073 * <td>Malicious code may steal this password.</td>
074 * </tr>
075 *
076 * <tr>
077 * <td>specifyStreamHandler</td>
078 * <td>The ability
079 * to specify a stream handler when constructing a URL</td>
080 * <td>Malicious code may create a URL with resources that it would
081 normally not have access to (like file:/foo/fum/), specifying a
082 stream handler that gets the actual bytes from someplace it does
083 have access to. Thus it might be able to trick the system into
084 creating a ProtectionDomain/CodeSource for a class even though
085 that class really didn't come from that location.</td>
086 * </tr>
087 *
088 * <tr>
089 * <td>setProxySelector</td>
090 * <td>The ability to set the proxy selector used to make decisions
091 * on which proxies to use when making network connections.</td>
092 * <td>Malicious code can set a ProxySelector that directs network
093 * traffic to an arbitrary network host.</td>
094 * </tr>
095 *
096 * <tr>
097 * <td>getProxySelector</td>
098 * <td>The ability to get the proxy selector used to make decisions
099 * on which proxies to use when making network connections.</td>
100 * <td>Malicious code can get a ProxySelector to discover proxy
101 * hosts and ports on internal networks, which could then become
102 * targets for attack.</td>
103 * </tr>
104 *
105 * <tr>
106 * <td>setCookieHandler</td>
107 * <td>The ability to set the cookie handler that processes highly
108 * security sensitive cookie information for an Http session.</td>
109 * <td>Malicious code can set a cookie handler to obtain access to
110 * highly security sensitive cookie information. Some web servers
111 * use cookies to save user private information such as access
112 * control information, or to track user browsing habit.</td>
113 * </tr>
114 *
115 * <tr>
116 * <td>getCookieHandler</td>
117 * <td>The ability to get the cookie handler that processes highly
118 * security sensitive cookie information for an Http session.</td>
119 * <td>Malicious code can get a cookie handler to obtain access to
120 * highly security sensitive cookie information. Some web servers
121 * use cookies to save user private information such as access
122 * control information, or to track user browsing habit.</td>
123 * </tr>
124 *
125 * <tr>
126 * <td>setResponseCache</td>
127 * <td>The ability to set the response cache that provides access to
128 * a local response cache.</td>
129 * <td>Malicious code getting access to the local response cache
130 * could access security sensitive information, or create false
131 * entries in the response cache.</td>
132 * </tr>
133 *
134 * <tr>
135 * <td>getResponseCache</td>
136 * <td>The ability to get the response cache that provides
137 * access to a local response cache.</td>
138 * <td>Malicious code getting access to the local response cache
139 * could access security sensitive information.</td>
140 * </tr>
141 *
142 * </table>
143 *
144 * @see java.security.BasicPermission
145 * @see java.security.Permission
146 * @see java.security.Permissions
147 * @see java.security.PermissionCollection
148 * @see java.lang.SecurityManager
149 *
150 * @version 1.57 07/05/05
151 *
152 * @author Marianne Mueller
153 * @author Roland Schemers
154 */
155
156 public final class NetPermission extends BasicPermission {
157 private static final long serialVersionUID = -8343910153355041693L;
158
159 /**
160 * Creates a new NetPermission with the specified name.
161 * The name is the symbolic name of the NetPermission, such as
162 * "setDefaultAuthenticator", etc. An asterisk
163 * may appear at the end of the name, following a ".", or by itself, to
164 * signify a wildcard match.
165 *
166 * @param name the name of the NetPermission.
167 *
168 * @throws NullPointerException if <code>name</code> is <code>null</code>.
169 * @throws IllegalArgumentException if <code>name</code> is empty.
170 */
171
172 public NetPermission(String name) {
173 super (name);
174 }
175
176 /**
177 * Creates a new NetPermission object with the specified name.
178 * The name is the symbolic name of the NetPermission, and the
179 * actions String is currently unused and should be null.
180 *
181 * @param name the name of the NetPermission.
182 * @param actions should be null.
183 *
184 * @throws NullPointerException if <code>name</code> is <code>null</code>.
185 * @throws IllegalArgumentException if <code>name</code> is empty.
186 */
187
188 public NetPermission(String name, String actions) {
189 super(name, actions);
190 }
191 }
|