public IHttpActionResult Authorize(Authorize authorize)
        {
            var dec = GlobalHelper.DecryptRSA(authorize).Split('%');

            if (dec == null)
            {
                return(NotFound());
            }
            Doctor dr = new Doctor();

            dr.Name     = dec[0];
            dr.LastName = dec[1];
            dr.PESEL    = dec[2].ToString();

            var DFDB = (from d in db.Doctor where d.PESEL.ToString() == dr.PESEL select d).SingleOrDefault();

            if (DFDB != null && DFDB.CipherData.Trim() == authorize.cipherData.Trim())
            {
                return(Json(MyAES.EncryptStringToBytes(DFDB.Id.ToString())));
            }

            else
            {
                return(NotFound());
            }
        }
Example #2
0
 public override IObservable<TwitterStatus> Upload(Authorize.AuthenticateInfo authInfo, string status,
     byte[] attachedImageBin, long? in_reply_to_status_id = null,
     double? geo_lat = null, double? geo_long = null)
 {
     var param = new Dictionary<string, object>()
     {
         {"key", ApplicationKey},
         {"message", status},
     }.Parametalize();
     return new MultipartableOAuthClient(ApiEndpoint.DefaultConsumerKey, ApiEndpoint.DefaultConsumerSecret,
         authInfo.AccessToken)
     {
         Url = ApiEndpointUriString,
     }
     .AsOAuthEcho()
     .GetResponse(param.Select(p => new UploadContent(p.Key, p.Value))
         .Append(UploadContent.FromBinary("media", "attach.png", attachedImageBin)))
     .ReadString()
     .Select(s =>
     {
         using (var reader = new StringReader(s))
         {
             var doc = XDocument.Load(reader);
             return doc.Element("image").Element("url").ParseString();
         }
     })
     .SelectMany(s => authInfo.Update(status + " " + s, in_reply_to_status_id, geo_lat, geo_long));
 }
Example #3
0
        public static string AuthorizeTypeChange(Authorize authorize)
        {
            string authCode = "";

            switch (authorize)
            {
                case Authorize.Create:
                    authCode = "AC006002";
                    break;
                case Authorize.Read:
                    authCode = "AC006001";
                    break;
                case Authorize.Update:
                    authCode = "AC006003";
                    break;
                case Authorize.Delete:
                    authCode = "AC006004";
                    break;
                case Authorize.Admin:
                    authCode = "AC006005";
                    break;
            }

            return authCode;
        }
 public PollsController(Authorize authorize, UserServices userServices)
 {
     client             = new HttpClient();
     client.BaseAddress = new Uri("https://localhost:44337/");
     this.authorize     = authorize;
     this.userServices  = userServices;
 }
Example #5
0
        public void RemoveRange(IEnumerable <TResult> dtos, Authorize <TResult, int> authorize,
                                NotFound <TResult, int> notFound = null)
        {
            if (dtos == null)
            {
                throw new ArgumentNullException(nameof(dtos));
            }
            if (authorize == null)
            {
                throw new ArgumentNullException(nameof(authorize));
            }
            var dtoArray     = dtos.ToArray();
            var entities     = new List <T>(dtoArray.Length);
            var hasError     = false;
            var continuation = new Continuation();

            for (var index = 0; index < dtoArray.Length; index++)
            {
                var dto    = dtoArray[index];
                var entity = _dbSet.Find(GetKeyValues(dto));
                if (entity == null)
                {
                    (notFound ?? NotFound).Invoke(dto, index, continuation);
                    hasError = true;
                    if (continuation.Yes)
                    {
                        continue;
                    }
                    break;
                }

                var oldDto = Map(entity);
                if (!authorize(dto, oldDto, index, continuation))
                {
                    hasError = true;
                    if (continuation.Yes)
                    {
                        continue;
                    }
                    break;
                }

                entities.Add(entity);
            }

            if (hasError)
            {
                return;
            }

            if (SoftDelete)
            {
                _rules.Apply(entities, DataAction.Remove);
            }
            else
            {
                _dbSet.RemoveRange(entities);
            }
        }
        public ActionResult Details(int?id)
        {
            User          user   = new Authorize().GetAuthorizedUser(Request.Cookies["user"]);
            string        text   = GetWebpage("Home", user, id, null);
            ContentResult result = Content(text, "text/html");

            return(result);
        }
