Ejemplo n.º 1
0
        private List <PropertyInfo> GetEncryptedProperties <T>(T obj, bool serverManaged = false)
        {
            List <PropertyInfo> encryptedProps = new List <PropertyInfo>();

            PropertyInfo[] allProps = obj.GetType().GetProperties();
            foreach (PropertyInfo prop in allProps)
            {
                object[] attrs = prop.GetCustomAttributes(true);
                foreach (object attr in attrs)
                {
                    Encrypted encrypted = attr as Encrypted;
                    if (encrypted != null && encrypted.serverManaged == serverManaged)
                    {
                        //Don't encrypt null values
                        var value = prop.GetValue(obj);
                        if (value == null)
                        {
                            continue;
                        }

                        encryptedProps.Add(prop);
                    }
                }
            }

            return(encryptedProps);
        }
Ejemplo n.º 2
0
        }         // CheckHmrc

        private bool IsSameMarketPlace(int nMpID, byte[] oSecData, MP_MarketplaceType oMp, string sShopID)
        {
            VendorInfo vi = Integration.ChannelGrabberConfig.Configuration.Instance.GetVendorInfo(oMp.Name);

            if (vi == null)
            {
                return(false);
            }

            try {
                var am = Serialized.Deserialize <AccountModel>(Encrypted.Decrypt(oSecData));
                return(am.Fill().UniqueID() == sShopID);
            } catch (Exception e) {
                string sXml = System.Text.Encoding.Default.GetString(oSecData);

                new SafeILog(this).Warn(
                    e,
                    "Failed to de-serialize security data. Marketplace ID = {0}, Security data: {1}",
                    nMpID,
                    sXml
                    );

                return(false);
            }     // try
        }         // IsSameMarketPlace
        public async Task PutAsync(string key, object value)
        {
            if (value == null)
            {
                await DeleteAsync(key);

                return;
            }

            var stringBuilder = new StringBuilder();

            using (var writer = new StringWriter(stringBuilder))
            {
                var stringValue = value as string;
                if (stringValue != null)
                {
                    writer.Write(stringValue);
                }
                else
                {
                    HealthVaultClient.Serializer.Serialize(writer, value, null);
                }
            }

            string    stringContent = stringBuilder.ToString();
            Encrypted encrypted     = m_cryptographer.Encrypt(m_encryptionKey, stringContent);

            await m_inner.PutAsync(key, encrypted);
        }
