예제 #1
0
        /// <summary>
        /// Loads page
        /// </summary>
        /// <param name="sender">sender information</param>
        /// <param name="e">event information</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext.Current.Response.AddHeader("p3p",
                                                   "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");

            Authorizer auth = new Authorizer
            {
                Perms = "publish_stream"
            };

            if (auth.Authorize())
            {
                FacebookLayer fb = new FacebookLayer(auth);
                if (Request.QueryString["action"] != null)
                {
                    this.LocationActions(Request.QueryString, fb);
                }

                this.ShowFacebookContent(fb);
            }
            else
            {
                Response.Redirect("~/Login.aspx?returnUrl=" + HttpUtility.UrlEncode(Request.Url.PathAndQuery));
            }
        }
예제 #2
0
        public async Task <IActionResult> Update(
            string token,
            string postId,
            [FromBody] Post postIn)
        {
            var post = await _data.GetPostAsync(postId);

            var blog = await _blogs.Get(token);

            if (post == null || post.BlogUrl != blog.BlogUrl)
            {
                return(NotFound());
            }

            var auth = await Authorizer.Authorize(token, blog.Email, _blogs);

            if (!auth)
            {
                return(BadRequest());
            }

            await _data.Update(postId, postIn);

            return(NoContent());
        }
예제 #3
0
        /*
        /// <summary>
        /// Initializes a new instance of the FacebookLayer class
        /// </summary>
        public FacebookLayer()
        {
            this.Auth = new Authorizer();

            if (this.Auth.Authorize())
            {
                this.FbClient = new FacebookClient(CurrentSession.AccessToken);
                this.User = new FacebookUser();
                try
                {
                    var me = (IDictionary<string, object>) this.FbClient.Get("me");

                    this.User.FacebookId = (string) me["id"];
                    this.User.FacebookName = (string) me["first_name"];
                }
                catch
                {
                    this.IsAccessTokenValid = false;
                    return;
                }

                this.IsAccessTokenValid = true;
                IDictionary<string, object> friendsData = (IDictionary<string, object>) this.FbClient.Get("me/friends");
                this.facebookData = new FacebookData(this.User, friendsData);
                this.SortedFriends = this.facebookData.SortedFriends;
            }
        }
        */
        /// <summary>
        /// Initializes a new instance of the FacebookLayer class using authorization
        /// </summary>
        /// <param name="auth">authorization instance</param>
        public FacebookLayer(Authorizer auth)
        {
            this.Auth = auth;

            if (auth.Authorize())
            {
                this.FbClient = new FacebookClient(CurrentSession.AccessToken);
                this.User = new FacebookUser();
                try
                {
                    var me = (IDictionary<string, object>) this.FbClient.Get("me");

                    this.User.FacebookId = (string) me["id"];
                    this.User.FacebookName = (string) me["first_name"];
                }
                catch
                {
                    this.IsAccessTokenValid = false;
                    return;
                }

                this.IsAccessTokenValid = true;
                IDictionary<string, object> friendsData = (IDictionary<string, object>)FbClient.Get("me/friends");
                facebookData = new FacebookData(User, (IList<object>)friendsData["data"]);
            }
        }
예제 #4
0
        /// <summary>
        /// Loads page
        /// </summary>
        /// <param name="sender">sender information</param>
        /// <param name="e">event information</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext.Current.Response.AddHeader("p3p",
                                                   "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");

            Authorizer auth = new Authorizer
                                  {
                                      Perms = "publish_stream"
                                  };

            if (auth.Authorize())
            {
                FacebookLayer fb = new FacebookLayer(auth);
                if (Request.QueryString["action"] != null)
                {
                    this.LocationActions(Request.QueryString, fb);
                }

                this.ShowFacebookContent(fb);
            }
            else
            {
                Response.Redirect("~/Login.aspx?returnUrl=" + HttpUtility.UrlEncode(Request.Url.PathAndQuery));
            }
        }
예제 #5
0
/*
 *      /// <summary>
 *      /// Initializes a new instance of the FacebookLayer class
 *      /// </summary>
 *      public FacebookLayer()
 *      {
 *          this.Auth = new Authorizer();
 *
 *          if (this.Auth.Authorize())
 *          {
 *              this.FbClient = new FacebookClient(CurrentSession.AccessToken);
 *              this.User = new FacebookUser();
 *              try
 *              {
 *                  var me = (IDictionary<string, object>) this.FbClient.Get("me");
 *
 *                  this.User.FacebookId = (string) me["id"];
 *                  this.User.FacebookName = (string) me["first_name"];
 *              }
 *              catch
 *              {
 *                  this.IsAccessTokenValid = false;
 *                  return;
 *              }
 *
 *              this.IsAccessTokenValid = true;
 *              IDictionary<string, object> friendsData = (IDictionary<string, object>) this.FbClient.Get("me/friends");
 *              this.facebookData = new FacebookData(this.User, friendsData);
 *              this.SortedFriends = this.facebookData.SortedFriends;
 *          }
 *      }
 */

        /// <summary>
        /// Initializes a new instance of the FacebookLayer class using authorization
        /// </summary>
        /// <param name="auth">authorization instance</param>
        public FacebookLayer(Authorizer auth)
        {
            this.Auth = auth;

            if (auth.Authorize())
            {
                this.FbClient = new FacebookClient(CurrentSession.AccessToken);
                this.User     = new FacebookUser();
                try
                {
                    var me = (IDictionary <string, object>) this.FbClient.Get("me");

                    this.User.FacebookId   = (string)me["id"];
                    this.User.FacebookName = (string)me["first_name"];
                }
                catch
                {
                    this.IsAccessTokenValid = false;
                    return;
                }

                this.IsAccessTokenValid = true;
                IDictionary <string, object> friendsData = (IDictionary <string, object>)FbClient.Get("me/friends");
                facebookData = new FacebookData(User, (IList <object>)friendsData["data"]);
            }
        }
