x509-store (empty) → 1.4.0
raw patch · 4 files changed
+109/−0 lines, 4 filesdep +basedep +bytestringdep +containerssetup-changed
Dependencies added: base, bytestring, containers, directory, filepath, mtl, pem, process, time, x509
Files
- Data/X509/CertificateStore.hs +40/−0
- LICENSE +27/−0
- Setup.hs +2/−0
- x509-store.cabal +40/−0
+ Data/X509/CertificateStore.hs view
@@ -0,0 +1,40 @@+module Data.X509.CertificateStore+ ( CertificateStore+ , makeCertificateStore+ -- * Queries+ , findCertificate+ , listCertificates+ ) where++import Data.List (foldl')+import Data.Monoid+import Data.X509+import qualified Data.Map as M+import Control.Monad (mplus)++-- | A Collection of certificate or store of certificates.+data CertificateStore = CertificateStore (M.Map DistinguishedName SignedCertificate)+ | CertificateStores [CertificateStore]++instance Monoid CertificateStore where+ mempty = CertificateStore M.empty+ mappend s1@(CertificateStore _) s2@(CertificateStore _) = CertificateStores [s1,s2]+ mappend (CertificateStores l) s2@(CertificateStore _) = CertificateStores (l ++ [s2])+ mappend s1@(CertificateStore _) (CertificateStores l) = CertificateStores ([s1] ++ l)+ mappend (CertificateStores l1) (CertificateStores l2) = CertificateStores (l1 ++ l2)++-- | Create a certificate store out of a list of X509 certificate+makeCertificateStore :: [SignedCertificate] -> CertificateStore+makeCertificateStore = CertificateStore . foldl' accumulate M.empty+ where accumulate m x509 = M.insert (certSubjectDN $ getCertificate x509) x509 m++-- | Find a certificate using the subject distinguished name+findCertificate :: DistinguishedName -> CertificateStore -> Maybe SignedCertificate+findCertificate dn store = lookupIn store+ where lookupIn (CertificateStore m) = M.lookup dn m+ lookupIn (CertificateStores l) = foldl mplus Nothing $ map lookupIn l++-- | List all certificates in a store+listCertificates :: CertificateStore -> [SignedCertificate]+listCertificates (CertificateStore store) = map snd $ M.toList store+listCertificates (CertificateStores l) = concatMap listCertificates l
+ LICENSE view
@@ -0,0 +1,27 @@+Copyright (c) 2010-2013 Vincent Hanquez <vincent@snarc.org>++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:+1. Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.+2. Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.+3. Neither the name of the author nor the names of his contributors+ may be used to endorse or promote products derived from this software+ without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF+SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ x509-store.cabal view
@@ -0,0 +1,40 @@+Name: x509-store+Version: 1.4.0+Description: X.509 collection accessing and storing methods for certificate, crl, exception list+License: BSD3+License-file: LICENSE+Copyright: Vincent Hanquez <vincent@snarc.org>+Author: Vincent Hanquez <vincent@snarc.org>+Maintainer: Vincent Hanquez <vincent@snarc.org>+Synopsis: X.509 collection accessing and storing methods+Build-Type: Simple+Category: Data+stability: experimental+Homepage: http://github.com/vincenthz/hs-certificate+Cabal-Version: >=1.8++Flag test+ Description: Build unit test+ Default: False++Flag executable+ Description: Build the executable+ Default: False++Library+ Build-Depends: base >= 3 && < 5+ , bytestring+ , mtl+ , pem >= 0.1 && < 0.2+ , x509+ , containers+ , directory+ , filepath+ , process+ , time+ Exposed-modules: Data.X509.CertificateStore+ ghc-options: -Wall++source-repository head+ type: git+ location: git://github.com/vincenthz/hs-certificate