gi-gio-0.2.44.12: GI/Gio/Objects/TlsCertificate.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}
module GI.Gio.Objects.TlsCertificate
(
-- * Exported types
TlsCertificate(..) ,
TlsCertificateK ,
toTlsCertificate ,
noTlsCertificate ,
-- * Methods
-- ** tlsCertificateGetIssuer
tlsCertificateGetIssuer ,
-- ** tlsCertificateIsSame
tlsCertificateIsSame ,
-- ** tlsCertificateListNewFromFile
tlsCertificateListNewFromFile ,
-- ** tlsCertificateNewFromFile
tlsCertificateNewFromFile ,
-- ** tlsCertificateNewFromFiles
tlsCertificateNewFromFiles ,
-- ** tlsCertificateNewFromPem
tlsCertificateNewFromPem ,
-- ** tlsCertificateVerify
tlsCertificateVerify ,
-- * Properties
-- ** Certificate
TlsCertificateCertificatePropertyInfo ,
constructTlsCertificateCertificate ,
getTlsCertificateCertificate ,
-- ** CertificatePem
TlsCertificateCertificatePemPropertyInfo,
constructTlsCertificateCertificatePem ,
getTlsCertificateCertificatePem ,
-- ** Issuer
TlsCertificateIssuerPropertyInfo ,
constructTlsCertificateIssuer ,
getTlsCertificateIssuer ,
-- ** PrivateKey
TlsCertificatePrivateKeyPropertyInfo ,
constructTlsCertificatePrivateKey ,
-- ** PrivateKeyPem
TlsCertificatePrivateKeyPemPropertyInfo ,
constructTlsCertificatePrivateKeyPem ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GObject as GObject
newtype TlsCertificate = TlsCertificate (ForeignPtr TlsCertificate)
foreign import ccall "g_tls_certificate_get_type"
c_g_tls_certificate_get_type :: IO GType
type instance ParentTypes TlsCertificate = TlsCertificateParentTypes
type TlsCertificateParentTypes = '[GObject.Object]
instance GObject TlsCertificate where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_g_tls_certificate_get_type
class GObject o => TlsCertificateK o
instance (GObject o, IsDescendantOf TlsCertificate o) => TlsCertificateK o
toTlsCertificate :: TlsCertificateK o => o -> IO TlsCertificate
toTlsCertificate = unsafeCastTo TlsCertificate
noTlsCertificate :: Maybe TlsCertificate
noTlsCertificate = Nothing
-- VVV Prop "certificate"
-- Type: TByteArray
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
getTlsCertificateCertificate :: (MonadIO m, TlsCertificateK o) => o -> m ByteString
getTlsCertificateCertificate obj = liftIO $ getObjectPropertyByteArray obj "certificate"
constructTlsCertificateCertificate :: ByteString -> IO ([Char], GValue)
constructTlsCertificateCertificate val = constructObjectPropertyByteArray "certificate" val
data TlsCertificateCertificatePropertyInfo
instance AttrInfo TlsCertificateCertificatePropertyInfo where
type AttrAllowedOps TlsCertificateCertificatePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint TlsCertificateCertificatePropertyInfo = (~) ByteString
type AttrBaseTypeConstraint TlsCertificateCertificatePropertyInfo = TlsCertificateK
type AttrGetType TlsCertificateCertificatePropertyInfo = ByteString
type AttrLabel TlsCertificateCertificatePropertyInfo = "TlsCertificate::certificate"
attrGet _ = getTlsCertificateCertificate
attrSet _ = undefined
attrConstruct _ = constructTlsCertificateCertificate
-- VVV Prop "certificate-pem"
-- Type: TBasicType TUTF8
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
getTlsCertificateCertificatePem :: (MonadIO m, TlsCertificateK o) => o -> m T.Text
getTlsCertificateCertificatePem obj = liftIO $ getObjectPropertyString obj "certificate-pem"
constructTlsCertificateCertificatePem :: T.Text -> IO ([Char], GValue)
constructTlsCertificateCertificatePem val = constructObjectPropertyString "certificate-pem" val
data TlsCertificateCertificatePemPropertyInfo
instance AttrInfo TlsCertificateCertificatePemPropertyInfo where
type AttrAllowedOps TlsCertificateCertificatePemPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint TlsCertificateCertificatePemPropertyInfo = (~) T.Text
type AttrBaseTypeConstraint TlsCertificateCertificatePemPropertyInfo = TlsCertificateK
type AttrGetType TlsCertificateCertificatePemPropertyInfo = T.Text
type AttrLabel TlsCertificateCertificatePemPropertyInfo = "TlsCertificate::certificate-pem"
attrGet _ = getTlsCertificateCertificatePem
attrSet _ = undefined
attrConstruct _ = constructTlsCertificateCertificatePem
-- VVV Prop "issuer"
-- Type: TInterface "Gio" "TlsCertificate"
-- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
getTlsCertificateIssuer :: (MonadIO m, TlsCertificateK o) => o -> m TlsCertificate
getTlsCertificateIssuer obj = liftIO $ getObjectPropertyObject obj "issuer" TlsCertificate
constructTlsCertificateIssuer :: (TlsCertificateK a) => a -> IO ([Char], GValue)
constructTlsCertificateIssuer val = constructObjectPropertyObject "issuer" val
data TlsCertificateIssuerPropertyInfo
instance AttrInfo TlsCertificateIssuerPropertyInfo where
type AttrAllowedOps TlsCertificateIssuerPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
type AttrSetTypeConstraint TlsCertificateIssuerPropertyInfo = TlsCertificateK
type AttrBaseTypeConstraint TlsCertificateIssuerPropertyInfo = TlsCertificateK
type AttrGetType TlsCertificateIssuerPropertyInfo = TlsCertificate
type AttrLabel TlsCertificateIssuerPropertyInfo = "TlsCertificate::issuer"
attrGet _ = getTlsCertificateIssuer
attrSet _ = undefined
attrConstruct _ = constructTlsCertificateIssuer
-- VVV Prop "private-key"
-- Type: TByteArray
-- Flags: [PropertyWritable,PropertyConstructOnly]
constructTlsCertificatePrivateKey :: ByteString -> IO ([Char], GValue)
constructTlsCertificatePrivateKey val = constructObjectPropertyByteArray "private-key" val
data TlsCertificatePrivateKeyPropertyInfo
instance AttrInfo TlsCertificatePrivateKeyPropertyInfo where
type AttrAllowedOps TlsCertificatePrivateKeyPropertyInfo = '[ 'AttrConstruct]
type AttrSetTypeConstraint TlsCertificatePrivateKeyPropertyInfo = (~) ByteString
type AttrBaseTypeConstraint TlsCertificatePrivateKeyPropertyInfo = TlsCertificateK
type AttrGetType TlsCertificatePrivateKeyPropertyInfo = ()
type AttrLabel TlsCertificatePrivateKeyPropertyInfo = "TlsCertificate::private-key"
attrGet _ = undefined
attrSet _ = undefined
attrConstruct _ = constructTlsCertificatePrivateKey
-- VVV Prop "private-key-pem"
-- Type: TBasicType TUTF8
-- Flags: [PropertyWritable,PropertyConstructOnly]
constructTlsCertificatePrivateKeyPem :: T.Text -> IO ([Char], GValue)
constructTlsCertificatePrivateKeyPem val = constructObjectPropertyString "private-key-pem" val
data TlsCertificatePrivateKeyPemPropertyInfo
instance AttrInfo TlsCertificatePrivateKeyPemPropertyInfo where
type AttrAllowedOps TlsCertificatePrivateKeyPemPropertyInfo = '[ 'AttrConstruct]
type AttrSetTypeConstraint TlsCertificatePrivateKeyPemPropertyInfo = (~) T.Text
type AttrBaseTypeConstraint TlsCertificatePrivateKeyPemPropertyInfo = TlsCertificateK
type AttrGetType TlsCertificatePrivateKeyPemPropertyInfo = ()
type AttrLabel TlsCertificatePrivateKeyPemPropertyInfo = "TlsCertificate::private-key-pem"
attrGet _ = undefined
attrSet _ = undefined
attrConstruct _ = constructTlsCertificatePrivateKeyPem
type instance AttributeList TlsCertificate = TlsCertificateAttributeList
type TlsCertificateAttributeList = ('[ '("certificate", TlsCertificateCertificatePropertyInfo), '("certificate-pem", TlsCertificateCertificatePemPropertyInfo), '("issuer", TlsCertificateIssuerPropertyInfo), '("private-key", TlsCertificatePrivateKeyPropertyInfo), '("private-key-pem", TlsCertificatePrivateKeyPemPropertyInfo)] :: [(Symbol, *)])
type instance SignalList TlsCertificate = TlsCertificateSignalList
type TlsCertificateSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
-- method TlsCertificate::new_from_file
-- method type : Constructor
-- Args : [Arg {argName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsCertificate"
-- throws : True
-- Skip return : False
foreign import ccall "g_tls_certificate_new_from_file" g_tls_certificate_new_from_file ::
CString -> -- file : TBasicType TUTF8
Ptr (Ptr GError) -> -- error
IO (Ptr TlsCertificate)
tlsCertificateNewFromFile ::
(MonadIO m) =>
T.Text -> -- file
m TlsCertificate
tlsCertificateNewFromFile file = liftIO $ do
file' <- textToCString file
onException (do
result <- propagateGError $ g_tls_certificate_new_from_file file'
checkUnexpectedReturnNULL "g_tls_certificate_new_from_file" result
result' <- (wrapObject TlsCertificate) result
freeMem file'
return result'
) (do
freeMem file'
)
-- method TlsCertificate::new_from_files
-- method type : Constructor
-- Args : [Arg {argName = "cert_file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key_file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "cert_file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key_file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsCertificate"
-- throws : True
-- Skip return : False
foreign import ccall "g_tls_certificate_new_from_files" g_tls_certificate_new_from_files ::
CString -> -- cert_file : TBasicType TUTF8
CString -> -- key_file : TBasicType TUTF8
Ptr (Ptr GError) -> -- error
IO (Ptr TlsCertificate)
tlsCertificateNewFromFiles ::
(MonadIO m) =>
T.Text -> -- cert_file
T.Text -> -- key_file
m TlsCertificate
tlsCertificateNewFromFiles cert_file key_file = liftIO $ do
cert_file' <- textToCString cert_file
key_file' <- textToCString key_file
onException (do
result <- propagateGError $ g_tls_certificate_new_from_files cert_file' key_file'
checkUnexpectedReturnNULL "g_tls_certificate_new_from_files" result
result' <- (wrapObject TlsCertificate) result
freeMem cert_file'
freeMem key_file'
return result'
) (do
freeMem cert_file'
freeMem key_file'
)
-- method TlsCertificate::new_from_pem
-- method type : Constructor
-- Args : [Arg {argName = "data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsCertificate"
-- throws : True
-- Skip return : False
foreign import ccall "g_tls_certificate_new_from_pem" g_tls_certificate_new_from_pem ::
CString -> -- data : TBasicType TUTF8
Int64 -> -- length : TBasicType TInt64
Ptr (Ptr GError) -> -- error
IO (Ptr TlsCertificate)
tlsCertificateNewFromPem ::
(MonadIO m) =>
T.Text -> -- data
Int64 -> -- length
m TlsCertificate
tlsCertificateNewFromPem data_ length_ = liftIO $ do
data_' <- textToCString data_
onException (do
result <- propagateGError $ g_tls_certificate_new_from_pem data_' length_
checkUnexpectedReturnNULL "g_tls_certificate_new_from_pem" result
result' <- (wrapObject TlsCertificate) result
freeMem data_'
return result'
) (do
freeMem data_'
)
-- method TlsCertificate::get_issuer
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsCertificate"
-- throws : False
-- Skip return : False
foreign import ccall "g_tls_certificate_get_issuer" g_tls_certificate_get_issuer ::
Ptr TlsCertificate -> -- _obj : TInterface "Gio" "TlsCertificate"
IO (Ptr TlsCertificate)
tlsCertificateGetIssuer ::
(MonadIO m, TlsCertificateK a) =>
a -> -- _obj
m TlsCertificate
tlsCertificateGetIssuer _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- g_tls_certificate_get_issuer _obj'
checkUnexpectedReturnNULL "g_tls_certificate_get_issuer" result
result' <- (newObject TlsCertificate) result
touchManagedPtr _obj
return result'
-- method TlsCertificate::is_same
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cert_two", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cert_two", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "g_tls_certificate_is_same" g_tls_certificate_is_same ::
Ptr TlsCertificate -> -- _obj : TInterface "Gio" "TlsCertificate"
Ptr TlsCertificate -> -- cert_two : TInterface "Gio" "TlsCertificate"
IO CInt
tlsCertificateIsSame ::
(MonadIO m, TlsCertificateK a, TlsCertificateK b) =>
a -> -- _obj
b -> -- cert_two
m Bool
tlsCertificateIsSame _obj cert_two = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
let cert_two' = unsafeManagedPtrCastPtr cert_two
result <- g_tls_certificate_is_same _obj' cert_two'
let result' = (/= 0) result
touchManagedPtr _obj
touchManagedPtr cert_two
return result'
-- method TlsCertificate::verify
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "identity", argType = TInterface "Gio" "SocketConnectable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "trusted_ca", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "identity", argType = TInterface "Gio" "SocketConnectable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "trusted_ca", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsCertificateFlags"
-- throws : False
-- Skip return : False
foreign import ccall "g_tls_certificate_verify" g_tls_certificate_verify ::
Ptr TlsCertificate -> -- _obj : TInterface "Gio" "TlsCertificate"
Ptr SocketConnectable -> -- identity : TInterface "Gio" "SocketConnectable"
Ptr TlsCertificate -> -- trusted_ca : TInterface "Gio" "TlsCertificate"
IO CUInt
tlsCertificateVerify ::
(MonadIO m, TlsCertificateK a, SocketConnectableK b, TlsCertificateK c) =>
a -> -- _obj
Maybe (b) -> -- identity
Maybe (c) -> -- trusted_ca
m [TlsCertificateFlags]
tlsCertificateVerify _obj identity trusted_ca = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
maybeIdentity <- case identity of
Nothing -> return nullPtr
Just jIdentity -> do
let jIdentity' = unsafeManagedPtrCastPtr jIdentity
return jIdentity'
maybeTrusted_ca <- case trusted_ca of
Nothing -> return nullPtr
Just jTrusted_ca -> do
let jTrusted_ca' = unsafeManagedPtrCastPtr jTrusted_ca
return jTrusted_ca'
result <- g_tls_certificate_verify _obj' maybeIdentity maybeTrusted_ca
let result' = wordToGFlags result
touchManagedPtr _obj
whenJust identity touchManagedPtr
whenJust trusted_ca touchManagedPtr
return result'
-- method TlsCertificate::list_new_from_file
-- method type : MemberFunction
-- Args : [Arg {argName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGList (TInterface "Gio" "TlsCertificate")
-- throws : True
-- Skip return : False
foreign import ccall "g_tls_certificate_list_new_from_file" g_tls_certificate_list_new_from_file ::
CString -> -- file : TBasicType TUTF8
Ptr (Ptr GError) -> -- error
IO (Ptr (GList (Ptr TlsCertificate)))
tlsCertificateListNewFromFile ::
(MonadIO m) =>
T.Text -> -- file
m [TlsCertificate]
tlsCertificateListNewFromFile file = liftIO $ do
file' <- textToCString file
onException (do
result <- propagateGError $ g_tls_certificate_list_new_from_file file'
checkUnexpectedReturnNULL "g_tls_certificate_list_new_from_file" result
result' <- unpackGList result
result'' <- mapM (wrapObject TlsCertificate) result'
g_list_free result
freeMem file'
return result''
) (do
freeMem file'
)