예제 #6
0
        public void TestAuthorizer()
        {
            string consumerKey    = "egjNlASi3o3r4nriynMAnlTjE";
            string consumerSecret = "fhuBNzdwrs1Tt9NrkzCvYJbzQeCr5WvIGvHPOG95lod9SVJ7Qd";

            Token token = Authorizer.Authorize(consumerKey, consumerSecret);
        }
예제 #7
0
        public async Task <ActionResult <Blog> > Authorize(string token, string email)
        {
            var auth = await Authorizer.Authorize(token, email, _data);

            if (auth)
            {
                return(await _data.Get(token));
            }

            return(BadRequest());
        }
예제 #8
0
        public async Task <User> CreateUser(User newUser)
        {
            Authorizer authorizer = new Authorizer();
            Token      token      = new Token();

            token = await authorizer.Authorize();

            UserService userService = new UserService(token);
            User        user        = await userService.CreateObject(newUser);

            return(user);
        }
예제 #9
0
        public async Task <Term> UpdateTerm(Term newterm)
        {
            Authorizer authorizer = new Authorizer();
            Token      token      = new Token();

            token = await authorizer.Authorize();

            TermService termService = new TermService(token);
            Term        term        = await termService.UpdateObject(newterm);

            return(term);
        }
예제 #10
0
        public async Task <DataTable> Getuser()
        {
            Authorizer authorizer = new Authorizer();
            Token      token      = new Token();

            token = await authorizer.Authorize();

            UserService userService = new UserService(token);
            DataTable   user        = await userService.ReadAllObject();

            return(user);
        }
예제 #11
0
        public async Task <Course> UpdateCourse(Course newcourses)
        {
            Authorizer authorizer = new Authorizer();
            Token      token      = new Token();

            token = await authorizer.Authorize();

            CourseService termService = new CourseService(token);
            Course        course      = await termService.UpdateObject(newcourses);

            return(course);
        }
예제 #12
0
        private void _Authorize(string login, string password, string captcha_key)
        {
            GlobalIndicator.Instance.Text      = AppResources.Connecting;
            GlobalIndicator.Instance.IsLoading = true;

            SignInButton.IsEnabled = false;
            SignUpButton.IsEnabled = false;

            _settings.Password = password;
            _settings.UserName = login;

            Authorizer auth = new Authorizer();

            if (!string.IsNullOrEmpty(captcha_key))
            {
                auth.Authorize(login, password, _captchaSid, captcha_key, _SignInResult);
            }
            else
            {
                auth.Authorize(login, password, null, null, _SignInResult);
            }
        }
예제 #13
0
 /// <summary>
 /// AccessToken command's action
 /// </summary>
 private void AccessToken()
 {
     try
     {
         _tweetSearcher.Token = Authorizer.Authorize(ConsumerKey, ConsumerSecret);
     }
     catch (Exception e)
     {
     }
     finally
     {
         TokenAccessRequested?.Invoke();
         RequestClose?.Invoke(this, EventArgs.Empty);
         RequestClose = null;
     }
 }
예제 #14
0
        private void OnRequest(Task <HttpListenerContext> task)
        {
            WebContext wc = null;

            try {
                StartWaitNextRequest();
                wc = task.Result;
                if (CheckInvalidStartupConditions(wc))
                {
                    return;
                }
                PrepareForCrossSiteScripting(task);
                if (CheckOptionsMethodIsCalled(task))
                {
                    return;
                }
                if (wc.Request.ContentLength > Config.MaxRequestSize)
                {
                    throw    new Exception("Exceed max request size");
                }
                CopyCookies(wc);
                Authenticator.Authenticate(wc.Request, wc.Response);
                if (Applications.Application.HasCurrent)
                {
                    Applications.Application.Current.Principal.SetCurrentUser(wc.User);
                }
                var authorization = Authorizer.Authorize(wc.Request);

                if (BeforeHandlerProcessed(wc, authorization))
                {
                    if (!wc.Response.WasClosed)
                    {
                        wc.Response.Close();
                    }
                    return;
                }

                new HostRequestHandler(this, wc).Execute();
            }
            catch (Exception ex) {
                if (!wc.Response.WasClosed)
                {
                    wc.Finish("some error occured " + ex, status: 500);
                }
            }
        }
