Exemplo n.º 1
0
        /// <summary>
        /// Compile an expression from a parse tree node.
        /// </summary>
        /// <param name="parseTreeNode">An Irony parse tree node.</param>
        /// <param name="settings">Compilation settings.</param>
        /// <returns>An expression tree.</returns>
        public IExpression CompileParseTreeNode(ParseTreeNode parseTreeNode, BuilderSettings settings)
        {
            if (parseTreeNode == null)
            {
                throw new ArgumentNullException("parseTreeNode");
            }

            // Build the expression
            var builder = new StaticBuilder(EntityRepository, ScriptNameResolver);

            builder.Settings = settings;
            Expression result = builder.CompileTree(parseTreeNode);

            return(result);
        }
 public static T GetJWT <T>(this String jwt, Boolean verifySignature = true)
 {
     if (String.IsNullOrEmpty(jwt))
     {
         throw new Exception("Missing JWT in Payload.AccessToken");
     }
     else
     {
         var builder      = ((verifySignature) ? StaticBuilder.MustVerifySignature() : StaticBuilder);
         var decodedToken = builder.Decode(jwt);
         var apiUser      = JsonConvert.DeserializeObject <jwtWrapper <T> >(decodedToken);
         var expDate      = DateTimeOffset.FromUnixTimeSeconds(apiUser.exp);
         if (ReferenceEquals(apiUser, null) || (expDate < DateTime.UtcNow))
         {
             throw new AuthenticationException("Invalid jtw");
         }
         else
         {
             return(apiUser.user);
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sets the headers which will be added to all files served by the handler.
 /// </summary>
 /// <param name="headers">The headers.</param>
 /// <returns>Current instance.</returns>
 public static StaticBuilder SetCommonHeaders(params string[] headers)
 {
     return(StaticBuilder.StartWithCommonHeaders(headers));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Adds a folder. All files below that folder will be accessible.
 /// </summary>
 /// <param name="path">The path to the folder from the web application root.</param>
 /// <param name="alias">The public alias to use for the file.</param>
 /// <param name="headers">The headers for files below the folder.</param>
 /// <returns>Current instance.</returns>
 public static StaticBuilder AddFolderAlias(string path, string alias, params string[] headers)
 {
     return(StaticBuilder.StartWithFolder(path, alias, headers));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds a file.
 /// </summary>
 /// <param name="path">The path to the file from the web application root.</param>
 /// <param name="headers">The headers for the file.</param>
 /// <returns>Current instance.</returns>
 public static StaticBuilder AddFile(string path, params string[] headers)
 {
     return(StaticBuilder.StartWithFile(path, path, headers));
 }