Home | History | Annotate | Download | only in security
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  * Copyright (c) 1997, 2013, 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.security;
     28 
     29 
     30 // Android-changed: Stubbed the implementation.  Android doesn't support SecurityManager.
     31 // See comments in java.lang.SecurityManager for details.
     32 /**
     33  * Legacy security code; do not use.
     34  */
     35 public final class AccessController {
     36 
     37     private AccessController() { }
     38 
     39     /**
     40      * Calls {@code action.run()}.
     41      */
     42     public static <T> T doPrivileged(PrivilegedAction<T> action) {
     43         return action.run();
     44     }
     45 
     46     /**
     47      * Calls {@code action.run()}.
     48      */
     49     public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) {
     50         return action.run();
     51     }
     52 
     53 
     54     /**
     55      * Calls {@code action.run()}.
     56      */
     57     public static <T> T doPrivileged(PrivilegedAction<T> action,
     58                                      AccessControlContext context) {
     59         return action.run();
     60     }
     61 
     62     /**
     63      * Calls {@code action.run()}.
     64      */
     65     public static <T> T
     66         doPrivileged(PrivilegedExceptionAction<T> action)
     67         throws PrivilegedActionException {
     68         try {
     69             return action.run();
     70         } catch (RuntimeException e) {
     71             throw e;
     72         } catch (Exception e) {
     73             throw new PrivilegedActionException(e);
     74         }
     75     }
     76 
     77 
     78     /**
     79      * Calls {@code action.run()}.
     80      */
     81     public static <T> T doPrivilegedWithCombiner
     82         (PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
     83         return doPrivileged(action);
     84     }
     85 
     86 
     87     /**
     88      * Calls {@code action.run()}.
     89      */
     90     public static <T> T
     91         doPrivileged(PrivilegedExceptionAction<T> action,
     92                      AccessControlContext context)
     93         throws PrivilegedActionException {
     94         return doPrivileged(action);
     95     }
     96 
     97     public static AccessControlContext getContext() {
     98         return new AccessControlContext(null);
     99     }
    100 
    101     public static void checkPermission(Permission perm)
    102                  throws AccessControlException {
    103     }
    104 }
    105