Ejemplo n.º 4
0
        public void TestDecrypt()
        {
            string sIn     = @"<?xml version=""1.0""?>
<AccountModel xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <id>2022</id>  
  <name>xero1</name> 
  <apikey>DFECQTB5KOK7IHIGGW5S2KXBNLLAV8</apikey>  
  <secret>MWOWLLN0LOGVUPF9BLBUGBM0EOCLWR</sercet> 
  <limitDays>0</limitDays>  
  <accountTypeName>XERO</accountTypeName> 
  <displayName>[email protected]</displayName>  
  <publicCert>-----BEGIN CERTIFICATE-----MIICaDCCAdGgAwIBAgIJAI88EON8XhSeMA0GCSqGSIb3DQEBBQUAME0xCzAJBgNVBAYTAlVLMQ4wDAYDVQQKDAVlemJvYjEOMAwGA1UEAwwFZXpib2IxHjAcBgkqhkiG9w0BCQEWD2V6Ym9iQGV6Ym9iLmNvbTAeFw0xNDA3MjExMTQ2NDdaFw0xOTA3MjAxMTQ2NDdaME0xCzAJBgNVBAYTAlVLMQ4wDAYDVQQKDAVlemJvYjEOMAwGA1UEAwwFZXpib2IxHjAcBgkqhkiG9w0BCQEWD2V6Ym9iQGV6Ym9iLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAx85lHKJsulizOsWLLVW/NdF5fh4WJwXwwbmXRweTlvITHkfoJn7Kh6WeFj23QMspLZuN88L55dJdM7PUFgMS8PRO8ul2MegJ3oTOceIke0Ks49RH2kaeXvHt7xY+nAvgKZuqVlz9sjijkcQLUJ/AuNWsMvjkAooxns4kDB4gS48CAwEAAaNQME4wHQYDVR0OBBYEFDAtGGKmWyhFxidHpPO0VzWtRi2uMB8GA1UdIwQYMBaAFDAtGGKmWyhFxidHpPO0VzWtRi2uMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEARHwqcwcDhiRNrVPWJZmlhMnOmftcfNcP3ak0lyBIe8SrSxLvHmWRonZa84G1/S/u5aaa/Kh2LX3LN1ypj1DEQJfsi8lwj7Lk9NiJQLi66azs73Z6gdVNAJ0KapVt6S81yV9Hf1xs5qRZU/+Ex/OZ+12QMGpe4X7bF8tOXarBROQ=-----END CERTIFICATE-----</publicCert>  <privateKey>-----BEGIN RSA PRIVATE KEY-----MIICXwIBAAKBgQDHzmUcomy6WLM6xYstVb810Xl+HhYnBfDBuZdHB5OW8hMeR+gmfsqHpZ4WPbdAyyktm43zwvnl0l0zs9QWAxLw9E7y6XYx6AnehM5x4iR7Qqzj1EfaRp5e8e3vFj6cC+Apm6pWXP2yOKORxAtQn8C41awy+OQCijGeziQMHiBLjwIDAQABAoGBAJiVhaHYaC/mjPjU4vQ8B0mSLrWhREmIv9MxZ9VWc99R/kehoifDq+brE07o0okonMm3gTAmNbDMdWCGc/BbaJo/8amH3pgbCtEfLUKN7bokiREUQG8rSOxXkjUXAesrLUI+5ZVKQzNPKB20xAEF9vmj/+Ew4q/aaOKSKiw8WHgBAkEA79Jah/WpFWkau8gSGLsoSu7NHbNPNMxy/zR4Sa8uCfX4jdht3hgVpIeDRfqr3gCyVdmC3c1MvT8mVLDinAxOGQJBANVI/JZ+aB5l8L82UwtK1nmwuEgrHS2vwTlxYPtraIn5WHB7DZIWEv21XJXKT+sKAxZxwtf1eo/uOvR5Y+jYy+cCQQC8H2VWu5TsL6uB3Bqd/cpIpXSPNMYQI8SdfrpRCrLxq1pTYpAkpP3tN0P5k/5XwnIiN+KZPN9SoIPf8XWBdYGZAkEArDvbVcBQXjPd/NtmpljR58Uwm37NekZSmAuZ0I5FBh5oL7T/GXhf76dUU9XjQZ99LNPDD1g5mB8+VovshW0FAwJBAKEbR4WNRWgoc0qV2rJ8gUpCXns9yjVEPTkxyDUGIMn/qTHAicTdl0G4NVJ6H9AYrIvFa4ICwOninM+6k/AiRg4=-----END RSA PRIVATE KEY-----</privateKey>
</AccountModel>";
            var    sOutEn  = new Encrypted(new Serialized(sIn));
            string sOutDec = Encrypted.Decrypt(sOutEn);

            //string sOutput = null;
            ////xero
            //string sInput  = "C0/PLr+re1WYbSklttMpN43371tjwPz5G/zRdZgtika0HJyXaOvvimQX/Y+8jYj5iAWu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43sYMh5/TsU3PzvPD/WsGs7GjpFmxeml7+j1hB/o6MYCznKWjirQjIiUuYXE8XpaE/nvIxQLuEA/YAPq/kUI+PuXyhOR9WKE/XoQ2WYv0KOJ3Ct4eZy+43LwmbVHBGk8//Pp0kZwmbOpWT6CqSd32zTIDxhZL6yEbkjt9wWP5h0yZ4aze64JC8t7f4xjLimn90ocYp/lvgtN9JvOTfik5fIazhOCPeWAh/Zm+cFNiPH++3NlmNcwB1qzmhvKJ+RzodAL16D7tOQF49YyVt8VuJG+rlXRlx12AL80OkH5Q1KXjP2AGbRSkc7QLCYzxd0NVX2GGPN30OmZ2nQGy1ze689h86LsZDjpUCXR01anflqBOYblRenIGqIwEXJXtbqVujriANlZhhSK6SAByjK7WfdTkgbGM2hFl9pjZPPcopjdPCgJdLJ6C7Oo3gyjkH3vL8qe4idcmi0";
            //try
            //{
            //	sOutput = Encrypted.Decrypt(sInput2);
            //	sOutput = Encrypted.Decrypt(sInput);
            //}
            //catch (Exception e)
            //{
            //	m_oLog.Warn(e, "Failed to decrypt.");
            //	sOutput = string.Empty;
            //} // try
            Console.WriteLine(sOutDec);
            Assert.IsFalse(String.IsNullOrEmpty(sOutDec));
        }
