Beispiel #1
0
 public void importData(String filepathName)
 {
     try
     {
         FileStream   fileStream = new FileStream(filepathName, FileMode.Open);
         BinaryReader reader     = new BinaryReader(fileStream, Encoding.Default);
         String       buffer     = reader.ReadString();
         String       decrypted  = buffer;
         reader.Close();
         fileStream.Close();
         Utils.log("Data loaded from " + filepathName);
         EncryptedDatafile newDatafile = JsonConvert.DeserializeObject <EncryptedDatafile>(decrypted);
         //비밀번호 덮어씌워짐 방지 -> 체크
         if (!datafile.getPureRootPassword().Equals(newDatafile.getPureRootPassword()))
         {
             //서로 다른 비밀번호의 데이터 파일 import 시 비번 묻기
             RequireImportedDataPWWindow requirePWWindow = new RequireImportedDataPWWindow(newDatafile.getPureRootPassword());
             bool?result = requirePWWindow.ShowDialog();
             if (result == true)
             {
                 setDataFileExceptPassword(newDatafile);
             }
         }
         else
         {
             this.datafile = newDatafile;
         }
         saveFile();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
Beispiel #2
0
        public void loadFiles()
        {
            try
            {
                FileStream   fileStream = new FileStream(SECURE_KEY_STORAGE_NAME, FileMode.Open);
                BinaryReader reader     = new BinaryReader(fileStream, Encoding.Default);
                String       buffer     = reader.ReadString();
                String       decrypted  = StringSecure.decodeBase64(buffer);
                reader.Close();
                fileStream.Close();
                Utils.log("Secure Key loaded!");
                SecureKeyPair loadedSecureKey = JsonConvert.DeserializeObject <SecureKeyPair>(decrypted);
                this.stringSecure = new StringSecure(loadedSecureKey);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            try
            {
                FileStream   fileStream = new FileStream(getEncodedDatafileName(), FileMode.Open);
                BinaryReader reader     = new BinaryReader(fileStream, Encoding.Default);
                String       buffer     = reader.ReadString();
                String       decrypted  = buffer;
                reader.Close();
                fileStream.Close();
                Utils.log("Data loaded!");
                datafile = JsonConvert.DeserializeObject <EncryptedDatafile>(decrypted);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Beispiel #3
0
 public MainWindow()
 {
     InitializeComponent();
     this.Title            = Utils.getDefaultWindowTitle();
     WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
     fileManager           = new DatafileManager();
     datafile = fileManager.getCurrentValidDataFile();
     rootPasswordHint.Content = "[힌트] " + (datafile.RootPasswordHint == "" ? "초기 비밀번호는 root입니다." : datafile.RootPasswordHint);
     versionInfo.Content      = Utils.getDevelopmentInfo();
 }
        public ModifyAccountWindow(DatafileManager manager, String id)
        {
            InitializeComponent();
            fileManager = manager;
            datafile    = fileManager.getCurrentValidDataFile();
            AccountInfo account = datafile.getAccountInfo(id);

            lblQuestion.Content = formatTitle(account.InfoTitle);
            itemID = id;
        }
Beispiel #5
0
        public AddNewKeyPairWindow(DatafileManager manager, String id)
        {
            InitializeComponent();
            fileManager = manager;
            datafile    = fileManager.getCurrentValidDataFile();
            ID_KEY      = id;

            AccountInfo accountInfo = datafile.getAccountInfo(ID_KEY);

            this.Title = "'" + accountInfo.InfoTitle + "' 에 새로운 키페어 추가";
        }
        public ModifyKeyPairWindow(DatafileManager manager, String accountId, String keyPairId)
        {
            InitializeComponent();
            fileManager        = manager;
            datafile           = fileManager.getCurrentValidDataFile();
            encryptedAccountId = accountId;
            encryptedKeyPairId = keyPairId;

            EncryptedKeyMap keyInfo = datafile.getAccountInfo(accountId).getEncryptedKeyMapById(keyPairId);

            newKeyName.Text  = keyInfo.KeyTitle;
            newKeyValue.Text = keyInfo.PureValue;
        }
Beispiel #7
0
 public DatafileManager()
 {
     if (File.Exists(getEncodedDatafileName()))
     {
         //파일 존재함, 이후에 유효한지 검사
         loadFiles();
     }
     else
     {
         //파일 없음, 생성
         SecureKeyPair secureKeyPair = new SecureKeyPair();
         stringSecure = new StringSecure(secureKeyPair);
         datafile     = new EncryptedDatafile(stringSecure);
         saveSecureKeyFile(secureKeyPair);
     }
 }
Beispiel #8
0
 public void importRawData(String filepathName)
 {
     try
     {
         FileStream   fileStream = new FileStream(filepathName, FileMode.Open);
         BinaryReader reader     = new BinaryReader(fileStream, Encoding.Default);
         String       buffer     = reader.ReadString();
         reader.Close();
         fileStream.Close();
         Utils.log("Raw Data loaded from " + filepathName);
         RawDatafile rawFile = JsonConvert.DeserializeObject <RawDatafile>(buffer);
         this.datafile = rawFile.convertToEncryptedData(stringSecure);
         //키가 다른 것에 대한 exception 처리할 것
         saveFile();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
Beispiel #9
0
 public void setDataFileExceptPassword(EncryptedDatafile encryptedDatafile)
 {
     //키페어 리스트만 저장
     datafile.setNewAccountTable(encryptedDatafile.AccountTable);
 }
 public AddNewAccountWindow(DatafileManager manager)
 {
     InitializeComponent();
     fileManager = manager;
     datafile    = fileManager.getCurrentValidDataFile();
 }
Beispiel #11
0
        /* ------------------------------------------- TOOL ------------------------------------------- */

        //초기 데이터 업데이트
        private void updateData()
        {
            fileManager.loadFiles();
            datafile = fileManager.getCurrentValidDataFile();
        }
 public RootPasswordSetting(DatafileManager manager)
 {
     InitializeComponent();
     fileManager = manager;
     datafile    = fileManager.getCurrentValidDataFile();
 }