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); }
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 java.security.ProtectionDomain GetProtectionDomainFromType(Type type) { if (type == null || type.Assembly == typeof(object).Assembly || type.Assembly == typeof(Java_java_security_AccessController).Assembly || type.Assembly == Java_java_lang_SecurityManager.jniAssembly || type.Assembly == typeof(java.lang.Thread).Assembly) { return(null); } TypeWrapper tw = ClassLoaderWrapper.GetWrapperFromType(type); if (tw != null) { return(Java_java_lang_Class.getProtectionDomain0(tw.ClassObject)); } return(null); }
public static object[][] getParameterAnnotationsImpl(object methodOrConstructor) { #if FIRST_PASS return(null); #else MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(methodOrConstructor); object[][] objAnn = mw.DeclaringType.GetParameterAnnotations(mw); if (objAnn == null) { return(null); } java.lang.annotation.Annotation[][] ann = new java.lang.annotation.Annotation[objAnn.Length][]; for (int i = 0; i < ann.Length; i++) { List <java.lang.annotation.Annotation> list = new List <java.lang.annotation.Annotation>(); foreach (object obj in objAnn[i]) { java.lang.annotation.Annotation a = obj as java.lang.annotation.Annotation; if (a != null) { list.Add(Java_java_lang_Class.FreezeOrWrapAttribute(a)); } else if (obj is IKVM.Attributes.DynamicAnnotationAttribute) { a = (java.lang.annotation.Annotation)JVM.NewAnnotation(mw.DeclaringType.GetClassLoader().GetJavaClassLoader(), ((IKVM.Attributes.DynamicAnnotationAttribute)obj).Definition); if (a != null) { list.Add(a); } } } ann[i] = list.ToArray(); } return(ann); #endif }
public static object getDeclaredAnnotationsImpl(object methodOrConstructor) { MethodWrapper mw = MethodWrapper.FromMethodOrConstructor(methodOrConstructor); return(Java_java_lang_Class.AnnotationsToMap(mw.DeclaringType.GetClassLoader(), mw.DeclaringType.GetMethodAnnotations(mw))); }
public static object getDeclaredAnnotationsImpl(java.lang.reflect.Field thisField) { FieldWrapper fw = FieldWrapper.FromField(thisField); return(Java_java_lang_Class.AnnotationsToMap(fw.DeclaringType.GetClassLoader(), fw.DeclaringType.GetFieldAnnotations(fw))); }
public static object declaredAnnotationsImpl(java.lang.reflect.Executable executable) { MethodWrapper mw = MethodWrapper.FromExecutable(executable); return(Java_java_lang_Class.AnnotationsToMap(mw.DeclaringType.GetClassLoader(), mw.DeclaringType.GetMethodAnnotations(mw))); }