{-# LANGUAGE FlexibleContexts #-}
-- |
-- Schema Organization and Namespaces
--
-- <https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf saml-core-2.0-os> §1.2
module SAML2.Core.Namespaces 
  ( samlURN
  , samlURNIdentifier
  ) where

import Network.URI (URI(..))

import SAML2.Core.Versioning

samlURN :: SAMLVersion -> [String] -> URI
samlURN :: SAMLVersion -> [String] -> URI
samlURN SAMLVersion
v [String]
l = URI
  { uriScheme :: String
uriScheme = String
"urn:"
  , uriAuthority :: Maybe URIAuth
uriAuthority = Maybe URIAuth
forall a. Maybe a
Nothing
  , uriPath :: String
uriPath = String
"oasis:names:tc:SAML" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> (String -> String) -> [String] -> String
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Char
':'Char -> String -> String
forall a. a -> [a] -> [a]
:) (SAMLVersion -> String
forall a. Show a => a -> String
show SAMLVersion
v String -> [String] -> [String]
forall a. a -> [a] -> [a]
: [String]
l)
  , uriQuery :: String
uriQuery = String
""
  , uriFragment :: String
uriFragment = String
""
  }

samlURNIdentifier :: String -> (SAMLVersion, String) -> URI
samlURNIdentifier :: String -> (SAMLVersion, String) -> URI
samlURNIdentifier String
t (SAMLVersion
v, String
n) = SAMLVersion -> [String] -> URI
samlURN SAMLVersion
v [String
t, String
n]