Example #7
0
        public UploaderProperty(string resource, string login, string password, string odata, Logger logger)
        {
            _odata    = odata;
            authorize = new Authorize(resource, login, password);
            Task taskAuth = AuthorizeStart();

            _logger = logger;
        }
        public IActionResult VerifyPhoneNumber([Required] string id, [FromBody] VerifyPhoneNumberRequest request)
        {
            Authorize.TokenAgainstResource(HttpContext.User, id);

            _customerService.VerifyPhoneNumber(id, request.VerificationCode);

            return(Ok());
        }
        public IActionResult SendPhoneVerification([Required] string id)
        {
            Authorize.TokenAgainstResource(HttpContext.User, id);

            _customerService.SendPhoneVerification(id);

            return(Ok());
        }
Example #10
0
    public void Login()
    {
        Authorize authorize = new Authorize();

        authorize.Username = usernameTextBox.Text;
        authorize.Password = passwordTextBox.Text;
        display.Show(authorize);
    }
Example #11
0
 internal Tokens(Authorize auth, string username, string password)
 {
     this.AccessToken = auth.AccessToken;
     this.Auth        = auth;
     this.username    = username;
     this.password    = password;
     this.ExpireTime  = DateTime.Today.ToLocalTime().AddSeconds(this.Auth.ExpiresIn);
 }
 /// <summary>
 /// 提交授权
 /// </summary>
 /// <param name="authorize"></param>
 /// <returns></returns>
 public int AddAuthorize(Authorize authorize)
 {
     using (SqlSugarClient db = BaseDB.GetClient())
     {
         var i = db.Insertable(authorize).ExecuteCommand();
         return(i);
     }
 }
Example #13
0
        public JsonResult GetList(int pageindex, int pagesize, string serialNumber,
                                  int?model, int?status, bool?active)
        {
            var user = Authorize.GetUser();
            var list = BLL.Client.Get(user.Server).ManageGetDealerDeviceList(user.LoginId, pageindex, pagesize, serialNumber, model, status, active);

            return(Json(new { Result = 1, Count = list.Total, List = list.List }));
        }
Example #14
0
        public ActionResult Activate(int?again)
        {
            OpResult op   = null;
            var      comp = Authorize.GetCompanyByConnect(ref op);

            ViewBag.code = op != null? op.Code:"";
            return(View(comp));
        }
    public void Login()
    {
        Authorize authorize = new Authorize();

        authorize.Username = usernameTextBox.Text;
        authorize.Password = passwordTextBox.Text;
        // Todo: Rest of login logic here
    }
Example #16
0
    static void Main()
    {
        Point point = new Point();

        point.x = 5;
        point.y = 3;

        //Object initilization can be simplified as below
        //Point point = new Point
        //{
        //    x = 5,
        //    y = 3
        //};

        System.Console.WriteLine(point.x);
        System.Console.WriteLine(point.y);

        //Human Class (Creating an object of the Human class and assigning initial values to the class)
        Human human = new Human(80, 130);
        //Creating an object of Human class and default constructor works
        Human humanTwo = new Human();

        humanTwo.Height = 80;
        humanTwo.Weight = 130;

        System.Console.WriteLine(human.Height);
        System.Console.WriteLine(human.Weight);

        //Create object of User class
        User user = new User();

        user.UserName = "******";       //Oops, this is not a valid user name !
        user.UserName = "******";

        user.Password = 2;          //Oops, this is not a valid password, Please use password value between with 4 to 10
        user.Password = 5;

        //Create object of Authorize class
        Authorize authorize = new Authorize("abcd");

        //we can read the username
        System.Console.WriteLine(authorize.UserName);
        //we can not read the password
        //System.Console.WriteLine(authorize.Password);

        Department department  = new Department("ab");
        Department department2 = new Department();

        department2.UserName = "******";

        Constant constant = new Constant();

        System.Console.WriteLine(constant.ID);

        Constant constant2 = new Constant(4);

        System.Console.WriteLine(constant2.ID);
    }
        public ActionResult ActualResetPassword(DataModel model)
        {
            using (var e = new EntityContext())
            {
                var data = ActionData.GetAction <DataModel>(Guid.Parse(model.Guid), e);
                model.Email = data.Item1.Email;
                var actionRow = data.Item2;
                if (model == null || actionRow == null || actionRow.Investigator_Name == null)
                {
                    return(View(ResetPasswordErrorView));
                }

                // clears the errors from the model
                model.ClearToaster();
                // check for simple warnings
                var isValid = true;
                // makes sure we don't have any empty fields
                if (String.IsNullOrEmpty(model.Password) || String.IsNullOrEmpty(model.Email))
                {
                    model.AddError(GlobalErrors.EmptyFields);
                    isValid = false;
                }
                if (!CredentialsHelper.IsPasswordValid(model.Password)) // check password is valid
                {
                    model.AddError(RegistrationErrors.InvalidPassword);
                    isValid = false;
                }
                else // if password is valid get warnings
                {
                    model.AddWarnings(CredentialsHelper.GetPasswordWarnings(model.Password));
                }


                if (isValid)                                 // check for more serious warnings
                {
                    using (var e2 = new EntityContext())     // db context
                    {
                        if (isValid && !model.HasWarnings()) // we have checked everything we need to check
                        {
                            var success = Authorize.ResetPassword(model.Email, model.Password, e2);

                            e.Web_Action_Data.Remove(actionRow);
                            e.SaveChanges();
                            if (!success)
                            {
                                return(View(ResetPasswordErrorView));
                            }
                            else
                            {
                                return(View(ResetPasswordSuccessView));
                            }
                        }
                    }
                }
            }
            // if we got here there was an error
            return(View(ReceivedView, model));
        }