Ejemplo n.º 5
0
 private void Reset_Click(object sender, EventArgs e)
 {
     Message.Clear();
     Key.Clear();
     Encrypted.Clear();
     Decrypted.Clear();
 }
Ejemplo n.º 6
0
        }         // constructor

        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            string output = new Encrypted(this.txtInput.Text);

            this.txtOutput.Text = output;
            this.txtOutput.Update();
        }         // encrypt clicked
Ejemplo n.º 7
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((Encrypted.GetHashCode() * 397) ^ (CipherParams?.GetHashCode() ?? 0));
     }
 }
Ejemplo n.º 8
0
        public Encrypted <ScenarioInfo> GetScenarioInfo(Encrypted <string> scenarioId)
        {
            return(Handle((user) =>
            {
                var scenario = GetScenario(scenarioId.Decrypt(_secretKey));
                var executeScenarioAction = new ScenarioActionSource(user, ScenarioStartupSource.Network, ScenarioAction.Execute);
                var viewScenarioAction = new ScenarioActionSource(user, ScenarioStartupSource.Network, ScenarioAction.ViewValue);

                var currentValue = string.Empty;
                var canSetValue = true;
                var isAvailable = true;
                try
                {
                    currentValue = scenario.CalculateCurrentValue(viewScenarioAction, null);
                    canSetValue = scenario.IsAccessAvailable(executeScenarioAction);
                }
                catch
                {
                    isAvailable = false;
                    canSetValue = false;
                    currentValue = scenario.ValueType.DefaultValue;
                }

                return new Encrypted <ScenarioInfo>(new ScenarioInfo()
                {
                    CurrentValue = currentValue,
                    ScenarioId = scenario.Id,
                    ValueType = scenario.ValueType,
                    VisualSettings = GetVisualSettings(user, scenario.Id),
                    Name = scenario.Name,
                    OnlyGetValue = !canSetValue,
                    IsAvailable = isAvailable && scenario.GetIsAvailable()
                }, _secretKey);
            }));
        }
Ejemplo n.º 9
0
 public Encrypted <string> GetScenarioValue(Encrypted <string> scenarioId)
 {
     return(Handle((user) => {
         var scenarioActionSource = new ScenarioActionSource(user, ScenarioStartupSource.Network, ScenarioAction.ViewValue);
         return new Encrypted <string>(GetScenario(scenarioId.Decrypt(_secretKey)).CalculateCurrentValue(scenarioActionSource, null), _secretKey);
     }));
 }
Ejemplo n.º 10
0
        public void test_refresh_not_mfa()
        {
            var m = new YodleeMain();

            m.LoginUser("*****@*****.**", Encrypted.Decrypt("sykuYcJcd+ShmykTY/pi0qBpRJK0a9HBiiw9NN0Dgjg="));
            m.RefreshNotMFAItem(10334329, true);
        }
