module Network.Wai.SAML2.KeyInfo (
KeyInfo(..)
) where
import qualified Data.ByteString as BS
import qualified Data.Text as T
import Data.Text.Encoding
import Text.XML.Cursor
import Network.Wai.SAML2.XML
data KeyInfo = KeyInfo {
KeyInfo -> ByteString
keyInfoCertificate :: BS.ByteString
} deriving (KeyInfo -> KeyInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeyInfo -> KeyInfo -> Bool
$c/= :: KeyInfo -> KeyInfo -> Bool
== :: KeyInfo -> KeyInfo -> Bool
$c== :: KeyInfo -> KeyInfo -> Bool
Eq, Int -> KeyInfo -> ShowS
[KeyInfo] -> ShowS
KeyInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeyInfo] -> ShowS
$cshowList :: [KeyInfo] -> ShowS
show :: KeyInfo -> String
$cshow :: KeyInfo -> String
showsPrec :: Int -> KeyInfo -> ShowS
$cshowsPrec :: Int -> KeyInfo -> ShowS
Show)
instance FromXML KeyInfo where
parseXML :: forall (m :: * -> *). MonadFail m => Cursor -> m KeyInfo
parseXML Cursor
cursor = forall (f :: * -> *) a. Applicative f => a -> f a
pure KeyInfo{
keyInfoCertificate :: ByteString
keyInfoCertificate =
Text -> ByteString
encodeUtf8 forall a b. (a -> b) -> a -> b
$ [Text] -> Text
T.concat forall a b. (a -> b) -> a -> b
$ Cursor
cursor
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Name -> Axis
element (Text -> Name
dsName Text
"X509Data")
forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Name -> Axis
element (Text -> Name
dsName Text
"X509Certificate")
forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
content
}