1 /* 2 * Copyright (c) 1997, 2004, 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.*" or "*" is valid, 44 * "*foo" or "a*b" is not valid. 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> 58 * <td>allowHttpTrace</td> 59 * <td>The ability to use the HTTP TRACE method in HttpURLConnection.</td> 60 * <td>Malicious code using HTTP TRACE could get access to security sensitive 61 * information in the HTTP headers (such as cookies) that it might not 62 * otherwise have access to.</td> 63 * </tr> 64 * 65 * <tr> 66 * <td>getCookieHandler</td> 67 * <td>The ability to get the cookie handler that processes highly 68 * security sensitive cookie information for an Http session.</td> 69 * <td>Malicious code can get a cookie handler to obtain access to 70 * highly security sensitive cookie information. Some web servers 71 * use cookies to save user private information such as access 72 * control information, or to track user browsing habit.</td> 73 * </tr> 74 * 75 * <tr> 76 * <td>getProxySelector</td> 77 * <td>The ability to get the proxy selector used to make decisions 78 * on which proxies to use when making network connections.</td> 79 * <td>Malicious code can get a ProxySelector to discover proxy 80 * hosts and ports on internal networks, which could then become 81 * targets for attack.</td> 82 * </tr> 83 * 84 * <tr> 85 * <td>getResponseCache</td> 86 * <td>The ability to get the response cache that provides 87 * access to a local response cache.</td> 88 * <td>Malicious code getting access to the local response cache 89 * could access security sensitive information.</td> 90 * </tr> 91 * 92 * <tr> 93 * <td>requestPasswordAuthentication</td> 94 * <td>The ability 95 * to ask the authenticator registered with the system for 96 * a password</td> 97 * <td>Malicious code may steal this password.</td> 98 * </tr> 99 * 100 * <tr> 101 * <td>setCookieHandler</td> 102 * <td>The ability to set the cookie handler that processes highly 103 * security sensitive cookie information for an Http session.</td> 104 * <td>Malicious code can set a cookie handler to obtain access to 105 * highly security sensitive cookie information. Some web servers 106 * use cookies to save user private information such as access 107 * control information, or to track user browsing habit.</td> 108 * </tr> 109 * 110 * <tr> 111 * <td>setDefaultAuthenticator</td> 112 * <td>The ability to set the 113 * way authentication information is retrieved when 114 * a proxy or HTTP server asks for authentication</td> 115 * <td>Malicious 116 * code can set an authenticator that monitors and steals user 117 * authentication input as it retrieves the input from the user.</td> 118 * </tr> 119 * 120 * <tr> 121 * <td>setProxySelector</td> 122 * <td>The ability to set the proxy selector used to make decisions 123 * on which proxies to use when making network connections.</td> 124 * <td>Malicious code can set a ProxySelector that directs network 125 * traffic to an arbitrary network host.</td> 126 * </tr> 127 * 128 * <tr> 129 * <td>setResponseCache</td> 130 * <td>The ability to set the response cache that provides access to 131 * a local response cache.</td> 132 * <td>Malicious code getting access to the local response cache 133 * could access security sensitive information, or create false 134 * entries in the response cache.</td> 135 * </tr> 136 * 137 * <tr> 138 * <td>specifyStreamHandler</td> 139 * <td>The ability 140 * to specify a stream handler when constructing a URL</td> 141 * <td>Malicious code may create a URL with resources that it would 142 normally not have access to (like file:/foo/fum/), specifying a 143 stream handler that gets the actual bytes from someplace it does 144 have access to. Thus it might be able to trick the system into 145 creating a ProtectionDomain/CodeSource for a class even though 146 that class really didn't come from that location.</td> 147 * </tr> 148 * </table> 149 * 150 * @see java.security.BasicPermission 151 * @see java.security.Permission 152 * @see java.security.Permissions 153 * @see java.security.PermissionCollection 154 * @see java.lang.SecurityManager 155 * 156 * 157 * @author Marianne Mueller 158 * @author Roland Schemers 159 */ 160 161 public final class NetPermission extends BasicPermission { 162 private static final long serialVersionUID = -8343910153355041693L; 163 164 /** 165 * Creates a new NetPermission with the specified name. 166 * The name is the symbolic name of the NetPermission, such as 167 * "setDefaultAuthenticator", etc. An asterisk 168 * may appear at the end of the name, following a ".", or by itself, to 169 * signify a wildcard match. 170 * 171 * @param name the name of the NetPermission. 172 * 173 * @throws NullPointerException if <code>name</code> is <code>null</code>. 174 * @throws IllegalArgumentException if <code>name</code> is empty. 175 */ 176 177 public NetPermission(String name) 178 { 179 super(name); 180 } 181 182 /** 183 * Creates a new NetPermission object with the specified name. 184 * The name is the symbolic name of the NetPermission, and the 185 * actions String is currently unused and should be null. 186 * 187 * @param name the name of the NetPermission. 188 * @param actions should be null. 189 * 190 * @throws NullPointerException if <code>name</code> is <code>null</code>. 191 * @throws IllegalArgumentException if <code>name</code> is empty. 192 */ 193 194 public NetPermission(String name, String actions) 195 { 196 super(name, actions); 197 } 198 }