Browse code

added .txt extension to Readme files

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1555 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 22/10/2009 01:22:47
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,113 @@
1
+conf_auth Readme
2
+
3
+conf_auth application: PIN collect, authentication and B2BUA 
4
+                       connect with timeout
5
+
6
+The conf_auth application is an ivr application which plays 
7
+a welcome message to the caller, collects a PIN, verifies 
8
+this PIN agains a XMLRPC authentication server, and if correct
9
+ connects in back-to-back user agent mode to a uri returned
10
+from the authentication server. The call is terminated after 
11
+a timeout, if the authentication server did return a timeout
12
+value. If the caller while collecting the PIN does not enter 
13
+any digit for a number of seconds, she or he is prompted with
14
+a hint message.
15
+
16
+As this script combines diverse SEMS/ivr functionality (TTS, 
17
+DTMF collect, b2bua, timer), it may well serve as a basis for 
18
+customized services, and actually it is rather meant as a 
19
+demonstration of these possibilities.
20
+
21
+The authentication server here needs to serve only one method: 
22
+AuthorizeConference. This method takes as argument the From URI, 
23
+Request URI, and PIN, and returns either a tuple of 
24
+['FAIL', <file_name>] where <file_name> is the file which should
25
+be played to tell the user that the entered PIN is not correct, or 
26
+['OK', <to>, <to_uri>, <timer_timeout>, <max_participants>] 
27
+where 
28
+ <to>               : To in the second call leg 
29
+ <to_uri>           : Uri of the second call leg 
30
+ <timer_timeout>    : Timeout of call (0 if no timer)
31
+ <max_participants> : unused
32
+
33
+An example python authentication server is given below.
34
+
35
+#---------- auth_srv.py -------------------------------------
36
+!/usr/bin/python
37
+
38
+import sys
39
+sys.path.insert(0, '../')
40
+import xmlrpc
41
+import traceback
42
+import select
43
+import string
44
+import csv
45
+
46
+PORT            = 23456
47
+TIMEOUT         = 1.0
48
+LOGLEVEL        = 3             # this is the default log level
49
+TEST_NAME       = 'shilad'
50
+TEST_PASS       = 'shilad'
51
+
52
+PINS    = {
53
+                'sip:uli@iptel.org' +  'sip:conf1@confserver.net' +  '1234' \
54
+                        : ['test <sip:1@192.168.5.100>','sip:1@192.168.5.100']
55
+}
56
+
57
+
58
+# you may uncomment the 'setAuth()' line to use the example
59
+# authentication function 'authenticate()' supplied below
60
+#
61
+def exampleServer():
62
+
63
+        global exitFlag
64
+
65
+        exitFlag = 0
66
+        s = xmlrpc.server()
67
+#       s.setAuth(authenticate)
68
+        s.addMethods({
69
+                'AuthorizeConference' : confAuthMethod,
70
+                'add_pin'   : addPinMethod,
71
+                'list_pins' : listPinsMethod
72
+        })
73
+        s.bindAndListen(PORT)
74
+        while 1:
75
+                try:
76
+                        s.work()        # you could set a timeout if desired
77
+                except:
78
+                        e = sys.exc_info()
79
+                        if e[0] in (KeyboardInterrupt, SystemExit):
80
+                                raise e[0], e[1], e[2]
81
+                        traceback.print_exc()
82
+                if exitFlag:
83
+                        break
84
+
85
+def authenticate(uri, name, password):
86
+        if name == TEST_NAME and password == TEST_PASS:
87
+                return (1, 'a domain')
88
+        else:
89
+                return (0, 'a domain')
90
+
91
+def confAuthMethod(serv, src, uri, method, params):
92
+        print 'params are', params
93
+        test_key = params[0] + params[1] + params[2]
94
+        print 'test_key = ', test_key
95
+        if not PINS.has_key(test_key):
96
+                return ['FAIL', 'wav/failed.wav']
97
+        else:
98
+                return ['OK', PINS[test_key][0], PINS[test_key][1], 30, 5 ]
99
+
100
+def addPinMethod(serv, src, uri, method, params):
101
+        print 'params are', params
102
+        add_key = params[0] +  params[1] + params[2]
103
+        print 'add_key = ', add_key
104
+        PINS[add_key] = [params[3], params[4]]
105
+        return ['ok']
106
+
107
+def listPinsMethod(serv, src, uri, method, params):
108
+        return PINS
109
+
110
+if __name__ == '__main__':
111
+        exampleServer()
112
+
113
+#---------- auth_srv.py -------------------------------------