rev 49922 : 8202419: Avoid creating Permission constants early
Reviewed-by: TBD

   1 /*
   2  * Copyright (c) 2003, 2016, 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 sun.security.util;
  27 

  28 import java.net.SocketPermission;
  29 import java.net.NetPermission;
  30 import java.security.AccessController;
  31 import java.security.PrivilegedAction;
  32 import java.security.Permission;
  33 import java.security.BasicPermission;
  34 import java.security.SecurityPermission;
  35 import java.security.AllPermission;
  36 import sun.security.action.GetPropertyAction;
  37 
  38 /**
  39  * Permission constants and string constants used to create permissions
  40  * used throughout the JDK.
  41  */
  42 public final class SecurityConstants {
  43     // Cannot create one of these
  44     private SecurityConstants () {
  45     }
  46 
  47     // Commonly used string constants for permission actions used by
  48     // SecurityManager. Declare here for shortcut when checking permissions
  49     // in FilePermission, SocketPermission, and PropertyPermission.
  50 
  51     public static final String FILE_DELETE_ACTION = "delete";
  52     public static final String FILE_EXECUTE_ACTION = "execute";
  53     public static final String FILE_READ_ACTION = "read";
  54     public static final String FILE_WRITE_ACTION = "write";
  55     public static final String FILE_READLINK_ACTION = "readlink";
  56 
  57     public static final String SOCKET_RESOLVE_ACTION = "resolve";
  58     public static final String SOCKET_CONNECT_ACTION = "connect";
  59     public static final String SOCKET_LISTEN_ACTION = "listen";
  60     public static final String SOCKET_ACCEPT_ACTION = "accept";
  61     public static final String SOCKET_CONNECT_ACCEPT_ACTION = "connect,accept";
  62 
  63     public static final String PROPERTY_RW_ACTION = "read,write";
  64     public static final String PROPERTY_READ_ACTION = "read";
  65     public static final String PROPERTY_WRITE_ACTION = "write";
  66 
  67     // Permission constants used in the various checkPermission() calls in JDK.
  68 
  69     // java.lang.Class, java.lang.SecurityManager, java.lang.System,
  70     // java.net.URLConnection, java.security.AllPermission, java.security.Policy,
  71     // sun.security.provider.PolicyFile
  72     public static final AllPermission ALL_PERMISSION = new AllPermission();
  73 
  74     // java.net.URL
  75     public static final NetPermission SPECIFY_HANDLER_PERMISSION =
  76        new NetPermission("specifyStreamHandler");
  77 
  78     // java.net.ProxySelector
  79     public static final NetPermission SET_PROXYSELECTOR_PERMISSION =
  80        new NetPermission("setProxySelector");
  81 
  82     // java.net.ProxySelector
  83     public static final NetPermission GET_PROXYSELECTOR_PERMISSION =
  84        new NetPermission("getProxySelector");
  85 
  86     // java.net.CookieHandler
  87     public static final NetPermission SET_COOKIEHANDLER_PERMISSION =
  88        new NetPermission("setCookieHandler");
  89 
  90     // java.net.CookieHandler
  91     public static final NetPermission GET_COOKIEHANDLER_PERMISSION =
  92        new NetPermission("getCookieHandler");
  93 
  94     // java.net.ResponseCache
  95     public static final NetPermission SET_RESPONSECACHE_PERMISSION =
  96        new NetPermission("setResponseCache");
  97 
  98     // java.net.ResponseCache
  99     public static final NetPermission GET_RESPONSECACHE_PERMISSION =
 100        new NetPermission("getResponseCache");
 101 
 102     // java.lang.SecurityManager, sun.applet.AppletPanel
 103     public static final RuntimePermission CREATE_CLASSLOADER_PERMISSION =
 104         new RuntimePermission("createClassLoader");
 105 
 106     // java.lang.SecurityManager
 107     public static final RuntimePermission CHECK_MEMBER_ACCESS_PERMISSION =
 108         new RuntimePermission("accessDeclaredMembers");
 109 
 110     // java.lang.SecurityManager, sun.applet.AppletSecurity
 111     public static final RuntimePermission MODIFY_THREAD_PERMISSION =
 112         new RuntimePermission("modifyThread");
 113 
 114     // java.lang.SecurityManager, sun.applet.AppletSecurity
 115     public static final RuntimePermission MODIFY_THREADGROUP_PERMISSION =
 116         new RuntimePermission("modifyThreadGroup");
 117 
 118     // java.lang.Class
 119     public static final RuntimePermission GET_PD_PERMISSION =
 120         new RuntimePermission("getProtectionDomain");
 121 
 122     // java.lang.Class, java.lang.ClassLoader, java.lang.Thread
 123     public static final RuntimePermission GET_CLASSLOADER_PERMISSION =
 124         new RuntimePermission("getClassLoader");
 125 
 126     // java.lang.Thread
 127     public static final RuntimePermission STOP_THREAD_PERMISSION =
 128        new RuntimePermission("stopThread");
 129 
 130     // java.lang.Thread
 131     public static final RuntimePermission GET_STACK_TRACE_PERMISSION =
 132        new RuntimePermission("getStackTrace");
 133 




 134     // java.security.AccessControlContext
 135     public static final SecurityPermission CREATE_ACC_PERMISSION =
 136        new SecurityPermission("createAccessControlContext");
 137 
 138     // java.security.AccessControlContext
 139     public static final SecurityPermission GET_COMBINER_PERMISSION =
 140        new SecurityPermission("getDomainCombiner");
 141 
 142     // java.security.Policy, java.security.ProtectionDomain
 143     public static final SecurityPermission GET_POLICY_PERMISSION =
 144         new SecurityPermission ("getPolicy");
 145 
 146     // java.lang.SecurityManager
 147     public static final SocketPermission LOCAL_LISTEN_PERMISSION =
 148         new SocketPermission("localhost:0", SOCKET_LISTEN_ACTION);
 149 
 150     public static final String PROVIDER_VER =
 151         GetPropertyAction.privilegedGetProperty("java.specification.version");















 152 }
--- EOF ---