1 /* 2 * Copyright (c) 1997, 2015, 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.security; 27 28 import java.util.*; 29 import java.util.stream.Stream; 30 import java.util.stream.StreamSupport; 31 32 // Android-changed: Stubbed the implementation. Android doesn't support SecurityManager. 33 // See comments in java.lang.SecurityManager for details. 34 /** 35 * Android doesn't support {@link SecurityManager}. Do not use this class. 36 */ 37 38 public abstract class PermissionCollection implements java.io.Serializable { 39 40 /** 41 * Adds a permission object to the current collection of permission objects. 42 * 43 * @param permission the Permission object to add. 44 * 45 * @exception SecurityException - if this PermissionCollection object 46 * has been marked readonly 47 * @exception IllegalArgumentException - if this PermissionCollection 48 * object is a homogeneous collection and the permission 49 * is not of the correct type. 50 */ add(Permission permission)51 public abstract void add(Permission permission); 52 53 /** 54 * Checks to see if the specified permission is implied by 55 * the collection of Permission objects held in this PermissionCollection. 56 * 57 * @param permission the Permission object to compare. 58 * 59 * @return true if "permission" is implied by the permissions in 60 * the collection, false if not. 61 */ implies(Permission permission)62 public abstract boolean implies(Permission permission); 63 64 /** 65 * Returns an enumeration of all the Permission objects in the collection. 66 * 67 * @return an enumeration of all the Permissions. 68 */ elements()69 public abstract Enumeration<Permission> elements(); 70 setReadOnly()71 public void setReadOnly() { } 72 isReadOnly()73 public boolean isReadOnly() { return true; } 74 75 /** 76 * Returns a stream of all the Permission objects in the collection. 77 * 78 * <p> The collection should not be modified (see {@link #add}) during the 79 * execution of the terminal stream operation. Otherwise, the result of the 80 * terminal stream operation is undefined. 81 * 82 * @implSpec 83 * The default implementation creates a stream whose source is derived from 84 * the enumeration returned from a call to {@link #elements()}. 85 * 86 * @return a stream of all the Permissions. 87 * @since 9 88 * 89 * @hide 90 */ elementsAsStream()91 public Stream<Permission> elementsAsStream() { 92 // Android-changed: Stubbed the implementation. 93 /* 94 int characteristics = isReadOnly() 95 ? Spliterator.NONNULL | Spliterator.IMMUTABLE 96 : Spliterator.NONNULL; 97 return StreamSupport.stream( 98 Spliterators.spliteratorUnknownSize( 99 elements().asIterator(), characteristics), 100 false); 101 */ 102 return Stream.empty(); 103 } 104 105 } 106