Example #18
0
        public int DeleteAuthorizeButton(Authorize authorize)
        {
            var entity = authorizeButtonApp.FindEntity(authorize.ID);

            entity.Remove();
            var ret = authorizeButtonApp.Update(entity);

            return(ret);
        }
Example #19
0
        public JsonResult Stock(string devices)
        {
            var user = Authorize.GetUser();

            BLL.Client.Get(user.Server).ManageStockDeviceList(user.LoginId, devices);
            return(Json(new { Result = 1, Message = "入库成功" }));

            ;
        }
Example #20
0
        public bool DoAuthorize(WebContext wc, bool mock)
        {
            if (Authorize != null)
            {
                return(Authorize.Do(wc, mock));
            }

            return(true);
        }
Example #21
0
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            // clears the errors from the model
            model.ClearToaster();
            // check for simple warnings
            var isValid = true;

            // makes sure we don't have any empty fields
            if (String.IsNullOrEmpty(model.Email))
            {
                model.AddError(GlobalErrors.EmptyFields);
                isValid = false;
            }
            if (!CredentialsHelper.IsEmailValid(model.Email)) // check email is valid
            {
                model.AddError(ResetPasswordErrors.InvalidEmail);
                isValid = false;
            }

            if (isValid)                            // check for more serious warnings
            {
                using (var e = new EntityContext()) // db context
                {
                    // check if email exists in the database, we need the email to register
                    if (!Authorize.EmailExists(model.Email, e))
                    {
                        model.AddError(ResetPasswordErrors.EmailNotAssociatedWithUser);
                        isValid = false;
                    }
                    else if (!Authorize.EmailIsRegistered(model.Email, e)) // if it does check if it is already registered
                    {
                        model.AddError(ResetPasswordErrors.EmailNotRegistered);
                        isValid = false;
                    }

                    if (isValid && !model.HasWarnings()) // we have checked everything we need to check
                    {
                        CachedUser cachedUser = GetCachedUser.UserByEmail(model.Email, e);
                        if (cachedUser == null)
                        {
                            model.AddError(RegistrationErrors.UnknowError);
                        }
                        else
                        {
                            return(RedirectToAction("Send", "ResetPassword", new
                            {
                                email = cachedUser.Email,
                                username = cachedUser.Username,
                                investigatorName = cachedUser.InvestigatorName
                            }));
                        }
                    }
                }
            }
            // if we got here there was an error
            return(View(model));
        }
Example #22
0
        private static void InitApplication()
        {
            Authorize auth = new Authorize();

            auth.AuthenticateUser();
            TweetService.ClearLists();
            tweetTimer = new Timer(TimerCallback, null, 0, 60000);
            Console.ReadLine();
        }
