private void GetPublicKeys() { if (hasPublicKeys) { _logger.Trace("We already have public keys, not loading them."); return; } _logger.Info("Getting PublicKeys"); var rsaPage = _website.LoadPage(_publicRsaKeyUrl); var rsaXmlObject = XDocument.Parse(rsaPage); var rsaXmlResponse = rsaXmlObject.Element("response"); _encpubkeyE = rsaXmlResponse.Element("encpubkeye").Value; _encpubkeyN = rsaXmlResponse.Element("encpubkeyn").Value; _logger.Trace("Public Key E: {0}, N: {1}", _encpubkeyE, _encpubkeyN.Remove(4) + "..." + _encpubkeyN.Substring(_encpubkeyN.Length - 4)); Jurassic.ScriptSource scriptSource = new FileScriptSource("js/main.js"); var jsResult = _engine.Evaluate(scriptSource); _engine.Evaluate(string.Format("g_encPublickey.e = '{0}'; g_encPublickey.n = '{1}';", _encpubkeyE, _encpubkeyN)); LoadHomePageWithCsrf(); hasPublicKeys = true; _logger.Info("Getting PublicKeys... Done!"); }
public virtual object Include(string scriptPath) { scriptPath = HttpContext.Current.Request.MapPath(scriptPath); var source = new FileScriptSource(scriptPath, System.Text.Encoding.Unicode); return(Engine.Evaluate(source)); }
public void AddPaths(string paths) { var parts = paths.Split(';'); foreach (var path in parts) { var fileScriptSource = new FileScriptSource(path); _fileScriptSources.Add(fileScriptSource); } }
/// <summary> /// Override of include intended to be used from .net /// </summary> /// <param name="scriptPath">The path to the code to execute.</param> /// <param name="scope">The containing scope.</param> /// <param name="thisObject">The value of the "this" object.</param> /// <param name="strictMode">Indicates if the statement is being called under strict mode code.</param> /// <returns></returns> public virtual object Include(string scriptPath, Scope scope, object thisObject, bool strictMode) { scriptPath = HttpContext.Current.Request.MapPath(scriptPath); var source = new FileScriptSource(scriptPath, System.Text.Encoding.Unicode); var sourceReader = source.GetReader(); var code = sourceReader.ReadToEnd(); return(Engine.Eval(code, scope, thisObject, strictMode)); }
private async Task GetPublicKeysAsync() { if (this.hasPublicKeys) { Console.WriteLine("We already have public keys, not loading them."); return; } Console.WriteLine("Getting PublicKeys"); var rsaPage = await this.client.GetStringAsync(publicRsaKeyUrl); var rsaXmlObject = XDocument.Parse(rsaPage); var rsaXmlResponse = rsaXmlObject.Element("response"); this.encpubkeyE = rsaXmlResponse.Element("encpubkeye").Value; this.encpubkeyN = rsaXmlResponse.Element("encpubkeyn").Value; Console.WriteLine( "Public Key E: {0}, N: {1}", this.encpubkeyE, this.encpubkeyN.Remove(4) + "..." + this.encpubkeyN.Substring(this.encpubkeyN.Length - 4)); var directory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var scriptSource = new FileScriptSource(Path.Combine(directory, "main.js")); var jsResult = this.engine.Evaluate(scriptSource); this.engine.Evaluate( string.Format( "g_encPublickey.e = '{0}'; g_encPublickey.n = '{1}';", this.encpubkeyE, this.encpubkeyN)); await this.LoadHomePageWithCsrfAsync(); this.hasPublicKeys = true; Console.WriteLine("Getting PublicKeys... Done!"); }
void IScriptSourceVisitor.Visit(FileScriptSource scriptSource) { _scripts.Add(new Script(scriptSource.Name, _scriptLoader.Load(scriptSource.FileName))); }