CryptoPermissions.java revision 0
0N/A * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * This class contains CryptoPermission objects, organized into 0N/A * PermissionCollections according to algorithm names. 0N/A * <p>When the <code>add</code> method is called to add a 0N/A * CryptoPermission, the CryptoPermission is stored in the 0N/A * appropriate PermissionCollection. If no such 0N/A * collection exists yet, the algorithm name associated with 0N/A * the CryptoPermission object is 0N/A * determined and the <code>newPermissionCollection</code> method 0N/A * is called on the CryptoPermission or CryptoAllPermission class to 0N/A * create the PermissionCollection and add it to the Permissions object. 0N/A * @see javax.crypto.CryptoPermission 0N/A * @see java.security.PermissionCollection 0N/A * @see java.security.Permissions 0N/A * @author Sharon Liu 0N/A // This class is similar to java.security.Permissions 0N/A * Creates a new CryptoPermissions object containing 0N/A * no CryptoPermissionCollections. 0N/A * Populates the crypto policy from the specified 0N/A * InputStream into this CryptoPermissions object. 0N/A * @param in the InputStream to load from. 0N/A * @exception SecurityException if cannot load 0N/A * Returns true if this CryptoPermissions object doesn't 0N/A * contain any CryptoPermission objects; otherwise, returns 0N/A * Adds a permission object to the PermissionCollection for the 0N/A * algorithm returned by 0N/A * <code>(CryptoPermission)permission.getAlgorithm()</code>. 0N/A * This method creates 0N/A * a new PermissionCollection object (and adds the permission to it) 0N/A * if an appropriate collection does not yet exist. <p> 0N/A * @param permission the Permission object to add. 0N/A * @exception SecurityException if this CryptoPermissions object is 0N/A * marked as readonly. 0N/A "to a readonly CryptoPermissions " +
0N/A * Checks if this object's PermissionCollection for permissons 0N/A * of the specified permission's algorithm implies the specified 0N/A * permission. Returns true if the checking succeeded. 0N/A * @param permission the Permission object to check. 0N/A * @return true if "permission" is implied by the permissions 0N/A * in the PermissionCollection it belongs to, false if not. 0N/A * Returns an enumeration of all the Permission objects in all the 0N/A * PermissionCollections in this CryptoPermissions object. 0N/A * @return an enumeration of all the Permissions. 0N/A // go through each Permissions in the hash table 0N/A // and call their elements() function. 0N/A * Returns a CryptoPermissions object which 0N/A * represents the minimum of the specified 0N/A * CryptoPermissions object and this 0N/A * CryptoPermissions object. 0N/A * @param other the CryptoPermission 0N/A * object to compare with this object. 0N/A // For each algorithm in this CryptoPermissions, 0N/A // find out if there is anything we should add into 0N/A // The other CryptoPermissions 0N/A // doesn't allow this given 0N/A // algorithm at all. Just skip this 0N/A // If this CryptoPermissions doesn't 0N/A // have a wildcard, we are done. 0N/A // Deal with the algorithms only appear 0N/A // in the other CryptoPermissions. 0N/A * Get the minimum of the two given PermissionCollection 0N/A * <code>thisPc</code> and <code>thatPc</code>. 0N/A * @param thisPc the first given PermissionColloection 0N/A * @param thatPc the second given PermissionCollection 0N/A // For each CryptoPermission in 0N/A // thisPc object, do the following: 0N/A // 1) if this CryptoPermission is implied 0N/A // by thatPc, this CryptoPermission 0N/A // should be returned, and we can 0N/A // move on to check the next 0N/A // CryptoPermission in thisPc. 0N/A // 2) otherwise, we should return 0N/A // all CryptoPermissions in thatPc 0N/A // are implied by this CryptoPermission. 0N/A // Then we can move on to the 0N/A // next CryptoPermission in thisPc. 0N/A * Returns all the CryptoPermission objects in the given 0N/A * PermissionCollection object 0N/A * whose maximum keysize no greater than <code>maxKeySize</code>. 0N/A * For all CryptoPermission objects with a maximum keysize greater 0N/A * than <code>maxKeySize</code>, this method constructs a 0N/A * corresponding CryptoPermission object whose maximum keysize is 0N/A * set to <code>maxKeySize</code>, and includes that in the result. 0N/A * @param maxKeySize the given maximum key size. 0N/A * @param pc the given PermissionCollection object. 0N/A * Returns the PermissionCollection for the 0N/A * specified algorithm. Returns null if there 0N/A * isn't such a PermissionCollection. 0N/A * @param alg the algorithm name. 0N/A // If this CryptoPermissions includes CryptoAllPermission, 0N/A // we should return CryptoAllPermission. 0N/A // If there isn't a PermissionCollection for 0N/A // the given algorithm,we should return the 0N/A // PermissionCollection for the wildcard 0N/A * Returns the PermissionCollection for the algorithm 0N/A * associated with the specified CryptoPermission 0N/A * object. Creates such a PermissionCollection 0N/A * if such a PermissionCollection does not 0N/A * @param cryptoPerm the CryptoPermission object. 0N/A // if we enter with permissionimpl null, we know 0N/A // there are no more left. 0N/A // try to see if there are any left in the current one 0N/A // get the next one that has something in it... 0N/A // if it is null, we are done! 0N/A // hasMoreElements will update permset to the next permset 0N/A // with something in it...