Example #23
0
        /// <summary>
        /// اطالعات مربوط به سطوح دسترسی را در ذخیره میکند
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="resourceIdList">منابعی که دسترسی به آنها مجاز است</param>
        /// <returns></returns>
        public bool UpdateAthorize(decimal roleId, IList <decimal> resourceIdList)
        {
            EntityRepository <Resource> resourceRep = new EntityRepository <Resource>();

            using (NHibernateSessionManager.Instance.BeginTransactionOn())
            {
                try
                {
                    Role role = base.GetByID(roleId);
                    if (role.AuthorizeList != null)
                    {
                        role.AuthorizeList.Clear();
                        this.SaveChanges(role, UIActionType.EDIT);
                    }
                    else
                    {
                        role.AuthorizeList = new List <Authorize>();
                    }
                    foreach (decimal resourceId in resourceIdList)
                    {
                        Authorize athorize = new Authorize();
                        Resource  resource = resourceRep.GetById(resourceId, false);
                        athorize.Allow    = true;
                        athorize.Resource = resource;
                        athorize.Role     = role;
                        if (role.AuthorizeList.Where(auth => auth.Resource.ID == athorize.Resource.ID && auth.Role.ID == athorize.Role.ID).Count() == 0)
                        {
                            role.AuthorizeList.Add(athorize);
                        }
                        foreach (decimal parentId in resource.ParentPathList)
                        {//add parents
                            athorize          = new Authorize();
                            athorize.Allow    = true;
                            athorize.Resource = new Resource()
                            {
                                ID = parentId
                            };
                            athorize.Role = role;
                            if (role.AuthorizeList.Where(auth => auth.Resource.ID == athorize.Resource.ID && auth.Role.ID == athorize.Role.ID).Count() == 0)
                            {
                                role.AuthorizeList.Add(athorize);
                            }
                        }
                    }
                    this.SaveChanges(role, UIActionType.EDIT);

                    NHibernateSessionManager.Instance.CommitTransactionOn();
                    return(true);
                }
                catch (Exception ex)
                {
                    NHibernateSessionManager.Instance.RollbackTransactionOn();
                    LogException(ex, "BRole", "UpdateAthorize");
                    throw ex;
                }
            }
        }
Example #24
0
        public JsonResult Sales(int dealerId, string devices)
        {
            var user = Authorize.GetUser();

            BLL.Client.Get(user.Server).ManageSalesDeviceList(user.LoginId, dealerId, devices);
            return(Json(new { Result = 1, Message = "销售成功" }));

            ;
        }
Example #25
0
        public int ModifyAuthorize(Authorize authorize, string keyValue)
        {
            var entity = authorizeApp.FindEntity(keyValue);

            EntityCopyHelper.CopyEnity(entity, authorize);
            var ret = authorizeApp.Update(entity);

            return(ret);
        }
Example #26
0
        public AutorizacionOs Autorizar(Authorize model)
        {
            var autorizacionOs = new AutorizacionOs();

            try
            {
                var outputpres = "";
                var cuenta     = 1;

                var output = "MSH|^~\\&|TRIA0100M|TRIA00007160|SWISSHL7|SWISS^800006^IIN|";
                output += DateTime.Now.ToString("yyyyMMddHHmmss") + "||ZQA^Z02^ZQA_Z02|08050522304540783782|P|2.4|||NE|AL|ARG";
                output += Environment.NewLine;
                output += "PRD|PS^CIRCULO MEDICO DE SALTA||^^^A||||30543364610^CU|";
                output += Environment.NewLine;
                output += "PRD|EF^" + model.Efector.Name + "||^^^C||||" + model.Efector.Cuit + "^CU&M&C|";
                output += Environment.NewLine;
                output += "PID|||800006" + model.Credencial + "^^^SWISS^HC||UNKNOWN";
                output += Environment.NewLine;
                foreach (var prestacion in model.Prestaciones)
                {
                    outputpres += "PR1|" + cuenta + "||" + prestacion.CodPres + Environment.NewLine;
                    outputpres += "AUT||||||||" + prestacion.Cant + "|0" + Environment.NewLine;
                    cuenta++;
                }
                output += outputpres;
                output += "PV1||O||P|||||||||||||||||||||||||||||||||||||||||||||||V";
                output += Environment.NewLine;

                // var resultado = _traditum.Send(output);
                //logResult(output.ToString(), resultado.ToString(), "A");

                //var OSerror = false;
                //if (resultado.Contains("Error ejecutando") || resultado.Contains("no se pueden procesar") || resultado.Contains("Unable to read data"))
                //{
                //    OSerror = OsStatus.checkSwiss(true);
                //    autorizacionOs.ShowMessage = Mensajes.Get("ServidorNoResponde");
                //    autorizacionOs.HasError = true;
                //    autorizacionOs.SetError(GetType().Name, 152, resultado, string.Empty, model, string.Empty, OSerror);
                //    return autorizacionOs;
                //}

                //if (resultado.Substring(0, 4) == "MSH|")
                //{
                //    OSerror = OsStatus.checkSwiss(false);
                //    return SetAutorizacionOs(resultado, model);
                //}

                //OSerror = OsStatus.checkSwiss(true);
                //autorizacionOs.SetError(GetType().Name, 0, resultado, string.Empty, model, string.Empty, OSerror);
            }
            catch (Exception ex)
            {
                autorizacionOs.SetError(GetType().Name, GetMethod.ErrorLine(ex), ex.Message, ex.InnerException?.ToString() ?? "", model, string.Empty);
            }
            return(autorizacionOs);
        }