Ejemplo n.º 11
0
        public ActionResult RefreshYodlee(string displayName = null)
        {
            var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id);
            var yodleeMain    = new YodleeMain();

            var oEsi = new YodleeServiceInfo();

            var yodlees = this.customer.CustomerMarketPlaces
                          .Where(mp => mp.Marketplace.InternalId == oEsi.InternalId)
                          .ToList();

            if (yodlees.Count == 0)
            {
                return(View(new { error = "Error loading bank accounts" }));
            }

            var lu = yodleeMain.LoginUser(yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password));

            if (lu == null)
            {
                return(View(new { error = "Error logging to yodlee account" }));
            }

            MP_CustomerMarketPlace umi = displayName == null ? yodlees[0] : yodlees.FirstOrDefault(y => y.DisplayName == displayName);             //TODO Currently refreshes the first one

            if (umi == null)
            {
                return(View(new { error = "Account not found" }));
            }
            var    callback = Url.Action("RecheckYodleeCallback", "YodleeMarketPlaces", new { Area = "Customer" }, "https") + "/" + umi.Id;
            string finalUrl = yodleeMain.GetEditAccountUrl(Serialized.Deserialize <YodleeSecurityInfo>(umi.SecurityData).ItemId, callback, yodleeAccount.Username, Encrypted.Decrypt(yodleeAccount.Password));

            return(Redirect(finalUrl));
        }
Ejemplo n.º 12
0
        public static SessionToken Deserialize(string sToken)
        {
            try {
                string sDecoded = Encrypted.Decrypt(Convert.FromBase64String(sToken));

                string[] ary = sDecoded.Split(new string[] { Separator }, StringSplitOptions.RemoveEmptyEntries);

                if (ary.Length != 4)
                {
                    ms_oLog.Alert(
                        "Supplied token '{0}' has been de-serialised successfully to '{1}' but contains unexpected number of fields.",
                        sToken,
                        sDecoded
                        );

                    return(null);
                }                 // if

                return(new SessionToken(ary[0], ary[1], ary[2], ary[3]));
            }
            catch (Exception e) {
                ms_oLog.Alert(e, "Failed to de-serialise session token from '{0}'.", sToken);
                return(null);
            }     // try
        }         // Deserialize
Ejemplo n.º 13
0
        public ViewResult YodleeCallback()
        {
            Log.InfoFormat("Got to yodlee's callback with params:{0}", HttpContext.Request.Params);
            foreach (string key in HttpContext.Request.Params.Keys)
            {
                if (key == "oauth_error_code")
                {
                    Log.WarnFormat("Yodlee returned an error. oauth_error_code:{0} oauth_error_problem:{1}", HttpContext.Request.Params["oauth_error_code"], HttpContext.Request.Params["oauth_error_problem"]);
                    if (HttpContext.Request.Params["oauth_error_code"] == "407")
                    {
                        return(View(new { error = "Failure linking account" }));
                    }
                }
            }

            var yodleeAccount = this.yodleeAccountsRepository.Search(this.customer.Id);

            string decryptedPassword = Encrypted.Decrypt(yodleeAccount.Password);
            string displayname;
            long   csId;

            var yodleeMain = new YodleeMain();
            var oEsi       = new YodleeServiceInfo();

            var items = this.customer.CustomerMarketPlaces
                        .Where(mp => mp.Marketplace.InternalId == oEsi.InternalId)
                        .Select(mp => Serialized.Deserialize <YodleeSecurityInfo>(mp.SecurityData).ItemId).ToList();

            long itemId = yodleeMain.GetItemId(yodleeAccount.Username, decryptedPassword, items, out displayname, out csId);

            if (itemId == -1)
            {
                return(View(new { error = "Failure linking account" }));
            }

            int marketPlaceId = this.mpTypes
                                .GetAll()
                                .First(a => a.InternalId == oEsi.InternalId)
                                .Id;

            var securityData = new YodleeSecurityInfo
            {
                ItemId        = itemId,
                Name          = yodleeAccount.Username,
                Password      = yodleeAccount.Password,
                MarketplaceId = marketPlaceId,
                CsId          = csId
            };

            var yodleeDatabaseMarketPlace = new YodleeDatabaseMarketPlace();

            var marketPlace = this.dbHelper.SaveOrUpdateCustomerMarketplace(displayname, yodleeDatabaseMarketPlace, securityData, this.customer);

            Log.InfoFormat("Added or updated yodlee marketplace: {0}", marketPlace.Id);

            this.serviceClient.Instance.UpdateMarketplace(this.context.Customer.Id, marketPlace.Id, true, this.context.UserId);

            return(View(YodleeAccountModel.ToModel(marketPlace, this.yodleeBanksRepository)));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Metodo de lectura del token
        /// </summary>
        /// <returns></returns>
        public TokenDto Get()
        {
            var      authHeader   = WebOperationContext.Current.IncomingRequest.Headers["Authorization"];
            var      access_token = Encrypted.Decode(authHeader);
            var      token        = JsonConvert.DeserializeObject <Dictionary <string, object> >(access_token);
            TokenDto tokenDto     = new TokenDto(int.Parse(token["codeStore"].ToString()), int.Parse(token["codeBox"].ToString()), int.Parse(token["usuario"].ToString()));

            return(tokenDto);
        }
Ejemplo n.º 15
0
        }         // GetDisplayName

        private void GetPassword()
        {
            try {
                Password = Encrypted.Decrypt(m_sRawPassword);
            }
            catch (Exception e) {
                throw new StrategyWarning(this, "Failed to get password from " + m_sRawPassword, e);
            }
        }         // GetPassword
