C++RAW #include "UnityPrefix.h" #include "Configuration/UnityConfigure.h" #include "Runtime/Scripting/ScriptingManager.h" #include "Runtime/Scripting/ScriptingExportUtility.h" #if UNITY_WEBPLAYER #include "PlatformDependent/CommonWebPlayer/ChainOfTrust.h" #endif CSRAW using System; using System.Security; namespace UnityEngine { CSRAW #if !UNITY_WINRT // Webplayer security related class. CLASS Security // Prefetch the webplayer socket security policy from a non-default port number. CSRAW static public bool PrefetchSocketPolicy(string ip, int atPort, int timeout=3000) { #if UNITY_EDITOR || UNITY_WEBPLAYER var method = GetUnityCrossDomainHelperMethod("PrefetchSocketPolicy"); var result = method.Invoke(null, new object[] { ip, atPort, timeout}); return (bool)result; #else return true; #endif } CONDITIONAL UNITY_WEBPLAYER || UNITY_EDITOR CSRAW [System.Security.SecuritySafeCritical] public static string GetChainOfTrustValue (string name) { var callingAssembly = System.Reflection.Assembly.GetCallingAssembly (); if (!_verifiedAssemblies.Contains(callingAssembly)) throw new ArgumentException("Calling assembly needs to be verified by Security.LoadAndVerifyAssembly"); var token = callingAssembly.GetName ().GetPublicKeyToken (); return GetChainOfTrustValueInternal (name, UnityEngine.Security.TokenToHex (token)); } CONDITIONAL UNITY_WEBPLAYER || UNITY_EDITOR CUSTOM private static string GetChainOfTrustValueInternal (string name, string publicKeyToken) { #if UNITY_WEBPLAYER std::string token = publicKeyToken.AsUTF8 (); std::string result = ChainOfTrust::GetValue(name,token); return scripting_string_new(result); #else return scripting_string_new(string()); #endif } END CSRAW #endif }