예제 #15
0
        void Authorize(object sender, RoutedEventArgs e)
        {
            var authorizer = new Authorizer();

            authorizer.Request()
            .Subscribe(x => Process.Start(x));

            var window = new AuthorizeWindow();

            if (window.ShowDialog() == true)
            {
                authorizer.Authorize(window.PinCode)
                .SelectMany(_ => Twitter.UserName())
                .Do(x => Setting.Name = x)
                .Do(_ => Twitter.ReAuthorize())
                .Subscribe(x => Dispatcher.Invoke(() => viewModel.Authorize(x)));
            }
        }
예제 #16
0
        public void AuthorizeCausesCheckAuthorizeReturnTrue()
        {
            var accountStub = new Mock <Account>();

            accountStub.Setup(acc => acc.UserId).Returns(3);
            accountStub.Setup(acc => acc.Email).Returns("[email protected]");
            accountStub.Setup(acc => acc.PasswordHash).Returns("Smth");
            var userRepoMock = new Mock <IUserRepository>();

            userRepoMock
            .Setup(mock => mock.GetAllAccounts(It.IsAny <Func <Account, bool> >()))
            .Returns(new List <Account> {
                accountStub.Object
            });
            var authorizer = new Authorizer(TimeSpan.FromHours(10), userRepoMock.Object);

            var token        = authorizer.Authorize(accountStub.Object.Email, accountStub.Object.PasswordHash);
            var isAuthorized = authorizer.CheckAuthorized(token.Token, accountStub.Object.UserId);

            Assert.IsTrue(isAuthorized);
        }
예제 #17
0
        private async void ExecuteAddAccountCommand()
        {
            PinEntryCancelled = new CancellationTokenSource();

            var result = await Authorizer.Authorize(DisplayPinPage, GetPinFromUser, PinEntryCancelled.Token);

            var accountData = result?.Data;

            if (accountData != null)
            {
                if (ContextList.Contexts.All(c => c.UserId != accountData.UserId))
                {
                    using (var ctx = new TwitterContext(result.Auth))
                    {
                        var twitterUser =
                            await
                            ctx.User.Where(tw => tw.Type == UserType.Show && tw.UserID == accountData.UserId && tw.IncludeEntities == false)
                            .SingleOrDefaultAsync();

                        accountData.ImageUrl = twitterUser.ProfileImageUrlHttps.Replace("_normal", "");
                    }

                    if (ContextList.Contexts.Count == 0)
                    {
                        accountData.IsDefault = true;
                    }
                    ContextList.AddContext(accountData);

                    var newColumns = await ViewServiceRepository.SelectAccountColumnTypes(accountData.UserId)
                                     ?? new ColumnDefinition[0];

                    if (newColumns.Any())
                    {
                        ColumnList.AddColumns(newColumns);
                    }
                }
            }

            Close(true);
        }
예제 #18
0
        public async Task <ActionResult <Post> > CreatePost(
            string token, [FromBody] Post post)
        {
            // Contains authorization condition.
            var blog = await _blogs.Get(token);

            if (blog == null)
            {
                return(NotFound());
            }

            var auth = await Authorizer.Authorize(token, blog.Email, _blogs);

            if (!auth)
            {
                return(BadRequest());
            }

            var posted = await _data.Create(post);

            return(posted);
        }
예제 #19
0
 public bool AuthorizedFor(Permission permission)
 {
     return(Authorizer.Authorize(permission));
 }
