Home | History | Annotate | Download | only in lang
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
      4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      5  *
      6  * This code is free software; you can redistribute it and/or modify it
      7  * under the terms of the GNU General Public License version 2 only, as
      8  * published by the Free Software Foundation.  Oracle designates this
      9  * particular file as subject to the "Classpath" exception as provided
     10  * by Oracle in the LICENSE file that accompanied this code.
     11  *
     12  * This code is distributed in the hope that it will be useful, but WITHOUT
     13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     15  * version 2 for more details (a copy is included in the LICENSE file that
     16  * accompanied this code).
     17  *
     18  * You should have received a copy of the GNU General Public License version
     19  * 2 along with this work; if not, write to the Free Software Foundation,
     20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     21  *
     22  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     23  * or visit www.oracle.com if you need additional information or have any
     24  * questions.
     25  */
     26 
     27 package java.lang;
     28 
     29 import java.security.*;
     30 import java.io.FileDescriptor;
     31 import java.net.InetAddress;
     32 
     33 // Android-changed: Stubbed the implementation.  Android doesn't support SecurityManager.
     34 // SecurityManager can only check access by Java code, so it can be bypassed by using
     35 // native code.  Applications should rely on Android permissions, process separation,
     36 // other other methods for security purposes.
     37 /**
     38  * Legacy security code; do not use.
     39  *
     40  * <p>Security managers do <i>not</i> provide a secure environment for
     41  * executing untrusted code and are unsupported on Android. Untrusted code
     42  * cannot be safely isolated within a single VM on Android. Application
     43  * developers can assume that there's no SecurityManager installed,
     44  * i.e. {@link java.lang.System#getSecurityManager()} will return null.
     45  */
     46 public
     47 class SecurityManager {
     48 
     49     /**
     50      * @deprecated Use {@link #checkPermission} instead.
     51      */
     52     @Deprecated
     53     protected boolean inCheck;
     54 
     55     /**
     56      * @deprecated Use {@link #checkPermission} instead.
     57      */
     58     @Deprecated
     59     public boolean getInCheck() {
     60         return inCheck;
     61     }
     62 
     63     public SecurityManager() {
     64 
     65     }
     66 
     67     protected Class[] getClassContext() {
     68         return null;
     69     }
     70 
     71     /**
     72      * @deprecated Use {@link #checkPermission} instead.
     73      */
     74     @Deprecated
     75     protected ClassLoader currentClassLoader()
     76     {
     77         return null;
     78     }
     79 
     80     /**
     81      * @deprecated Use {@link #checkPermission} instead.
     82      */
     83     @Deprecated
     84     protected Class<?> currentLoadedClass() {
     85         return null;
     86     }
     87 
     88     /**
     89      * @deprecated Use {@link #checkPermission} instead.
     90      */
     91     @Deprecated
     92     protected int classDepth(String name) {
     93         return -1;
     94     }
     95 
     96     /**
     97      * @deprecated Use {@link #checkPermission} instead.
     98      */
     99     @Deprecated
    100     protected int classLoaderDepth()
    101     {
    102         return -1;
    103     }
    104 
    105     /**
    106      * @deprecated Use {@link #checkPermission} instead.
    107      */
    108     @Deprecated
    109     protected boolean inClass(String name) {
    110         return false;
    111     }
    112 
    113     /**
    114      * @deprecated Use {@link #checkPermission} instead.
    115      */
    116     @Deprecated
    117     protected boolean inClassLoader() {
    118         return false;
    119     }
    120 
    121     public Object getSecurityContext() {
    122         return null;
    123     }
    124 
    125     public void checkPermission(Permission perm) {
    126 
    127     }
    128 
    129     public void checkPermission(Permission perm, Object context) {
    130 
    131     }
    132 
    133     public void checkCreateClassLoader() {
    134 
    135     }
    136 
    137     public void checkAccess(Thread t) { }
    138 
    139     public void checkAccess(ThreadGroup g) { }
    140 
    141     public void checkExit(int status) { }
    142 
    143     public void checkExec(String cmd) { }
    144 
    145     public void checkLink(String lib) { }
    146 
    147     public void checkRead(FileDescriptor fd) { }
    148 
    149     public void checkRead(String file) { }
    150 
    151     public void checkRead(String file, Object context) { }
    152 
    153     public void checkWrite(FileDescriptor fd) { }
    154 
    155     public void checkWrite(String file) { }
    156 
    157     public void checkDelete(String file) { }
    158 
    159     public void checkConnect(String host, int port) { }
    160 
    161     public void checkConnect(String host, int port, Object context) { }
    162 
    163     public void checkListen(int port) { }
    164 
    165     public void checkAccept(String host, int port) { }
    166 
    167     public void checkMulticast(InetAddress maddr) { }
    168 
    169     /**
    170      * @deprecated use {@link #checkMulticast(java.net.InetAddress)} instead.
    171      */
    172     @Deprecated
    173     public void checkMulticast(InetAddress maddr, byte ttl) { }
    174 
    175     public void checkPropertiesAccess() { }
    176 
    177     public void checkPropertyAccess(String key) { }
    178 
    179     public boolean checkTopLevelWindow(Object window) {
    180         return true;
    181     }
    182 
    183     public void checkPrintJobAccess() { }
    184 
    185     public void checkSystemClipboardAccess() { }
    186 
    187     public void checkAwtEventQueueAccess() { }
    188 
    189     public void checkPackageAccess(String pkg) { }
    190 
    191     public void checkPackageDefinition(String pkg) { }
    192 
    193     public void checkSetFactory() { }
    194 
    195     public void checkMemberAccess(Class<?> clazz, int which) { }
    196 
    197     public void checkSecurityAccess(String target) { }
    198 
    199     /**
    200      * Returns the current thread's thread group.
    201      */
    202     public ThreadGroup getThreadGroup() {
    203         return Thread.currentThread().getThreadGroup();
    204     }
    205 
    206 }
    207