/* * Reads in a Hashtable of Class/PermissionCollections and saves them in the * permsMap field. Reads in allPermission. */ //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException private void ReadObject(ObjectInputStream @in) { // Don't call defaultReadObject() // Read in serialized fields ObjectInputStream.GetField gfields = @in.ReadFields(); // Get allPermission AllPermission = (PermissionCollection)gfields.Get("allPermission", null); // Get permissions // writeObject writes a Hashtable<Class<?>, PermissionCollection> for // the perms key, so this cast is safe, unless the data is corrupt. //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.Hashtable<Class, PermissionCollection> perms = (java.util.Hashtable<Class, PermissionCollection>)gfields.get("perms", null); Dictionary <Class, PermissionCollection> perms = (Dictionary <Class, PermissionCollection>)gfields.Get("perms", null); PermsMap = new Dictionary <Class, PermissionCollection>(perms.Count * 2); //JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method: PermsMap.putAll(perms); // Set hasUnresolved UnresolvedPermissionCollection uc = (UnresolvedPermissionCollection)PermsMap[typeof(UnresolvedPermission)]; //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: HasUnresolved = (uc != null && uc.Elements().hasMoreElements()); }
/// <summary> /// Resolves any unresolved permissions of type p. /// </summary> /// <param name="p"> the type of unresolved permission to resolve /// </param> /// <returns> PermissionCollection containing the unresolved permissions, /// or null if there were no unresolved permissions of type p. /// </returns> private PermissionCollection GetUnresolvedPermissions(Permission p) { // Called from within synchronized method so permsMap doesn't need lock UnresolvedPermissionCollection uc = (UnresolvedPermissionCollection)PermsMap[typeof(UnresolvedPermission)]; // we have no unresolved permissions if uc is null if (uc == null) { return(null); } IList <UnresolvedPermission> unresolvedPerms = uc.GetUnresolvedPermissions(p); // we have no unresolved permissions of this type if unresolvedPerms is null if (unresolvedPerms == null) { return(null); } java.security.cert.Certificate[] certs = null; Object[] signers = p.GetType().Signers; int n = 0; if (signers != null) { for (int j = 0; j < signers.Length; j++) { if (signers[j] is java.security.cert.Certificate) { n++; } } certs = new java.security.cert.Certificate[n]; n = 0; for (int j = 0; j < signers.Length; j++) { if (signers[j] is java.security.cert.Certificate) { certs[n++] = (java.security.cert.Certificate)signers[j]; } } } PermissionCollection pc = null; lock (unresolvedPerms) { int len = unresolvedPerms.Count; for (int i = 0; i < len; i++) { UnresolvedPermission up = unresolvedPerms[i]; Permission perm = up.Resolve(p, certs); if (perm != null) { if (pc == null) { pc = p.NewPermissionCollection(); if (pc == null) { pc = new PermissionsHash(); } } pc.Add(perm); } } } return(pc); }