Пример #1
0
        public void test_get_service_ticket()
        {
            CasLogin casLogin      = new CasLogin(userName, password, casUrl);
            String   serviceTicket = casLogin.getServiceTicket(serviceUrl);

            Console.Out.WriteLine("serviceTicket:" + serviceTicket);
        }
Пример #2
0
        public async Task <IActionResult> TicketLogin([FromBody] CasLogin credenziali)
        {
            var query = new CasLoginQuery()
            {
                Ticket  = credenziali.Ticket,
                Service = credenziali.Service
            };

            try
            {
                var utente = (Utente)this._cashandler.Handle(query).User;

                if (utente == null)
                {
                    return(StatusCode(403, new { message = Costanti.UtenteNonAutorizzato }));
                }

                return(Ok(utente));
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("no element"))
                {
                    return(StatusCode(404, new { message = "Le credenziali inserite non risultano corrette" }));
                }
                return(BadRequest(new { message = ex.Message }));
            }
        }
Пример #3
0
        public void test_get_service_ticket_and_validate()
        {
            CasLogin casLogin      = new CasLogin(userName, password, casUrl);
            String   serviceTicket = casLogin.getServiceTicket(serviceUrl);

            CasValidate casValidate = new CasValidate(casUrl);

            casValidate.validateServiceTicket(serviceUrl, serviceTicket);
        }
Пример #4
0
        private static RmitJsonObject _GetRmitJsonObject()
        {
            // Initialize return object with some default values...
            var rmitJsonObject = new RmitJsonObject()
            {
                Timetables = new List <Timetables>(),
                IsFreeDay  = false,                // ...so sad lol
                HasError   = false
            };

            //   try
            //   {
            // Initialize login object then login
            var casLogin  = new CasLogin();
            var casResult = casLogin.RunCasLogin(Settings.RmitID, Settings.RmitPassword).Result;

            // Initialize portal stuff
            var portal          = new MyRmitPortal(casResult.CasCookieContainer);
            var timetableResult = portal.GetCurrentClassTimetable().Result;

            // Get the time. In this array, Monday is 0, Sunday is 6.
            int dayOfWeek = (int)((DateTime.Now.DayOfWeek) + 6) % 7;             // Shift the day of week



            // Set to list object
            foreach (var timetableForToday in timetableResult.WeeklyTimetable[dayOfWeek].DailyTimetable)
            {
                var tableContent = new Timetables()
                {
                    Title         = timetableForToday.Title,
                    Activity      = timetableForToday.ActivityType,
                    Subject       = timetableForToday.Subject,
                    CatalogNumber = timetableForToday.CatalogNumber,
                    StartTime     = timetableForToday.StartDisplayable,
                    EndTime       = timetableForToday.EndDisplayable
                };

                rmitJsonObject.Timetables.Add(tableContent);
            }

            if (rmitJsonObject.Timetables.Count == 0)
            {
                rmitJsonObject.IsFreeDay = true;
            }

            //    }

            //    catch (Exception error)
            //    {
            //        rmitJsonObject.HasError = true;
            //        rmitJsonObject.ErrorMessage = error.Message;
            //    }

            return(rmitJsonObject);
        }