Example #27
0
        public ActionResult Sales(string serialNumber)
        {
            var user       = Authorize.GetUser();
            var listDealer = BLL.Client.Get(user.Server).ManageGetDealerList(user.LoginId);

            ViewBag.Dealer       = listDealer;
            ViewBag.SerialNumber = serialNumber;
            ViewBag.Count        = BLL.Client.Get(user.Server).ManageGetCount(user.LoginId);
            return(View());
        }
Example #28
0
        /// <summary>
        /// Sends an Authorize message to a client.
        /// </summary>
        /// <param name="authorization">The authorization.</param>
        /// <param name="supplementalAuthorization">The supplemental authorization.</param>
        /// <param name="extension">The message header extension.</param>
        /// <returns>The sent message on success; <c>null</c> otherwise.</returns>
        public virtual EtpMessage <Authorize> Authorize(string authorization, IDictionary <string, string> supplementalAuthorization, IMessageHeaderExtension extension = null)
        {
            var body = new Authorize
            {
                Authorization             = authorization,
                SupplementalAuthorization = supplementalAuthorization ?? new Dictionary <string, string>(),
            };

            return(SendRequest(body, extension: extension));
        }
Example #29
0
        //Get all locked users
        public JsonResult GetLockedUsers()
        {
            //Returns a list of all locked users if user is admin or IT
            if (Authorize.InGroup(Authorize.IT))
            {
                return(Json(AD.LockedUsersToList(), JsonRequestBehavior.AllowGet));
            }

            return(null);
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            //For page authroization
            Authorize _obj = new Authorize();

            if (!_obj.IsRoleAuthorizedForUrl())
            {
                Response.Redirect(Convert.ToString(ConfigurationManager.AppSettings["UnauthorizedUrl"]));
            }
        }
Example #31
0
        public async Task CreateAppTest()
        {
            var authorize = new Authorize();

            await authorize.CreateApp(AccountInformation.Instance, "TootNet", Scope.Read | Scope.Write | Scope.Follow);

            Assert.NotNull(authorize.Instance);
            Assert.NotNull(authorize.ClientId);
            Assert.NotNull(authorize.ClientSecret);
        }
Example #32
0
        public ActionResult ModifyAuthorize(Authorize authorize, string keyvalue)
        {
            var ret = authorizeApp.ModifyAuthorize(authorize, keyvalue);

            if (ret == 1)
            {
                return(Success("修改权限成功"));
            }
            return(Error("修改权限失败"));
        }
Example #33
0
        public void AuthenticateAuthorize(Authorize details)
        {
            var client = new RestClient(this.url);

            var request = new RestRequest("oauth/authorize", Method.GET)
                              {
                                  RequestFormat = DataFormat.Json,
                                  JsonSerializer =
                                      new RestSharpJsonNetSerializer()
                              };

            request.AddQueryParameter("client_id", details.ClientId);
            request.AddQueryParameter("redirect_uri", ((Authorize)details).RedirectUri);
            request.AddQueryParameter("response_type", ((Authorize)details).GrantType);

            var response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception("Error request");
            }
        }
Example #34
0
        public ServiceList AuthenticateImplicitGrant(Authorize details, string code)
        {
            var client = new RestClient(this.url);

            details.Code = code;

            var request = new RestRequest("oauth/token", Method.POST)
                              {
                                  RequestFormat = DataFormat.Json,
                                  JsonSerializer =
                                      new RestSharpJsonNetSerializer()
                              };

            request.AddBody(details);

            var newResponse = client.Execute<ResponseToken>(request);

            if (newResponse.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception("Error request");
            }

            return new ServiceList(this.url, newResponse.Data);
        }