예제 #20
0
        public override void Execute()
        {
            #line 5 "..\..\Views\Shared\_AdminLayout.cshtml"

            Style.Reqiured("bootStrap").AtHead();
            Style.Reqiured("admin").AtHead();
            Script.Reqiured("admin").AtFoot();
            var plugs = ServiceLocator.Current.GetAllInstances <PluginBase>();
            List <AdminMenu> menus = new List <AdminMenu>();
            plugs.Each(m =>
            {
                var menu = m.AdminMenu();
                if (menu != null)
                {
                    var adminMenus = menu as AdminMenu[] ?? menu.ToArray();
                    menus.AddRange(adminMenus);
                }
            });
            if (ApplicationContext.CurrentUser == null)
            {
                FormsAuthentication.SignOut();
                Response.Redirect("~/");
                return;
            }


            #line default
            #line hidden
            WriteLiteral("\r\n<!DOCTYPE html>\r\n<html");

            WriteLiteral(" lang=\"zh\"");

            WriteLiteral(">\r\n<head>\r\n    <meta");

            WriteLiteral(" http-equiv=\"Content-Type\"");

            WriteLiteral(" content=\"text/html; charset=utf-8\"");

            WriteLiteral(" />\r\n    <meta");

            WriteLiteral(" charset=\"utf-8\"");

            WriteLiteral(" />\r\n    <title>ZKEASOFT</title>\r\n    <link");

            WriteAttribute("href", Tuple.Create(" href=\"", 963), Tuple.Create("\"", 983)
                           , Tuple.Create(Tuple.Create("", 970), Tuple.Create <System.Object, System.Int32>(Href("~/favicon.ico")
                                                                                                            , 970), false)
                           );

            WriteLiteral(" rel=\"shortcut icon\"");

            WriteLiteral(" type=\"image/x-icon\"");

            WriteLiteral(" />\r\n    <meta");

            WriteLiteral(" name=\"viewport\"");

            WriteLiteral(" content=\"width=device-width\"");

            WriteLiteral(" />\r\n");

            WriteLiteral("    ");


            #line 35 "..\..\Views\Shared\_AdminLayout.cshtml"
            Write(StyleAtHead());


            #line default
            #line hidden
            WriteLiteral("\r\n");

            WriteLiteral("    ");


            #line 36 "..\..\Views\Shared\_AdminLayout.cshtml"
            Write(ScriptAtHead());


            #line default
            #line hidden
            WriteLiteral("\r\n</head>\r\n<body>\r\n\r\n    <div");

            WriteLiteral(" id=\"wrap\"");

            WriteLiteral(" class=\"container-fluid\"");

            WriteLiteral(">\r\n        <nav");

            WriteLiteral(" class=\"navbar navbar-inverse navbar-fixed-top\"");

            WriteLiteral(">\r\n            <div");

            WriteLiteral(" class=\"container-fluid\"");

            WriteLiteral(">\r\n                <div");

            WriteLiteral(" class=\"navbar-header\"");

            WriteLiteral(">\r\n                    <a");

            WriteLiteral(" href=\"http://www.zkea.net\"");

            WriteLiteral(" target=\"_blank\"");

            WriteLiteral(" class=\"navbar-brand\"");

            WriteLiteral(" title=\"ZKEASOFT\"");

            WriteLiteral(">\r\n                        <img");

            WriteAttribute("src", Tuple.Create(" src=\"", 1477), Tuple.Create("\"", 1530)
                           , Tuple.Create(Tuple.Create("", 1483), Tuple.Create <System.Object, System.Int32>(Href("~/Content/themes/Admin/images/logo_zkea_min.png")
                                                                                                             , 1483), false)
                           );

            WriteLiteral(" alt=\"\"");

            WriteLiteral(" style=\"height: 20px;\"");

            WriteLiteral(" />\r\n                    </a>\r\n                </div>\r\n                <div");

            WriteLiteral(" class=\"collapse navbar-collapse\"");

            WriteLiteral(">\r\n                    <p");

            WriteLiteral(" class=\"navbar-text\"");

            WriteLiteral(">\r\n");

            WriteLiteral("                        ");


            #line 50 "..\..\Views\Shared\_AdminLayout.cshtml"
            Write(Version.CurrentVersion);


            #line default
            #line hidden
            WriteLiteral("\r\n                    </p>\r\n                    <ul");

            WriteLiteral(" class=\"nav navbar-nav\"");

            WriteLiteral(">\r\n                        <li>\r\n                            <a");

            WriteAttribute("href", Tuple.Create(" href=\"", 1900), Tuple.Create("\"", 1909)
                           , Tuple.Create(Tuple.Create("", 1907), Tuple.Create <System.Object, System.Int32>(Href("~/")
                                                                                                             , 1907), false)
                           );

            WriteLiteral(">查看站点</a>\r\n                        </li>\r\n                        <li>\r\n         " +
                         "                   <a");

            WriteLiteral(" href=\"http://www.zkea.net/zkeacms/videos\"");

            WriteLiteral(" target=\"_blank\"");

            WriteLiteral(">演示视频</a>\r\n                        </li>\r\n                        <li>\r\n         " +
                         "                   <a");

            WriteLiteral(" href=\"http://www.zkea.net/zkeacms/templates\"");

            WriteLiteral(" target=\"_blank\"");

            WriteLiteral(">下载模板</a>\r\n                        </li>\r\n                        <li>\r\n         " +
                         "                   <a");

            WriteLiteral(" href=\"http://www.zkea.net/zkeacms/theme\"");

            WriteLiteral(" target=\"_blank\"");

            WriteLiteral(">下载主题</a>\r\n                        </li>\r\n                        <li>\r\n         " +
                         "                   <a");

            WriteLiteral(" href=\"http://www.zkea.net/zkeacms/extend\"");

            WriteLiteral(" target=\"_blank\"");

            WriteLiteral(">扩展插件</a>\r\n                        </li>\r\n                        <li>\r\n         " +
                         "                   <a");

            WriteLiteral(" href=\"http://www.zkea.net/freewebsite/build\"");

            WriteLiteral(" target=\"_blank\"");

            WriteLiteral(">云建站</a>\r\n                        </li>\r\n                    </ul>\r\n             " +
                         "       <ul");

            WriteLiteral(" class=\"nav navbar-nav navbar-right\"");

            WriteLiteral(">\r\n                        <li>\r\n                            <a");

            WriteLiteral(" href=\"http://www.zkea.net/zkeacms/donate\"");

            WriteLiteral(" target=\"_blank\"");

            WriteLiteral(">\r\n                                <i");

            WriteLiteral(" class=\"glyphicon glyphicon-usd\"");

            WriteLiteral("></i>\r\n                                赞助\r\n                            </a>\r\n    " +
                         "                    </li>\r\n                        <li>\r\n                       " +
                         "     <a");

            WriteAttribute("href", Tuple.Create(" href=\"", 3200), Tuple.Create("\"", 3239)

            #line 80 "..\..\Views\Shared\_AdminLayout.cshtml"
                           , Tuple.Create(Tuple.Create("", 3207), Tuple.Create <System.Object, System.Int32>(Url.Action("Logout", "Account")

            #line default
            #line hidden
                                                                                                             , 3207), false)
                           );

            WriteLiteral(" target=\"_self\"");

            WriteLiteral(" title=\"退出\"");

            WriteLiteral(">\r\n                                <i");

            WriteLiteral(" class=\"glyphicon glyphicon-off\"");

            WriteLiteral("></i>\r\n                                退出\r\n                            </a>\r\n    " +
                         "                    </li>\r\n                    </ul>\r\n                </div>\r\n\r\n" +
                         "            </div>\r\n        </nav>\r\n        <nav");

            WriteLiteral(" class=\"navbar navbar-inverse navbar-fixed-left\"");

            WriteLiteral(">\r\n            <div");

            WriteLiteral(" class=\"\"");

            WriteLiteral(">\r\n                <div");

            WriteLiteral(" class=\"navbar-header\"");

            WriteLiteral(">\r\n                    <div");

            WriteLiteral(" class=\"userInfo\"");

            WriteLiteral(">\r\n                        <img");

            WriteAttribute("src", Tuple.Create(" src=\"", 3740), Tuple.Create("\"", 3803)

            #line 94 "..\..\Views\Shared\_AdminLayout.cshtml"
                           , Tuple.Create(Tuple.Create("", 3746), Tuple.Create <System.Object, System.Int32>(Url.PathContent(ApplicationContext.CurrentUser.PhotoUrl)

            #line default
            #line hidden
                                                                                                             , 3746), false)
                           );

            WriteLiteral(" class=\"img-circle\"");

            WriteLiteral(" />\r\n                        <strong>");


            #line 95 "..\..\Views\Shared\_AdminLayout.cshtml"
            Write(ApplicationContext.CurrentUser.UserName);


            #line default
            #line hidden
            WriteLiteral("</strong>\r\n                    </div>\r\n                </div>\r\n                <u" +
                         "l");

            WriteLiteral(" id=\"main-menu\"");

            WriteLiteral(" class=\"nav navbar-nav\"");

            WriteLiteral(">\r\n");


            #line 99 "..\..\Views\Shared\_AdminLayout.cshtml"


            #line default
            #line hidden

            #line 99 "..\..\Views\Shared\_AdminLayout.cshtml"
            foreach (AdminMenu menu in menus.Where(m => Authorizer.Authorize(m.PermissionKey)).OrderBy(m => m.Order))
            {
                if (menu.Children != null && menu.Children.Any())
                {
                    if (menu.Children.Any(m => Authorizer.Authorize(m.PermissionKey)))
                    {
            #line default
            #line hidden
                        WriteLiteral("                                <li");

                        WriteLiteral(" class=\"accordion-group\"");

                        WriteLiteral(">\r\n                                    <a");

                        WriteLiteral(" class=\"b_9FDDF6 group-item\"");

                        WriteLiteral(" href=\"#\"");

                        WriteLiteral(">\r\n                                        <i");

                        WriteAttribute("class", Tuple.Create(" class=\"", 4585), Tuple.Create("\"", 4613)
                                       , Tuple.Create(Tuple.Create("", 4593), Tuple.Create("glyphicon", 4593), true)

            #line 107 "..\..\Views\Shared\_AdminLayout.cshtml"
                                       , Tuple.Create(Tuple.Create(" ", 4602), Tuple.Create <System.Object, System.Int32>(menu.Icon

            #line default
            #line hidden
                                                                                                                          , 4603), false)
                                       );

                        WriteLiteral("></i>\r\n");

                        WriteLiteral("                                        ");


            #line 108 "..\..\Views\Shared\_AdminLayout.cshtml"
                        Write(menu.Title);


            #line default
            #line hidden
                        WriteLiteral("\r\n                                        <i");

                        WriteLiteral(" class=\"glyphicon group\"");

                        WriteLiteral("></i>\r\n                                    </a>\r\n                                " +
                                     "    <div");

                        WriteLiteral(" class=\"accordion-inner\"");

                        WriteLiteral(">\r\n");


            #line 112 "..\..\Views\Shared\_AdminLayout.cshtml"


            #line default
            #line hidden

            #line 112 "..\..\Views\Shared\_AdminLayout.cshtml"
                        foreach (AdminMenu child in menu.Children.Where(m => Authorizer.Authorize(m.PermissionKey)).OrderBy(m => m.Order))
                        {
            #line default
            #line hidden
                            WriteLiteral("                                            <a");

                            WriteAttribute("id", Tuple.Create(" id=\"", 5102), Tuple.Create("\"", 5154)
                                           , Tuple.Create(Tuple.Create("", 5107), Tuple.Create("menu", 5107), true)

            #line 114 "..\..\Views\Shared\_AdminLayout.cshtml"
                                           , Tuple.Create(Tuple.Create("", 5111), Tuple.Create <System.Object, System.Int32>((child.Url ?? child.Title).GetHashCode()

            #line default
            #line hidden
                                                                                                                             , 5111), false)
                                           );

                            WriteLiteral(" class=\"b_9FDDF6 menu-item\"");

                            WriteAttribute("href", Tuple.Create(" href=\"", 5182), Tuple.Create("\"", 5220)

            #line 114 "..\..\Views\Shared\_AdminLayout.cshtml"
                                           , Tuple.Create(Tuple.Create("", 5189), Tuple.Create <System.Object, System.Int32>(Url.Content(child.Url ?? "~/")

            #line default
            #line hidden
                                                                                                                             , 5189), false)
                                           );

                            WriteLiteral(">\r\n                                                <i");

                            WriteAttribute("class", Tuple.Create(" class=\"", 5274), Tuple.Create("\"", 5303)
                                           , Tuple.Create(Tuple.Create("", 5282), Tuple.Create("glyphicon", 5282), true)

            #line 115 "..\..\Views\Shared\_AdminLayout.cshtml"
                                           , Tuple.Create(Tuple.Create(" ", 5291), Tuple.Create <System.Object, System.Int32>(child.Icon

            #line default
            #line hidden
                                                                                                                              , 5292), false)
                                           );

                            WriteLiteral("></i>\r\n");

                            WriteLiteral("                                                ");


            #line 116 "..\..\Views\Shared\_AdminLayout.cshtml"
                            Write(child.Title);


            #line default
            #line hidden
                            WriteLiteral("\r\n                                            </a>\r\n");


            #line 118 "..\..\Views\Shared\_AdminLayout.cshtml"
                        }


            #line default
            #line hidden
                        WriteLiteral("                                    </div>\r\n                                </li>" +
                                     "\r\n");


            #line 121 "..\..\Views\Shared\_AdminLayout.cshtml"
                    }
                }
                else
                {
            #line default
            #line hidden
                    WriteLiteral("                            <li>\r\n                                <a");

                    WriteAttribute("id", Tuple.Create(" id=\"", 5732), Tuple.Create("\"", 5782)
                                   , Tuple.Create(Tuple.Create("", 5737), Tuple.Create("menu", 5737), true)

            #line 126 "..\..\Views\Shared\_AdminLayout.cshtml"
                                   , Tuple.Create(Tuple.Create("", 5741), Tuple.Create <System.Object, System.Int32>((menu.Url ?? menu.Title).GetHashCode()

            #line default
            #line hidden
                                                                                                                     , 5741), false)
                                   );

                    WriteLiteral(" class=\"b_9FDDF6 menu-item\"");

                    WriteAttribute("href", Tuple.Create(" href=\"", 5810), Tuple.Create("\"", 5847)

            #line 126 "..\..\Views\Shared\_AdminLayout.cshtml"
                                   , Tuple.Create(Tuple.Create("", 5817), Tuple.Create <System.Object, System.Int32>(Url.Content(menu.Url ?? "~/")

            #line default
            #line hidden
                                                                                                                     , 5817), false)
                                   );

                    WriteLiteral(">\r\n                                    <i");

                    WriteAttribute("class", Tuple.Create(" class=\"", 5889), Tuple.Create("\"", 5917)
                                   , Tuple.Create(Tuple.Create("", 5897), Tuple.Create("glyphicon", 5897), true)

            #line 127 "..\..\Views\Shared\_AdminLayout.cshtml"
                                   , Tuple.Create(Tuple.Create(" ", 5906), Tuple.Create <System.Object, System.Int32>(menu.Icon

            #line default
            #line hidden
                                                                                                                      , 5907), false)
                                   );

                    WriteLiteral("></i>\r\n");

                    WriteLiteral("                                    ");


            #line 128 "..\..\Views\Shared\_AdminLayout.cshtml"
                    Write(menu.Title);


            #line default
            #line hidden
                    WriteLiteral("\r\n                                </a>\r\n                            </li>\r\n");


            #line 131 "..\..\Views\Shared\_AdminLayout.cshtml"
                }
            }


            #line default
            #line hidden
            WriteLiteral("                </ul>\r\n            </div>\r\n\r\n        </nav>\r\n        <div");

            WriteLiteral(" class=\"main-container\"");

            WriteLiteral(">\r\n            <div");

            WriteLiteral(" class=\"site-map\"");

            WriteLiteral(">\r\n");

            WriteLiteral("                ");


            #line 139 "..\..\Views\Shared\_AdminLayout.cshtml"
            Write(Html.MvcSiteMap().SiteMapPath());


            #line default
            #line hidden
            WriteLiteral("\r\n            </div>\r\n            <div");

            WriteLiteral(" id=\"main-body\"");

            WriteLiteral(">\r\n");

            WriteLiteral("                ");


            #line 142 "..\..\Views\Shared\_AdminLayout.cshtml"
            Write(RenderBody());


            #line default
            #line hidden
            WriteLiteral("\r\n            </div>\r\n        </div>\r\n    </div>\r\n");

            WriteLiteral("    ");


            #line 146 "..\..\Views\Shared\_AdminLayout.cshtml"
            Write(StyleAtFoot());


            #line default
            #line hidden
            WriteLiteral("\r\n");

            WriteLiteral("    ");


            #line 147 "..\..\Views\Shared\_AdminLayout.cshtml"
            Write(ScriptAtFoot());


            #line default
            #line hidden
            WriteLiteral("\r\n    <script");

            WriteLiteral(" type=\"text/javascript\"");

            WriteLiteral(" async");

            WriteLiteral(" src=\"http://www.zkea.net/openstatistics\"");

            WriteLiteral("></script>\r\n</body>\r\n</html>\r\n");
        }
