public void TestCreate()
        {
            var user = new PassOneUser(_service.GetNextIdValue(), TestUser2.FirstName, TestUser2.LastName,
                                       TestUser2.Username,
                                       TestUser2.Password, TestUser2.k, TestUser2.v);
            _service.Create(user);

            User actual;
            using (var db = new PassOneContext())
            {
                db.Database.Connection.Open();
                var query = from u in db.Users select u;
                actual = query.ToList().FirstOrDefault(user1 => user1.Id == user.Id);
            }
            Assert.IsNotNull(actual);

            using (var db = new PassOneContext())
            {
                db.Database.Connection.Open();
                var userQuery = from u in db.Users select u;
                var remove = userQuery.ToList().FirstOrDefault(user1 => user1.Id == user.Id);
                db.Users.Remove(remove);
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public Dictionary<string, int> GetCredentialsList(PassOneUser passOneUser)
 {
     Dictionary<string, int> list;
     using (var db = new PassOneContext())
     {
         db.Database.Connection.Open();
         var query = from c in db.Credentials select c;
         list = query.ToList().Where(credential => credential.UserId == passOneUser.Id).ToDictionary(credential => credential.Title, credential => credential.Id);
     }
     return list;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to create a new credentials entry and save it to the data.bin file
        /// </summary>
        /// <param name="passOneUser">The user these credentials are saved on</param>
        /// <param name="creds">Credentials to be created</param>
        /// <param name="path">The location of the data.bin file</param>
        /// <returns>the Id of the credentials just created</returns>
        public int CreateCredentials(PassOneUser passOneUser, PassOneCredentials creds)
        {
            if (GetCredentialsList(passOneUser).ContainsKey(creds.Website))
                throw new TitleAlreadyExistsException();

            var credsSvc = GetService(Services.EntityCredentialsImplementation);
            creds.Id = credsSvc.GetNextIdValue();
            creds.UserId = passOneUser.Id;
            credsSvc.Create(creds);
            return creds.Id;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Method for updating the contents of a saved set of credentials
 /// </summary>
 /// <param name="user">The user whose list contains the credentials in question</param>
 /// <param name="creds">The credentials to be updated</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 public void UpdateCredentials(PassOneUser user, PassOneCredentials creds)
 {
     try
     {
         GetService().Edit(creds);
     }
     catch (CryptographicException)
     {
         throw new EncryptionException();
     }
 }
Ejemplo n.º 5
0
 //Constructor
 public CredentialsSoapTests()
 {
     TestPassOneUser = new PassOneUser(TestPassOneUser.Id, TestPassOneUser.FirstName, TestPassOneUser.LastName, TestPassOneUser.Username, TestPassOneUser.Password,
                         new byte[]
                             {
                                 220, 1, 103, 95, 8, 241, 44, 75, 252, 211, 167, 232, 169, 41, 181, 122, 51, 118,
                                 66, 175, 96
                                 ,
                                 102, 163, 243, 26, 232, 40, 189, 174, 181, 229, 13
                             },
                         new byte[] {229, 219, 79, 110, 4, 98, 121, 23, 194, 214, 43, 142, 22, 247, 128, 206});
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Method for deleting a credentials entry
 /// </summary>
 /// <param name="creds">The credentials to be deleted</param>
 /// <param name="passOneUser">The user whose list contains the credentials in question</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 public void DeleteCredentials(PassOneCredentials creds, PassOneUser passOneUser)
 {
     try
     {
         //creds.Encrypt(user.Encryption);
         GetService(Services.EntityCredentialsImplementation).Delete(creds);
     }
     catch (CryptographicException)
     {
         throw new EncryptionException();
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Method for deleting a credentials entry
 /// </summary>
 /// <param name="creds">The credentials to be deleted</param>
 /// <param name="user">The user whose list contains the credentials in question</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 public void DeleteCredentials(PassOneCredentials creds, PassOneUser user)
 {
     try
     {
         creds.Encrypt(new Encryption(user.K, user.V));
         GetService().Delete(creds);
     }
     catch (CryptographicException)
     {
         throw new EncryptionException();
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Method for retrieving a specific set of credentials
 /// </summary>
 /// <param name="passOneUser">The user whose list contains the credentials in question</param>
 /// <param name="id">The Id of the credentials to be retrieved</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 /// <returns>The requested credentials, if found; if not, returns null</returns>
 public PassOneCredentials FindCredentials(PassOneUser passOneUser, int id)
 {
     try
     {
         var creds =
             ((EntityCredentialsImplementation) GetService(Services.EntityCredentialsImplementation))
                 .RetreiveById(id) as PassOneCredentials;
         return creds;
     }
     catch (CryptographicException)
     {
         throw new EncryptionException();
     }
 }
Ejemplo n.º 9
0
 protected void CredentialsListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (PasswordValue.Visible)
     {
         PasswordValue.Visible = false;
         ShowPasswordButton.Text = "Show Password";
     }
     _passOneUser = (PassOneUser)Session["User"];
     var id = _userManager.GetCredentialsList(_passOneUser)[CredentialsListBox.SelectedItem.Value];
     _selectedCredentials = _credentialsManager.FindCredentials(_passOneUser, id);
     WebsiteValue.Text = _selectedCredentials.Website;
     UrlValue.Text = _selectedCredentials.Url;
     UsernameValue.Text = _selectedCredentials.Username;
     EmailValue.Text = _selectedCredentials.EmailAddress;
     PasswordValue.Text = _selectedCredentials.Password;
 }
        public void TestDelete()
        {
            using (var db = new PassOneContext())
            {
                db.Database.Connection.Open();
                var credsQuery = from c in db.Credentials select c;
                var creds = credsQuery.ToList().FirstOrDefault((creds1 => creds1.Id == TestCredentials.Id));
                db.Credentials.Remove(creds);
                db.SaveChanges();
                var user = new PassOneUser(TestUser.Id, TestUser.FirstName, TestUser.LastName, TestUser.Username,
                                           TestUser.Password, TestUser.k, TestUser.v);
                _service.Delete(user);

                var userQuery = from u in db.Users select u;
                var actual = userQuery.ToList().FirstOrDefault(user1 => user1.Id == user.Id);

                Assert.IsNull(actual);
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Abstract implementation method, returns the requested service
 /// </summary>
 /// <param name="serviceName">Enum - defines the specific service to be retrived</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 /// <param name="passOneUser">Optional parameter - required for credentials services</param>
 /// <returns></returns>
 public override IService GetSoapService(Services serviceName, string path,  PassOneUser passOneUser = null)
 {
     Type type;
     var obj = new object();
     try
     {
         type = Type.GetType(GetImplName(serviceName.ToString()));
         obj = Activator.CreateInstance(type);
     }
     catch (MissingMethodException)
     {
         obj = new CredentialsSoapSerializer(passOneUser);
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception occured: {0}", e);
         throw e;
     }
     ((ISerializeSvc)obj).SetPath(path);
     return (IService) obj;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Method for updating the contents of a saved set of credentials
 /// </summary>
 /// <param name="passOneUser">The user whose list contains the credentials in question</param>
 /// <param name="creds">The credentials to be updated</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 public void UpdateCredentials(PassOneUser passOneUser, PassOneCredentials creds)
 {
     var list = GetCredentialsList(passOneUser);
     if (list.ContainsKey(creds.Website) && FindCredentials(passOneUser, (list[creds.Website])).Id != creds.Id)
         throw new TitleAlreadyExistsException();
     try
     {
         GetService(Services.EntityCredentialsImplementation).Edit(creds);
     }
     catch (CryptographicException)
     {
         throw new EncryptionException();
     }
 }
Ejemplo n.º 13
0
 public PassOneModel_(PassOneUser user)
 {
     _user = user;
        CredentialsList = new Dictionary<string, int>();
        Details = new Details(OnDetailsChanged);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Method to create a new user in the user.bin file, takes a preconstructed User object
 /// </summary>
 /// <param name="passOneUser">The user to be created</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 public void CreateUser(PassOneUser passOneUser, string path )
 {
     GetService(path).Create(passOneUser);
 }
Ejemplo n.º 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _passOneUser = (PassOneUser)Session["User"];
            if (IsPostBack) return;

            CredentialsListBox.SelectedIndexChanged += CredentialsListBox_SelectedIndexChanged;
            UpdateListBox();

            if (CredentialsListBox.Items.Count <= 0) return;

            CredentialsListBox.SelectedIndex = 0;
            CredentialsListBox_SelectedIndexChanged(CredentialsListBox, null);
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Method for retreiving a given service from the Service Layer
 /// </summary>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 /// <param name="passOneUser">Optional parameter - required for credentials services</param>
 /// <returns>The requested service</returns>
 protected IEntitySvc GetService(string path, PassOneUser passOneUser = null)
 {
     return (IEntitySvc)Factory.GetEntityService(_service);
 }
Ejemplo n.º 17
0
 public void DeleteUser(PassOneUser passOneUser, string path)
 {
     GetService(path).Delete(passOneUser);
 }
Ejemplo n.º 18
0
 protected bool Equals(PassOneUser other)
 {
     return string.Equals(FirstName, other.FirstName) && string.Equals(LastName, other.LastName) && string.Equals(Username, other.Username) && string.Equals(Password, other.Password) && Equals(K, other.K) && Equals(V, other.V);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Method to update user information contained in the user.bin file
 /// </summary>
 /// <param name="passOneUser">The new user data</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 public void UpdateUser(PassOneUser passOneUser, string path)
 {
     //GetService(path).UpdateTable(passOneUser);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Method to update user information contained in the user.bin file
 /// </summary>
 /// <param name="user">The new user data</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 public void UpdateUser(PassOneUser user)
 {
     GetService().Edit(user);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Method to create a new user in the user.bin file, takes a preconstructed User object
 /// </summary>
 /// <param name="user">The user to be created</param>
 /// <param name="path">The directory path to where the app can find the PassOne data files</param>
 public void CreateUser(PassOneUser user)
 {
     GetService().Create(user);
 }
Ejemplo n.º 22
0
 public virtual IService GetSoapService(Services serviceName, string path, PassOneUser passOneUser = null)
 {
     return null;
 }
Ejemplo n.º 23
0
 public PassOneModel(PassOneUser user, Dictionary<string, int> dictionary)
 {
     _user = user;
        CredentialsList = dictionary;
        Details = new Details(OnDetailsChanged);
 }
 public void TestRetrieveById()
 {
     var expected = new PassOneUser(TestUser.Id, TestUser.FirstName, TestUser.LastName, TestUser.Username,
                                    TestUser.Password);
     var actual = _service.RetreiveById(TestUser.Id);
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 25
0
 protected bool Equals(PassOneUser other)
 {
     return Id == other.Id && string.Equals(FirstName, other.FirstName) && string.Equals(LastName, other.LastName) && string.Equals(Username, other.Username) && string.Equals(Password, other.Password);
 }
 //Contructor
 public CredentialsSoapSerializer(PassOneUser passOneUser)
 {
     _myPassOneUser = passOneUser;
 }