Beispiel #1
0
 private static void TranslateToMetadata(UserMetadata md, User user)
 {
     // can be null if user is DO or when deleting user
     md.DelegationToken = user.DelegationToken != null ? ConvertBinary(user.DelegationToken.ToUser) : null;
     md.Id = user.Id;
     md.Name = user.Name != null ? ConvertBinary(user.Name) : null;  // can be null when deleting user by clearing his name
     md.SignPublicKey = ConvertBinary(user.SignPublicKey);
 }
Beispiel #2
0
        public void CreateUser(User user)
        {
            LoadMetadata();

            UserMetadata md;
            List<UserMetadata> mds = this.metadata.Users.Where(m => m.Id == user.Id).ToList();
            if (mds.Count == 1)
            {
                md = mds[0];
            }
            else
            {
                md = new UserMetadata();
                this.metadata.Users.Add(md);
            }

            TranslateToMetadata(md, user);

            SaveMetadata();
        }
Beispiel #3
0
        private static User TranslateFromMetadata(UserMetadata md)
        {
            User u = new User();
            u.DelegationToken = md.DelegationToken != null ? new DelegationToken(ConvertBinary(md.DelegationToken)) : null;
            u.Id = md.Id;
            u.Name = md.Name != null ? ConvertBinary(md.Name) : null;
            u.SignPublicKey = ConvertBinary(md.SignPublicKey);

            return u;
        }