예제 #21
0
 public bool AuthorizedFor(Permission permission, IContent content)
 {
     return(Authorizer.Authorize(permission, content));
 }
예제 #22
0
        public IResponse HandleRequest(IRequest request)
        {
            if (Authorizer != null &&
                !IPAddress.IsLoopback(request.RemoteEndpoint.Address) &&
                !Authorizer.Authorize(
                    request.Headers,
                    request.RemoteEndpoint,
                    IP.GetMAC(request.RemoteEndpoint.Address)
                    ))
            {
                throw new HttpStatusException(HttpCode.Denied);
            }

            var path = request.Path.Substring(Prefix.Length);

            Debug(path);
            if (path == "description.xml")
            {
                return(new StringResponse(
                           HttpCode.Ok,
                           "text/xml",
                           GenerateDescriptor(request.LocalEndPoint.Address)
                           ));
            }
            if (path == "contentDirectory.xml")
            {
                return(new ResourceResponse(
                           HttpCode.Ok,
                           "text/xml",
                           "contentdirectory"
                           ));
            }
            if (path == "connectionManager.xml")
            {
                return(new ResourceResponse(
                           HttpCode.Ok,
                           "text/xml",
                           "connectionmanager"
                           ));
            }
            if (path == "MSMediaReceiverRegistrar.xml")
            {
                return(new ResourceResponse(
                           HttpCode.Ok,
                           "text/xml",
                           "MSMediaReceiverRegistrar"
                           ));
            }
            if (path == "control")
            {
                return(ProcessSoapRequest(request));
            }
            if (path.StartsWith("file/", StringComparison.Ordinal))
            {
                var id   = path.Split('/')[1];
                var item = GetItem(id) as IMediaResource;
                InfoFormat("{0}", request.RemoteEndpoint.Address + " : " + item.Path);
                return(new ItemResponse(Prefix, request, item));
            }

            if (path.StartsWith("cover/", StringComparison.Ordinal)) /*
                                                                      * var id = path.Split('/')[1];
                                                                      * InfoFormat("Serving cover {0}", id);
                                                                      * var item = GetItem(id) as IMediaCover;
                                                                      * if (item == null) {
                                                                      * throw new HttpStatusException(HttpCode.NotFound);
                                                                      * }
                                                                      * return new ItemResponse(Prefix, request, item.Cover, "Interactive");
                                                                      */
            {
                throw new HttpStatusException(HttpCode.NotFound);
            }
            if (path.StartsWith("subtitle/", StringComparison.Ordinal))
            {
                var id   = path.Split('/')[1];
                var item = GetItem(id) as IMetaVideoItem;
                InfoFormat("{0}", request.RemoteEndpoint.Address + " : " + item.Subtitle.Path);
                if (item == null)
                {
                    throw new HttpStatusException(HttpCode.NotFound);
                }
                return(new ItemResponse(Prefix, request, item.Subtitle, "Background"));
            }

            if (string.IsNullOrEmpty(path) || path == "index.html")
            {
                return(new Redirect(request, Prefix + "index/0"));
            }
            if (path.StartsWith("index/", StringComparison.Ordinal))
            {
                var id   = path.Substring("index/".Length);
                var item = GetItem(id);
                return(ProcessHtmlRequest(item));
            }

            if (request.Method == "SUBSCRIBE")
            {
                var res = new StringResponse(HttpCode.Ok, string.Empty);
                res.Headers.Add("SID", $"uuid:{Guid.NewGuid()}");
                res.Headers.Add("TIMEOUT", request.Headers["timeout"]);
                return(res);
            }

            if (request.Method == "UNSUBSCRIBE")
            {
                return(new StringResponse(HttpCode.Ok, string.Empty));
            }
            WarnFormat("Did not understand {0} {1}", request.Method, path);
            throw new HttpStatusException(HttpCode.NotFound);
        }