Ejemplo n.º 16
0
        public string Decrypt(string keyMaterial, Encrypted encrypted)
        {
            CryptographicKey key = SymmetricKeyFromMaterial(keyMaterial);

            IBuffer encryptedBuffer = CryptographicBuffer.DecodeFromBase64String(encrypted.Value);
            IBuffer decryptedBuffer = CryptographicEngine.Decrypt(key, encryptedBuffer, null);

            return(CryptographicBuffer.ConvertBinaryToString(encrypted.Encoding, decryptedBuffer));
        }
Ejemplo n.º 17
0
 private void GetCustomerID()
 {
     try {
         CustomerID = int.Parse(Encrypted.Decrypt(m_sRawCustomerID));
     }
     catch (Exception e) {
         throw new StrategyWarning(this, "Failed to get customer ID from " + m_sRawCustomerID, e);
     }
 }         // GetCustomerID
Ejemplo n.º 18
0
 public void AsyncExecuteScenarioParallel(Encrypted <string> scenarioId, Encrypted <string> value)
 {
     Handle((user) =>
     {
         var scenario     = GetScenario(scenarioId.Decrypt(_secretKey));
         var actionSource = new ScenarioActionSource(user, ScenarioStartupSource.Network, ScenarioAction.Execute);
         scenario.ExecuteAsyncParallel(actionSource, value.Decrypt(_secretKey), null);
     });
 }
Ejemplo n.º 19
0
 private bool PassExists(string password, int idUsuario)
 {
     if (password == "" || password == null)
     {
         return(false);
     }
     password = Encrypted.Encrypt(password);
     return(_context.Usuarios.Any(u => u.Clave == password && u.Id == idUsuario));
 }
Ejemplo n.º 20
0
 public void ExecuteScenario(Encrypted <string> scenarioId, Encrypted <string> value)
 {
     Handle((user) =>
     {
         var scenario     = GetScenario(scenarioId.Decrypt(_secretKey));
         var actionSource = new ScenarioActionSource(user, ScenarioStartupSource.Network, ScenarioAction.Execute);
         scenario.Execute(actionSource, value.Decrypt(_secretKey), out string executionId);
     });
 }
Ejemplo n.º 21
0
        }         // GetCustomerID

        private void GetDisplayName()
        {
            try {
                m_sDisplayName = Encrypted.Decrypt(m_sRawDisplayName);
            }
            catch (Exception e) {
                throw new StrategyWarning(this, "Failed to get display name from " + m_sRawDisplayName, e);
            }
        }         // GetDisplayName
