private static bool GetProtectionDomains(List<java.security.ProtectionDomain> array, [email protected] callerID, StackTrace stack) { // first we have to skip all AccessController related frames, because we can be called from a doPrivileged implementation (not the privileged action) // in which case we should ignore the doPrivileged frame int skip = 0; for (; skip < stack.FrameCount; skip++) { Type type = stack.GetFrame(skip).GetMethod().DeclaringType; if (type != typeof(Java_java_security_AccessController) && type != typeof(java.security.AccessController)) { break; } } java.security.ProtectionDomain previous_protection_domain = null; for (int i = skip; i < stack.FrameCount; i++) { bool is_privileged = false; java.security.ProtectionDomain protection_domain; MethodBase method = stack.GetFrame(i).GetMethod(); if (method.DeclaringType == typeof(java.security.AccessController) && method.Name == "doPrivileged") { is_privileged = true; java.lang.Class caller = callerID.getCallerClass(); protection_domain = caller == null ? null : Java_java_lang_Class.getProtectionDomain0(caller); } else if (Java_sun_reflect_Reflection.IsHideFromStackWalk(method)) { continue; } else { protection_domain = GetProtectionDomainFromType(method.DeclaringType); } if (previous_protection_domain != protection_domain && protection_domain != null) { previous_protection_domain = protection_domain; array.Add(protection_domain); } if (is_privileged) { return true; } } return false; }
private static bool GetProtectionDomains(List<java.security.ProtectionDomain> array, [email protected] callerID, StackTrace stack) { java.security.ProtectionDomain previous_protection_domain = null; for (int i = 0; i < stack.FrameCount; i++) { bool is_privileged = false; java.security.ProtectionDomain protection_domain; MethodBase method = stack.GetFrame(i).GetMethod(); if (method.DeclaringType == typeof(java.security.AccessController) && method.Name == "doPrivileged") { is_privileged = true; java.lang.Class caller = callerID.getCallerClass(); protection_domain = caller == null ? null : Java_java_lang_Class.getProtectionDomain0(caller); } else { protection_domain = GetProtectionDomainFromType(method.DeclaringType); } if (previous_protection_domain != protection_domain && protection_domain != null) { previous_protection_domain = protection_domain; array.Add(protection_domain); } if (is_privileged) { return true; } } return false; }