예제 #23
0
파일: DataPortal.cs 프로젝트: gnilesh4/csla
 private void AuthorizeRequest(AuthorizeRequest clientRequest)
 {
     Authorizer.Authorize(clientRequest);
 }
예제 #24
0
        public IResponse HandleRequest(IRequest request)
        {
            if (Authorizer != null &&
                !IPAddress.IsLoopback(request.RemoteEndpoint.Address) &&
                !Authorizer.Authorize(
                    request.Headers,
                    request.RemoteEndpoint,
                    IP.GetMAC(request.RemoteEndpoint.Address)
                    ))
            {
                throw new HttpStatusException(HttpCode.Denied);
            }

            var path = request.Path.Substring(prefix.Length);

            Debug(path);
            if (path == "description.xml")
            {
                return(new StringResponse(
                           HttpCode.Ok,
                           "text/xml",
                           GenerateDescriptor(request.LocalEndPoint.Address)
                           ));
            }
            if (path == "contentDirectory.xml")
            {
                return(new ResourceResponse(
                           HttpCode.Ok,
                           "text/xml",
                           "contentdirectory"
                           ));
            }
            if (path == "connectionManager.xml")
            {
                return(new ResourceResponse(
                           HttpCode.Ok,
                           "text/xml",
                           "connectionmanager"
                           ));
            }
            if (path == "MSMediaReceiverRegistrar.xml")
            {
                return(new ResourceResponse(
                           HttpCode.Ok,
                           "text/xml",
                           "MSMediaReceiverRegistrar"
                           ));
            }
            if (path == "control")
            {
                return(ProcessSoapRequest(request));
            }
            if (path.StartsWith("file/", StringComparison.Ordinal))
            {
                var id = path.Split('/')[1];
                InfoFormat("Serving file {0}", id);
                var item = GetItem(id) as IMediaResource;
                return(new ItemResponse(prefix, request, item));
            }
            if (path.StartsWith("cover/", StringComparison.Ordinal))
            {
                var id = path.Split('/')[1];
                InfoFormat("Serving cover {0}", id);
                var item = GetItem(id) as IMediaCover;
                return(new ItemResponse(prefix, request, item.Cover, "Interactive"));
            }
            if (path.StartsWith("subtitle/", StringComparison.Ordinal))
            {
                var id = path.Split('/')[1];
                InfoFormat("Serving subtitle {0}", id);
                var item = GetItem(id) as IMetaVideoItem;
                return(new ItemResponse(prefix, request, item.Subtitle, "Background"));
            }

            if (string.IsNullOrEmpty(path) || path == "index.html")
            {
                return(new Redirect(request, prefix + "index/0"));
            }
            if (path.StartsWith("index/", StringComparison.Ordinal))
            {
                var id   = path.Substring("index/".Length);
                var item = GetItem(id);
                return(ProcessHtmlRequest(item));
            }
            if (request.Method == "SUBSCRIBE")
            {
                var    res = new StringResponse(HttpCode.Ok, string.Empty);
                string notifySid;
                if (!request.Headers.TryGetValue("SID", out notifySid))
                {
                    notifySid = Guid.NewGuid().ToString();
                }
                else
                {
                    notifySid = notifySid.Remove(0, 5);
                }
                //string callback;
                Tuple <string, DateTime> subres;
                int      timeout  = System.Int32.Parse(request.Headers["timeout"].Remove(0, 7));
                DateTime dtimeout = System.DateTime.Now.AddSeconds(timeout);
                if (!subscribers.TryGetValue(notifySid, out subres))
                {
                    if (request.Headers.ContainsKey("CALLBACK"))
                    {
                        string callback = request.Headers["CALLBACK"].Replace("<", "").Replace(">", "");
                        subscribers.Add(notifySid, new Tuple <string, DateTime>(callback, dtimeout));
                        Debug("Subscribe: " + notifySid + ": " + callback);
                    }
                    else
                    {
                        Error("SUBSCRIBE WTF: " + request.Headers);
                    }
                }
                else
                {
                    //RENEW
                    subscribers[notifySid] = new Tuple <string, DateTime>(subres.Item1, dtimeout);
                }
                res.Headers.Add("SID", string.Format("uuid:{0}", notifySid));
                res.Headers.Add("TIMEOUT", request.Headers["timeout"]);
                return(res);
            }
            if (request.Method == "UNSUBSCRIBE")
            {
                //TODO: remove from subscribers
                return(new StringResponse(HttpCode.Ok, string.Empty));
            }
            WarnFormat("Did not understand {0} {1}", request.Method, path);
            throw new HttpStatusException(HttpCode.NotFound);
        }
