diff options
author | joe <joe@jerkface.net> | 2014-04-14 21:57:52 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-04-14 21:57:52 -0400 |
commit | 8ae8570ca4d03314b52045c5a4e71078e7db9593 (patch) | |
tree | 2c14762f4ecbe7f29a5d0ffc52dde7ed3638c319 /KeyRing.hs | |
parent | db0e17c179453e22cbadfb8b514d2e7efede170d (diff) |
imports wallet files
Diffstat (limited to 'KeyRing.hs')
-rw-r--r-- | KeyRing.hs | 46 |
1 files changed, 25 insertions, 21 deletions
@@ -418,7 +418,7 @@ data KeySpec = | |||
418 | 418 | ||
419 | 419 | ||
420 | buildKeyDB :: FilePath -> FilePath -> Maybe String -> KeyRingData | 420 | buildKeyDB :: FilePath -> FilePath -> Maybe String -> KeyRingData |
421 | -> IO ((KeyDB,Maybe String),[(FilePath,KikiReportAction)]) | 421 | -> IO (KikiCondition ((KeyDB,Maybe String),[(FilePath,KikiReportAction)])) |
422 | buildKeyDB secring pubring grip0 keyring = do | 422 | buildKeyDB secring pubring grip0 keyring = do |
423 | let isring (KeyRingFile {}) = True | 423 | let isring (KeyRingFile {}) = True |
424 | isring _ = False | 424 | isring _ = False |
@@ -457,20 +457,22 @@ buildKeyDB secring pubring grip0 keyring = do | |||
457 | (tag,top) <- Map.toList m | 457 | (tag,top) <- Map.toList m |
458 | return (top,fname,sub,tag) | 458 | return (top,fname,sub,tag) |
459 | 459 | ||
460 | {- | 460 | doDecrypt = todo |
461 | |||
461 | importWalletKey db' (top,fname,sub,tag) = do | 462 | importWalletKey db' (top,fname,sub,tag) = do |
462 | doImportG doDecrypt | 463 | try db' $ \(db',report0) -> do |
464 | r <- doImportG doDecrypt | ||
463 | db' | 465 | db' |
464 | (fmap keykey $ maybeToList wk) | 466 | (fmap keykey $ maybeToList wk) |
465 | tag | 467 | tag |
466 | fname | 468 | fname |
467 | sub | 469 | sub |
468 | -} | 470 | try r $ \(db'',report) -> do |
469 | 471 | return $ KikiSuccess (db'', report0 ++ report) | |
470 | -- db <- foldM importWalletKey db0 ts | ||
471 | (db,report) <- return (db0,[]) -- todo | ||
472 | 472 | ||
473 | return ( (db, grip), report ) | 473 | db <- foldM importWalletKey (KikiSuccess (db0,[])) wms' |
474 | try db $ \(db,report) -> do | ||
475 | return $ KikiSuccess ( (db, grip), report ) | ||
474 | 476 | ||
475 | torhash key = maybe "" id $ derToBase32 <$> derRSA key | 477 | torhash key = maybe "" id $ derToBase32 <$> derRSA key |
476 | 478 | ||
@@ -591,19 +593,21 @@ runKeyRing keyring op = do | |||
591 | ret = if null failed then KikiSuccess () else FailedToLock failed | 593 | ret = if null failed then KikiSuccess () else FailedToLock failed |
592 | ret <- case functorToEither ret of | 594 | ret <- case functorToEither ret of |
593 | Right {} -> do | 595 | Right {} -> do |
594 | ((db,grip), report1) <- buildKeyDB secring pubring grip0 keyring -- build db | 596 | bresult <- buildKeyDB secring pubring grip0 keyring -- build db |
595 | 597 | case functorToEither bresult of | |
596 | a <- return $ op KeyRingRuntime | 598 | Left e -> return $ KikiResult e [] |
597 | { rtPubring = pubring | 599 | Right ((db,grip), report1) -> do |
598 | , rtSecring = secring | 600 | a <- return $ op KeyRingRuntime |
599 | , rtRings = [] -- todo secring:pubring:keyringFiles keyring | 601 | { rtPubring = pubring |
600 | , rtWallets = [] -- todo walletFiles keyring | 602 | , rtSecring = secring |
601 | , rtGrip = grip | 603 | , rtRings = [] -- todo secring:pubring:keyringFiles keyring |
602 | , rtKeyDB = db | 604 | , rtWallets = [] -- todo walletFiles keyring |
603 | } | 605 | , rtGrip = grip |
604 | report2 <- todo -- write files | 606 | , rtKeyDB = db |
605 | 607 | } | |
606 | return $ KikiResult (KikiSuccess a) (report1 ++ report2) | 608 | report2 <- todo -- write files |
609 | |||
610 | return $ KikiResult (KikiSuccess a) (report1 ++ report2) | ||
607 | Left err -> return $ KikiResult err [] | 611 | Left err -> return $ KikiResult err [] |
608 | 612 | ||
609 | forM_ lked $ \(Just lk, fname) -> do dotlock_release lk | 613 | forM_ lked $ \(Just lk, fname) -> do dotlock_release lk |