Ejemplo n.º 22
0
 private string TryDecrypt(byte[] oEncoded)
 {
     try {
         return(Encrypted.Decrypt(oEncoded));
     }
     catch (Exception) {
         return("FAILED TO DECRYPT");
     } // try
 }     // TryDecrypt
Ejemplo n.º 23
0
        public void can_encrypt_and_decrypt()
        {
            const string text      = "Hello World";
            var          encrypted = new Encrypted(text);
            var          decrypted = encrypted.Decrypt();

            Assert.That(decrypted, Is.EqualTo(text));
            Assert.That(encrypted.ToString(), Is.Not.EqualTo(text));
        } // can_encrypt_and_decrypt() {
Ejemplo n.º 24
0
 public Encrypted <AddictionalData> SyncAddictionalData(Encrypted <AddictionalData> encryptedData)
 {
     return(Handle((user) => {
         WarningHandler.InfoFormat("User AddictionalData sync: [{0}];", user.Name);
         var data = encryptedData.Decrypt(_secretKey);
         AddictionalDataManager.Handle(data, user);
         var preparedData = AddictionalDataManager.Prepare(user);
         return new Encrypted <AddictionalData>(preparedData, _secretKey);
     }));
 }
Ejemplo n.º 25
0
        }         // encrypt clicked

        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            try {
                this.txtOutput.Text = Encrypted.Decrypt(this.txtInput.Text);
            } catch (Exception ex) {
                this.txtOutput.Text = ex.Message;
            }             // try

            this.txtOutput.Update();
        }         // decrypt clicked
Ejemplo n.º 26
0
        public User Create(CreateUserRequest userRequest)
        {
            var user = userRequest.ToUser();

            user.Password = Encrypted.Sha256(user.Password);

            fileRepository.Save(userRequest.Photo, userRequest.PhotoName);

            return(userRepository.Create(user));
        }
Ejemplo n.º 27
0
        public LoginReponse Login(LoginRequest loginRequest)
        {
            var user = userRepository.IsValidUserCredentials(loginRequest.Username, Encrypted.Sha256(loginRequest.Password));

            if (user == null)
            {
                throw new UnauthorizedAccessException();
            }

            return(authRepository.GenerateTokens(user));
        }
Ejemplo n.º 28
0
 public Encrypted <StatisticsScenarioInfo> GetStatisticsInfoForScenario(Encrypted <ScenarioInfo> info)
 {
     return(Handle((user) => {
         var scenarioId = info.Decrypt(_secretKey).ScenarioId;
         var scenario = ScenariosRepository.Scenarios.FirstOrDefault(x => x.Id == scenarioId);
         if (scenario == null)
         {
             return null;
         }
         return new Encrypted <StatisticsScenarioInfo>(StatisticsManager.GetStatisticsInfoForScenario(scenario, new ScenarioActionSource(user, ScenarioStartupSource.Network, ScenarioAction.ViewValue)), _secretKey);
     }));
 }
Ejemplo n.º 29
0
        public static string Stringify(this YodleeSecurityInfo oInfo)
        {
            if (oInfo == null)
            {
                return(string.Empty);
            }

            return(string.Format(
                       "Name: {0}, ItemID: {1}, CsId: {2}, Password: {3}",
                       oInfo.Name, oInfo.ItemId, oInfo.CsId, Encrypted.Decrypt(oInfo.Password)
                       ));
        } // Stringify
Ejemplo n.º 30
0
        public static bool ChangePassword(BOM.User user, String pass)
        {
            String encrypted = Encrypted.GetEncrypted(pass);

            if (DAL.AuthenticationDal.UpdatePassword(user, encrypted))
            {
                String res = BOL.SendMail(user.email, "password for watershed is updated", "updated password is: " + pass);
                return(true);
            }

            return(false);
        }