{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) /No description available in the introspection data./ -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Soup.Objects.AuthDomainDigest ( -- * Exported types AuthDomainDigest(..) , IsAuthDomainDigest , toAuthDomainDigest , noAuthDomainDigest , -- * Methods -- ** encodePassword #method:encodePassword# authDomainDigestEncodePassword , -- ** setAuthCallback #method:setAuthCallback# #if ENABLE_OVERLOADING AuthDomainDigestSetAuthCallbackMethodInfo, #endif authDomainDigestSetAuthCallback , -- * Properties -- ** authCallback #attr:authCallback# {- | The 'GI.Soup.Callbacks.AuthDomainDigestAuthCallback' -} #if ENABLE_OVERLOADING AuthDomainDigestAuthCallbackPropertyInfo, #endif #if ENABLE_OVERLOADING authDomainDigestAuthCallback , #endif clearAuthDomainDigestAuthCallback , constructAuthDomainDigestAuthCallback , getAuthDomainDigestAuthCallback , setAuthDomainDigestAuthCallback , -- ** authData #attr:authData# {- | The data to pass to the 'GI.Soup.Callbacks.AuthDomainDigestAuthCallback' -} #if ENABLE_OVERLOADING AuthDomainDigestAuthDataPropertyInfo , #endif #if ENABLE_OVERLOADING authDomainDigestAuthData , #endif constructAuthDomainDigestAuthData , getAuthDomainDigestAuthData , setAuthDomainDigestAuthData , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.ShortPrelude as SP import qualified Data.GI.Base.Overloading as O import qualified Prelude as P import qualified Data.GI.Base.Attributes as GI.Attributes import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr import qualified Data.GI.Base.GClosure as B.GClosure import qualified Data.GI.Base.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GValue as B.GValue import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack import qualified Data.GI.Base.Properties as B.Properties import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import qualified Foreign.Ptr as FP import qualified GHC.OverloadedLabels as OL import qualified GI.GLib.Callbacks as GLib.Callbacks import qualified GI.GObject.Objects.Object as GObject.Object import qualified GI.Soup.Callbacks as Soup.Callbacks import {-# SOURCE #-} qualified GI.Soup.Objects.AuthDomain as Soup.AuthDomain -- | Memory-managed wrapper type. newtype AuthDomainDigest = AuthDomainDigest (ManagedPtr AuthDomainDigest) foreign import ccall "soup_auth_domain_digest_get_type" c_soup_auth_domain_digest_get_type :: IO GType instance GObject AuthDomainDigest where gobjectType = c_soup_auth_domain_digest_get_type -- | Type class for types which can be safely cast to `AuthDomainDigest`, for instance with `toAuthDomainDigest`. class (GObject o, O.IsDescendantOf AuthDomainDigest o) => IsAuthDomainDigest o instance (GObject o, O.IsDescendantOf AuthDomainDigest o) => IsAuthDomainDigest o instance O.HasParentTypes AuthDomainDigest type instance O.ParentTypes AuthDomainDigest = '[Soup.AuthDomain.AuthDomain, GObject.Object.Object] -- | Cast to `AuthDomainDigest`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`. toAuthDomainDigest :: (MonadIO m, IsAuthDomainDigest o) => o -> m AuthDomainDigest toAuthDomainDigest = liftIO . unsafeCastTo AuthDomainDigest -- | A convenience alias for `Nothing` :: `Maybe` `AuthDomainDigest`. noAuthDomainDigest :: Maybe AuthDomainDigest noAuthDomainDigest = Nothing #if ENABLE_OVERLOADING type family ResolveAuthDomainDigestMethod (t :: Symbol) (o :: *) :: * where ResolveAuthDomainDigestMethod "accepts" o = Soup.AuthDomain.AuthDomainAcceptsMethodInfo ResolveAuthDomainDigestMethod "addPath" o = Soup.AuthDomain.AuthDomainAddPathMethodInfo ResolveAuthDomainDigestMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo ResolveAuthDomainDigestMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo ResolveAuthDomainDigestMethod "challenge" o = Soup.AuthDomain.AuthDomainChallengeMethodInfo ResolveAuthDomainDigestMethod "checkPassword" o = Soup.AuthDomain.AuthDomainCheckPasswordMethodInfo ResolveAuthDomainDigestMethod "covers" o = Soup.AuthDomain.AuthDomainCoversMethodInfo ResolveAuthDomainDigestMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo ResolveAuthDomainDigestMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo ResolveAuthDomainDigestMethod "getv" o = GObject.Object.ObjectGetvMethodInfo ResolveAuthDomainDigestMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo ResolveAuthDomainDigestMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo ResolveAuthDomainDigestMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo ResolveAuthDomainDigestMethod "ref" o = GObject.Object.ObjectRefMethodInfo ResolveAuthDomainDigestMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo ResolveAuthDomainDigestMethod "removePath" o = Soup.AuthDomain.AuthDomainRemovePathMethodInfo ResolveAuthDomainDigestMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo ResolveAuthDomainDigestMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo ResolveAuthDomainDigestMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo ResolveAuthDomainDigestMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo ResolveAuthDomainDigestMethod "tryGenericAuthCallback" o = Soup.AuthDomain.AuthDomainTryGenericAuthCallbackMethodInfo ResolveAuthDomainDigestMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo ResolveAuthDomainDigestMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo ResolveAuthDomainDigestMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo ResolveAuthDomainDigestMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo ResolveAuthDomainDigestMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo ResolveAuthDomainDigestMethod "getRealm" o = Soup.AuthDomain.AuthDomainGetRealmMethodInfo ResolveAuthDomainDigestMethod "setAuthCallback" o = AuthDomainDigestSetAuthCallbackMethodInfo ResolveAuthDomainDigestMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo ResolveAuthDomainDigestMethod "setFilter" o = Soup.AuthDomain.AuthDomainSetFilterMethodInfo ResolveAuthDomainDigestMethod "setGenericAuthCallback" o = Soup.AuthDomain.AuthDomainSetGenericAuthCallbackMethodInfo ResolveAuthDomainDigestMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo ResolveAuthDomainDigestMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveAuthDomainDigestMethod t AuthDomainDigest, O.MethodInfo info AuthDomainDigest p) => OL.IsLabel t (AuthDomainDigest -> p) where #if MIN_VERSION_base(4,10,0) fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #else fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif #endif -- VVV Prop "auth-callback" -- Type: TInterface (Name {namespace = "Soup", name = "AuthDomainDigestAuthCallback"}) -- Flags: [PropertyReadable,PropertyWritable] -- Nullable: (Nothing,Nothing) {- | Get the value of the “@auth-callback@” property. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' authDomainDigest #authCallback @ -} getAuthDomainDigestAuthCallback :: (MonadIO m, IsAuthDomainDigest o) => o -> m (Maybe Soup.Callbacks.AuthDomainDigestAuthCallback_WithClosures) getAuthDomainDigestAuthCallback obj = liftIO $ B.Properties.getObjectPropertyCallback obj "auth-callback" Soup.Callbacks.dynamic_AuthDomainDigestAuthCallback {- | Set the value of the “@auth-callback@” property. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' authDomainDigest [ #authCallback 'Data.GI.Base.Attributes.:=' value ] @ -} setAuthDomainDigestAuthCallback :: (MonadIO m, IsAuthDomainDigest o) => o -> FunPtr Soup.Callbacks.C_AuthDomainDigestAuthCallback -> m () setAuthDomainDigestAuthCallback obj val = liftIO $ B.Properties.setObjectPropertyCallback obj "auth-callback" val {- | Construct a `GValueConstruct` with valid value for the “@auth-callback@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`. -} constructAuthDomainDigestAuthCallback :: (IsAuthDomainDigest o) => FunPtr Soup.Callbacks.C_AuthDomainDigestAuthCallback -> IO (GValueConstruct o) constructAuthDomainDigestAuthCallback val = B.Properties.constructObjectPropertyCallback "auth-callback" val {- | Set the value of the “@auth-callback@” property to `Nothing`. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.clear' #authCallback @ -} clearAuthDomainDigestAuthCallback :: (MonadIO m, IsAuthDomainDigest o) => o -> m () clearAuthDomainDigestAuthCallback obj = liftIO $ B.Properties.setObjectPropertyCallback obj "auth-callback" FP.nullFunPtr #if ENABLE_OVERLOADING data AuthDomainDigestAuthCallbackPropertyInfo instance AttrInfo AuthDomainDigestAuthCallbackPropertyInfo where type AttrAllowedOps AuthDomainDigestAuthCallbackPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear] type AttrSetTypeConstraint AuthDomainDigestAuthCallbackPropertyInfo = (~) (FunPtr Soup.Callbacks.C_AuthDomainDigestAuthCallback) type AttrBaseTypeConstraint AuthDomainDigestAuthCallbackPropertyInfo = IsAuthDomainDigest type AttrGetType AuthDomainDigestAuthCallbackPropertyInfo = (Maybe Soup.Callbacks.AuthDomainDigestAuthCallback_WithClosures) type AttrLabel AuthDomainDigestAuthCallbackPropertyInfo = "auth-callback" type AttrOrigin AuthDomainDigestAuthCallbackPropertyInfo = AuthDomainDigest attrGet _ = getAuthDomainDigestAuthCallback attrSet _ = setAuthDomainDigestAuthCallback attrConstruct _ = constructAuthDomainDigestAuthCallback attrClear _ = clearAuthDomainDigestAuthCallback #endif -- VVV Prop "auth-data" -- Type: TBasicType TPtr -- Flags: [PropertyReadable,PropertyWritable] -- Nullable: (Nothing,Nothing) {- | Get the value of the “@auth-data@” property. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' authDomainDigest #authData @ -} getAuthDomainDigestAuthData :: (MonadIO m, IsAuthDomainDigest o) => o -> m (Ptr ()) getAuthDomainDigestAuthData obj = liftIO $ B.Properties.getObjectPropertyPtr obj "auth-data" {- | Set the value of the “@auth-data@” property. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' authDomainDigest [ #authData 'Data.GI.Base.Attributes.:=' value ] @ -} setAuthDomainDigestAuthData :: (MonadIO m, IsAuthDomainDigest o) => o -> Ptr () -> m () setAuthDomainDigestAuthData obj val = liftIO $ B.Properties.setObjectPropertyPtr obj "auth-data" val {- | Construct a `GValueConstruct` with valid value for the “@auth-data@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`. -} constructAuthDomainDigestAuthData :: (IsAuthDomainDigest o) => Ptr () -> IO (GValueConstruct o) constructAuthDomainDigestAuthData val = B.Properties.constructObjectPropertyPtr "auth-data" val #if ENABLE_OVERLOADING data AuthDomainDigestAuthDataPropertyInfo instance AttrInfo AuthDomainDigestAuthDataPropertyInfo where type AttrAllowedOps AuthDomainDigestAuthDataPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet] type AttrSetTypeConstraint AuthDomainDigestAuthDataPropertyInfo = (~) (Ptr ()) type AttrBaseTypeConstraint AuthDomainDigestAuthDataPropertyInfo = IsAuthDomainDigest type AttrGetType AuthDomainDigestAuthDataPropertyInfo = (Ptr ()) type AttrLabel AuthDomainDigestAuthDataPropertyInfo = "auth-data" type AttrOrigin AuthDomainDigestAuthDataPropertyInfo = AuthDomainDigest attrGet _ = getAuthDomainDigestAuthData attrSet _ = setAuthDomainDigestAuthData attrConstruct _ = constructAuthDomainDigestAuthData attrClear _ = undefined #endif #if ENABLE_OVERLOADING instance O.HasAttributeList AuthDomainDigest type instance O.AttributeList AuthDomainDigest = AuthDomainDigestAttributeList type AuthDomainDigestAttributeList = ('[ '("addPath", Soup.AuthDomain.AuthDomainAddPathPropertyInfo), '("authCallback", AuthDomainDigestAuthCallbackPropertyInfo), '("authData", AuthDomainDigestAuthDataPropertyInfo), '("filter", Soup.AuthDomain.AuthDomainFilterPropertyInfo), '("filterData", Soup.AuthDomain.AuthDomainFilterDataPropertyInfo), '("genericAuthCallback", Soup.AuthDomain.AuthDomainGenericAuthCallbackPropertyInfo), '("genericAuthData", Soup.AuthDomain.AuthDomainGenericAuthDataPropertyInfo), '("proxy", Soup.AuthDomain.AuthDomainProxyPropertyInfo), '("realm", Soup.AuthDomain.AuthDomainRealmPropertyInfo), '("removePath", Soup.AuthDomain.AuthDomainRemovePathPropertyInfo)] :: [(Symbol, *)]) #endif #if ENABLE_OVERLOADING authDomainDigestAuthCallback :: AttrLabelProxy "authCallback" authDomainDigestAuthCallback = AttrLabelProxy authDomainDigestAuthData :: AttrLabelProxy "authData" authDomainDigestAuthData = AttrLabelProxy #endif #if ENABLE_OVERLOADING type instance O.SignalList AuthDomainDigest = AuthDomainDigestSignalList type AuthDomainDigestSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)]) #endif -- method AuthDomainDigest::set_auth_callback -- method type : OrdinaryMethod -- Args : [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomainDigest"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Soup", name = "AuthDomainDigestAuthCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the callback", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 2, argDestroy = 3, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to pass to @auth_callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dnotify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destroy notifier to free @user_data when @domain\nis destroyed", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "soup_auth_domain_digest_set_auth_callback" soup_auth_domain_digest_set_auth_callback :: Ptr AuthDomainDigest -> -- domain : TInterface (Name {namespace = "Soup", name = "AuthDomainDigest"}) FunPtr Soup.Callbacks.C_AuthDomainDigestAuthCallback -> -- callback : TInterface (Name {namespace = "Soup", name = "AuthDomainDigestAuthCallback"}) Ptr () -> -- user_data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- dnotify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO () {- | Sets the callback that /@domain@/ will use to authenticate incoming requests. For each request containing authorization, /@domain@/ will invoke the callback, and then either accept or reject the request based on /@callback@/\'s return value. You can also set the auth callback by setting the 'GI.Soup.Constants.AUTH_DOMAIN_DIGEST_AUTH_CALLBACK' and 'GI.Soup.Constants.AUTH_DOMAIN_DIGEST_AUTH_DATA' properties, which can also be used to set the callback at construct time. -} authDomainDigestSetAuthCallback :: (B.CallStack.HasCallStack, MonadIO m, IsAuthDomainDigest a) => a {- ^ /@domain@/: the domain -} -> Soup.Callbacks.AuthDomainDigestAuthCallback {- ^ /@callback@/: the callback -} -> m () authDomainDigestSetAuthCallback domain callback = liftIO $ do domain' <- unsafeManagedPtrCastPtr domain callback' <- Soup.Callbacks.mk_AuthDomainDigestAuthCallback (Soup.Callbacks.wrap_AuthDomainDigestAuthCallback Nothing (Soup.Callbacks.drop_closures_AuthDomainDigestAuthCallback callback)) let userData = castFunPtrToPtr callback' let dnotify = safeFreeFunPtrPtr soup_auth_domain_digest_set_auth_callback domain' callback' userData dnotify touchManagedPtr domain return () #if ENABLE_OVERLOADING data AuthDomainDigestSetAuthCallbackMethodInfo instance (signature ~ (Soup.Callbacks.AuthDomainDigestAuthCallback -> m ()), MonadIO m, IsAuthDomainDigest a) => O.MethodInfo AuthDomainDigestSetAuthCallbackMethodInfo a signature where overloadedMethod _ = authDomainDigestSetAuthCallback #endif -- method AuthDomainDigest::encode_password -- method type : MemberFunction -- Args : [Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a username", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "realm", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an auth realm name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "password", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the password for @username in @realm", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "soup_auth_domain_digest_encode_password" soup_auth_domain_digest_encode_password :: CString -> -- username : TBasicType TUTF8 CString -> -- realm : TBasicType TUTF8 CString -> -- password : TBasicType TUTF8 IO CString {- | Encodes the username\/realm\/password triplet for Digest authentication. (That is, it returns a stringified MD5 hash of /@username@/, /@realm@/, and /@password@/ concatenated together). This is the form that is needed as the return value of 'GI.Soup.Objects.AuthDomainDigest.AuthDomainDigest'\'s auth handler. For security reasons, you should store the encoded hash, rather than storing the cleartext password itself and calling this method only when you need to verify it. This way, if your server is compromised, the attackers will not gain access to cleartext passwords which might also be usable at other sites. (Note also that the encoded password returned by this method is identical to the encoded password stored in an Apache .htdigest file.) -} authDomainDigestEncodePassword :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@username@/: a username -} -> T.Text {- ^ /@realm@/: an auth realm name -} -> T.Text {- ^ /@password@/: the password for /@username@/ in /@realm@/ -} -> m T.Text {- ^ __Returns:__ the encoded password -} authDomainDigestEncodePassword username realm password = liftIO $ do username' <- textToCString username realm' <- textToCString realm password' <- textToCString password result <- soup_auth_domain_digest_encode_password username' realm' password' checkUnexpectedReturnNULL "authDomainDigestEncodePassword" result result' <- cstringToText result freeMem result freeMem username' freeMem realm' freeMem password' return result' #if ENABLE_OVERLOADING #endif