Path: blob/master/src/java.base/share/classes/javax/net/ssl/SSLPermission.java
41159 views
/*1* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.net.ssl;2627import java.security.*;2829/**30* This class is for various network permissions.31* An SSLPermission contains a name (also referred to as a "target name") but32* no actions list; you either have the named permission33* or you don't.34* <P>35* The target name is the name of the network permission (see below). The naming36* convention follows the hierarchical property naming convention.37* Also, an asterisk38* may appear at the end of the name, following a ".", or by itself, to39* signify a wildcard match. For example: "foo.*" and "*" signify a wildcard40* match, while "*foo" and "a*b" do not.41* <P>42* The following table lists all the possible SSLPermission target names,43* and for each provides a description of what the permission allows44* and a discussion of the risks of granting code the permission.45*46* <table class="striped">47* <caption style="display:none">permission name, what it allows, and associated risks</caption>48* <thead>49* <tr>50* <th scope="col">Permission Target Name</th>51* <th scope="col">What the Permission Allows</th>52* <th scope="col">Risks of Allowing this Permission</th>53* </tr>54* </thead>55*56* <tbody>57* <tr>58* <th scope="row">setHostnameVerifier</th>59* <td>The ability to set a callback which can decide whether to60* allow a mismatch between the host being connected to by61* an HttpsURLConnection and the common name field in62* server certificate.63* </td>64* <td>Malicious65* code can set a verifier that monitors host names visited by66* HttpsURLConnection requests or that allows server certificates67* with invalid common names.68* </td>69* </tr>70*71* <tr>72* <th scope="row">getSSLSessionContext</th>73* <td>The ability to get the SSLSessionContext of an SSLSession.74* </td>75* <td>Malicious code may monitor sessions which have been established76* with SSL peers or might invalidate sessions to slow down performance.77* </td>78* </tr>79*80* <tr>81* <th scope="row">setDefaultSSLContext</th>82* <td>The ability to set the default SSL context83* </td>84* <td>Malicious code can set a context that monitors the opening of85* connections or the plaintext data that is transmitted.86* </td>87* </tr>88*89* </tbody>90* </table>91*92* @see java.security.BasicPermission93* @see java.security.Permission94* @see java.security.Permissions95* @see java.security.PermissionCollection96* @see java.lang.SecurityManager97*98* @since 1.499* @author Marianne Mueller100* @author Roland Schemers101*/102103public final class SSLPermission extends BasicPermission {104105@java.io.Serial106private static final long serialVersionUID = -3456898025505876775L;107108/**109* Creates a new SSLPermission with the specified name.110* The name is the symbolic name of the SSLPermission, such as111* "setDefaultAuthenticator", etc. An asterisk112* may appear at the end of the name, following a ".", or by itself, to113* signify a wildcard match.114*115* @param name the name of the SSLPermission.116*117* @throws NullPointerException if <code>name</code> is null.118* @throws IllegalArgumentException if <code>name</code> is empty.119*/120121public SSLPermission(String name)122{123super(name);124}125126/**127* Creates a new SSLPermission object with the specified name.128* The name is the symbolic name of the SSLPermission, and the129* actions String is currently unused and should be null.130*131* @param name the name of the SSLPermission.132* @param actions ignored.133*134* @throws NullPointerException if <code>name</code> is null.135* @throws IllegalArgumentException if <code>name</code> is empty.136*/137138public SSLPermission(String name, String actions)139{140super(name, actions);141}142}143144145