|
|
|
|
@ -16,6 +16,7 @@ import qualified Data.ByteString.Char8 as BS8
@@ -16,6 +16,7 @@ import qualified Data.ByteString.Char8 as BS8
|
|
|
|
|
import qualified Data.ByteString.Lazy as BL |
|
|
|
|
import qualified Data.Digest.Pure.MD5 as MD5 |
|
|
|
|
import qualified Data.List as L |
|
|
|
|
import Data.Word (Word8) |
|
|
|
|
import Data.XML.Pickle |
|
|
|
|
import Data.XML.Types |
|
|
|
|
|
|
|
|
|
@ -93,7 +94,7 @@ createResponse g hostname username passwd' pairs = let
@@ -93,7 +94,7 @@ createResponse g hostname username passwd' pairs = let
|
|
|
|
|
uname = Text.encodeUtf8 username |
|
|
|
|
passwd = Text.encodeUtf8 passwd' |
|
|
|
|
realm = Text.encodeUtf8 hostname |
|
|
|
|
-- Using Char instead of Word8 for random 1.0.0.0 (GHC 7) |
|
|
|
|
-- Using Int instead of Word8 for random 1.0.0.0 (GHC 7) |
|
|
|
|
-- compatibility. |
|
|
|
|
cnonce = BS.tail . BS.init . |
|
|
|
|
B64.encode . BS.pack . map toWord8 . take 8 $ Random.randoms g |
|
|
|
|
@ -122,7 +123,7 @@ createResponse g hostname username passwd' pairs = let
@@ -122,7 +123,7 @@ createResponse g hostname username passwd' pairs = let
|
|
|
|
|
in Text.decodeUtf8 $ B64.encode response |
|
|
|
|
where |
|
|
|
|
quote x = BS.concat ["\"",x,"\""] |
|
|
|
|
toWord8 x = fromIntegral (abs (x :: Int) `mod` 256) :: Binary.Word8 |
|
|
|
|
toWord8 x = fromIntegral (x :: Int) :: Word8 |
|
|
|
|
|
|
|
|
|
toPairs :: BS.ByteString -> Either String [(BS.ByteString, BS.ByteString)] |
|
|
|
|
toPairs = AP.parseOnly . flip AP.sepBy1 (void $ AP.char ',') $ do |
|
|
|
|
|