[asterisk-scf-commits] team/kpfleming/fosdem2011.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Sat Feb 5 07:10:36 CST 2011


branch "master" has been updated
       via  57c0bbea56fae6585ecf13f0628f79e437ee9e74 (commit)
      from  ade824dd35108f0ca494b8deb415924bbf61b522 (commit)

Summary of changes:
 fred.py |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit 57c0bbea56fae6585ecf13f0628f79e437ee9e74
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Sat Feb 5 14:10:31 2011 +0100

    Flesh out Python example.

diff --git a/fred.py b/fred.py
index b465b9c..044c8d4 100644
--- a/fred.py
+++ b/fred.py
@@ -3,18 +3,40 @@ from AsteriskSCF.SIP.ExtensionPoint.V1 import *
 from AsteriskSCF.System.Hook.V1 import *
 
 class fredHook(AuthHook):
+    _adapter = None
+    _proxy = None
+
+    def __init__(self):
+        _proxy = AuthHookPrx.uncheckedCast(_adapter.addWithUUID(self))
+
     def challengeRequest(info, challenges):
         result = HookResult()
-        result.status = HookStatus.Declined
+        challenge = DigestChallenge()
+
+	challenge.username = "bob"
+	challenge.password = "alice"
+	challenge.domain = [ "example.com" ]
+	challenge.algorithm = DigestAlgorithm.AKAv1MD5
+
+        challenges = [ challenge ]
+
+        result.status = HookStatus.Succeeded
+
         return result
 
 class fred(Ice.Application):
+    _hookId = None
+
     def run(self, args):
         adapter = self.communicator().createObjectAdapter("fred")
         adapter.activate()
-#        fredHook._adapter = adapter
+        fredHook._adapter = adapter
         hook = fredHook()
+	# this sample code does not actually locate the target SIP component
+        epPrx = AuthExtensionPointPrx.uncheckedCast(communicator().stringToProxy("sip_component"))
+        _hookId = epPrx.addAuthHook(hook._proxy, [ RequestType.DialogEstablishing ])
         self.communicator().waitForShutdown()
+	epPrx.removeAuthHook(_hookId)
         return 0
 
 app = fred()

-----------------------------------------------------------------------


-- 
team/kpfleming/fosdem2011.git



More information about the asterisk-scf-commits mailing list