예제 #25
0
        public IResponse HandleRequest(IRequest request)
        {
            if (Authorizer != null && !IPAddress.IsLoopback(request.RemoteEndpoint.Address) && !Authorizer.Authorize(request.Headers, request.RemoteEndpoint, IP.GetMAC(request.RemoteEndpoint.Address)))
            {
                throw new HttpStatusException(HttpCode.Denied);
            }

            var path = request.Path.Substring(prefix.Length);

            Debug(path);
            if (path == "description.xml")
            {
                return(new StringResponse(HttpCode.Ok, "text/xml", GenerateDescriptor(request.LocalEndPoint.Address)));
            }
            if (path == "contentDirectory.xml")
            {
                return(new ResourceResponse(HttpCode.Ok, "text/xml", "contentdirectory"));
            }
            if (path == "control")
            {
                return(ProcessSoapRequest(request));
            }
            if (path.StartsWith("file/"))
            {
                var id   = path.Split('/')[1];
                var item = GetItem(id) as IMediaResource;
                return(new ItemResponse(request, item));
            }
            if (path.StartsWith("cover/"))
            {
                var id   = path.Substring("cover/".Length);
                var item = GetItem(id) as IMediaCover;
                return(new ItemResponse(request, item.Cover, "Interactive"));
            }
            if (string.IsNullOrEmpty(path) || path == "index.html")
            {
                return(new Redirect(request, prefix + "index/0"));
            }
            if (path.StartsWith("index/"))
            {
                var id   = path.Substring("index/".Length);
                var item = GetItem(id);
                return(ProcessHtmlRequest(item));
            }
            WarnFormat("Did not understand {0} {1}", request.Method, path);
            throw new HttpStatusException(HttpCode.NotFound);
        }