processedPermissions = new Hashtable(); Vector exemptionMechanisms = new Vector(1); exemptionMechanisms.addElement(thisExemptionMechanism); processedPermissions.put(alg, exemptionMechanisms); return true; } if (processedPermissions.containsKey(CryptoAllPermission.ALG_NAME)) { return false; } Vector exemptionMechanisms; if (processedPermissions.containsKey(alg)) { exemptionMechanisms = (Vector)processedPermissions.get(alg); if (exemptionMechanisms.contains(thisExemptionMechanism)) { return false; } } else { exemptionMechanisms = new Vector(1); } exemptionMechanisms.addElement(thisExemptionMechanism); processedPermissions.put(alg, exemptionMechanisms); return true; } /** * Each grant entry in the policy configuration file is represented by a * GrantEntry object. <p> * * <p> * For example, the entry * <pre> * grant { * permission javax.crypto.CryptoPermission "DES", 56; * }; * * </pre> * is represented internally * <pre> * * pe = new CryptoPermissionEntry("javax.crypto.CryptoPermission", * "DES", 56); * * ge = new GrantEntry(); * * ge.add(pe); * * </pre> * * @see java.security.Permission * @see javax.crypto.CryptoPermission * @see javax.crypto.CryptoPermissions */ private static class GrantEntry { private Vector permissionEntries; GrantEntry() { permissionEntries = new Vector(); } void add(CryptoPermissionEntry pe) { permissionEntries.addElement(pe); } boolean remove(CryptoPermissionEntry pe) { return permissionEntries.removeElement(pe); } boolean contains(CryptoPermissionEntry pe) { return permissionEntries.contains(pe); } /** * Enumerate all the permission entries in this GrantEntry. */ Enumeration permissionElements(){ return permissionEntries.elements(); } } /** * Each crypto permission entry in the policy configuration file is * represented by a CryptoPermissionEntry object. <p> * * <p> * For example, the entry * <pre> * permission javax.crypto.CryptoPermission "DES", 56; * </pre> * is represented internally * <pre> * * pe = new CryptoPermissionEntry("javax.crypto.cryptoPermission", * "DES", 56); * </pre> * * @see java.security.Permissions * @see javax.crypto.CryptoPermission * @see javax.crypto.CryptoAllPermission */ private static class CryptoPermissionEntry { String cryptoPermission; String alg; String exemptionMechanism; int maxKeySize; boolean checkParam; AlgorithmParameterSpec algParamSpec; CryptoPermissionEntry() { // Set default values. maxKeySize = 0; alg = null; exemptionMechanism = null; checkParam = false; algParamSpec = null; } /** * Calculates a hash code value for the object. Objects * which are equal will also have the same hashcode. */ public int hashCode() { int retval = cryptoPermission.hashCode(); if (alg != null) retval ^= alg.hashCode(); if (exemptionMechanism != null) { retval ^= exemptionMechanism.hashCode(); } retval ^= maxKeySize; if (checkParam) retval ^= 100; if (algParamSpec != null) { retval ^= algParamSpec.hashCode(); } return retval; } public boolean equals(Object obj) { if (obj == this) return true; if (!(obj instanceof CryptoPermissionEntry)) return false; CryptoPermissionEntry that = (CryptoPermissionEntry) obj; if (this.cryptoPermission == null) { if (that.cryptoPermission != null) return false; } else { if (!this.cryptoPermission.equals( that.cryptoPermission)) return false; } if (this.alg == null) { if (that.alg != null) return false; } else { if (!this.alg.equalsIgnoreCase(that.alg)) return false; } if (!(this.maxKeySize == that.maxKeySize)) return false; if (this.checkParam != that.checkParam) return false; if (this.algParamSpec == null) { if (that.algParamSpec != null) return false; } else { if (!this.algParamSpec.equals(that.algParamSpec)) return false; } // everything matched -- the 2 objects are equal return true; } } static final class ParsingException extends GeneralSecurityException { private static final long serialVersionUID = 7147241245566588374L; /** * Constructs a ParsingException with the specified * detail message. * @param msg the detail message. */ ParsingException(String msg) { super(msg); } ParsingException(int line, String msg) { super("line " + line + ": " + msg); } ParsingException(int line, String expect, String actual) { super("line "+line+": expected '"+expect+"', found '"+actual+"'"); } }}Lines 501–707 of 707. Previous lines
processedPermissions = new Hashtable(); Vector exemptionMechanisms = new Vector(1); exemptionMechanisms.addElement(thisExemptionMechanism); processedPermissions.put(alg, exemptionMechanisms); return true; } if (processedPermissions.containsKey(CryptoAllPermission.ALG_NAME)) { return false; } Vector exemptionMechanisms; if (processedPermissions.containsKey(alg)) { exemptionMechanisms = (Vector)processedPermissions.get(alg); if (exemptionMechanisms.contains(thisExemptionMechanism)) { return false; } } else { exemptionMechanisms = new Vector(1); } exemptionMechanisms.addElement(thisExemptionMechanism); processedPermissions.put(alg, exemptionMechanisms); return true; } /** * Each grant entry in the policy configuration file is represented by a * GrantEntry object. <p> * * <p> * For example, the entry * <pre> * grant { * permission javax.crypto.CryptoPermission "DES", 56; * }; * * </pre> * is represented internally * <pre> * * pe = new CryptoPermissionEntry("javax.crypto.CryptoPermission", * "DES", 56); * * ge = new GrantEntry(); * * ge.add(pe); * * </pre> * * @see java.security.Permission * @see javax.crypto.CryptoPermission * @see javax.crypto.CryptoPermissions */ private static class GrantEntry { private Vector permissionEntries; GrantEntry() { permissionEntries = new Vector(); } void add(CryptoPermissionEntry pe) { permissionEntries.addElement(pe); } boolean remove(CryptoPermissionEntry pe) { return permissionEntries.removeElement(pe); } boolean contains(CryptoPermissionEntry pe) { return permissionEntries.contains(pe); } /** * Enumerate all the permission entries in this GrantEntry. */ Enumeration permissionElements(){ return permissionEntries.elements(); } } /** * Each crypto permission entry in the policy configuration file is * represented by a CryptoPermissionEntry object. <p> * * <p> * For example, the entry * <pre> * permission javax.crypto.CryptoPermission "DES", 56; * </pre> * is represented internally * <pre> * * pe = new CryptoPermissionEntry("javax.crypto.cryptoPermission", * "DES", 56); * </pre> * * @see java.security.Permissions * @see javax.crypto.CryptoPermission * @see javax.crypto.CryptoAllPermission */ private static class CryptoPermissionEntry { String cryptoPermission; String alg; String exemptionMechanism; int maxKeySize; boolean checkParam; AlgorithmParameterSpec algParamSpec; CryptoPermissionEntry() { // Set default values. maxKeySize = 0; alg = null; exemptionMechanism = null; checkParam = false; algParamSpec = null; } /** * Calculates a hash code value for the object. Objects * which are equal will also have the same hashcode. */ public int hashCode() { int retval = cryptoPermission.hashCode(); if (alg != null) retval ^= alg.hashCode(); if (exemptionMechanism != null) { retval ^= exemptionMechanism.hashCode(); } retval ^= maxKeySize; if (checkParam) retval ^= 100; if (algParamSpec != null) { retval ^= algParamSpec.hashCode(); } return retval; } public boolean equals(Object obj) { if (obj == this) return true; if (!(obj instanceof CryptoPermissionEntry)) return false; CryptoPermissionEntry that = (CryptoPermissionEntry) obj; if (this.cryptoPermission == null) { if (that.cryptoPermission != null) return false; } else { if (!this.cryptoPermission.equals( that.cryptoPermission)) return false; } if (this.alg == null) { if (that.alg != null) return false; } else { if (!this.alg.equalsIgnoreCase(that.alg)) return false; } if (!(this.maxKeySize == that.maxKeySize)) return false; if (this.checkParam != that.checkParam) return false; if (this.algParamSpec == null) { if (that.algParamSpec != null) return false; } else { if (!this.algParamSpec.equals(that.algParamSpec)) return false; } // everything matched -- the 2 objects are equal return true; } } static final class ParsingException extends GeneralSecurityException { private static final long serialVersionUID = 7147241245566588374L; /** * Constructs a ParsingException with the specified * detail message. * @param msg the detail message. */ ParsingException(String msg) { super(msg); } ParsingException(int line, String msg) { super("line " + line + ": " + msg); } ParsingException(int line, String expect, String actual) { super("line "+line+": expected '"+expect+"', found '"+actual+"'"); } } }