Browse code

Added first attempt to XCAP authorization in PA module. Watchers are authorized after each re-subscription because of absence of "XCAP change notifications". Added pa module parameters: auth - values 'none', 'xcap' auth_xcap_root - in the case of xcap auth holds xcap root used for auths

Vaclav Kubart authored on 27/10/2005 10:58:26
Showing 4 changed files
... ...
@@ -187,3 +187,13 @@ void str_clear(str_t *s)
187 187
 	}
188 188
 }
189 189
 
190
+char *str_strchr(const str *s, char c)
191
+{
192
+	if (s) {
193
+		int i;
194
+		for (i = 0; i < s->len; i++)
195
+			if (s->s[i] == c) return s->s + i;
196
+	}
197
+	return NULL;
198
+}
199
+
... ...
@@ -86,6 +86,9 @@ int str_prefix(const str_t *a, const str_t *b); /* ss_start */
86 86
 
87 87
 void str_clear(str_t *s);
88 88
 
89
+/** locate character in string */
90
+char *str_strchr(const str *s, char c);
91
+
89 92
 #ifdef __cplusplus
90 93
 }
91 94
 #endif
... ...
@@ -95,20 +95,23 @@ static void parse_uri(const str_t *uri, str_t *user, str_t *domain)
95 95
 {
96 96
 	char *a;
97 97
 	char *d;
98
-	char *s;
98
+	str_t s;
99 99
 	
100 100
 	str_clear(user);
101 101
 	str_clear(domain);
102 102
 	if (uri->len > 0) {
103
-		d = strchr(uri->s, ':');
104
-		if (d) s = d + 1;
105
-		else s = uri->s;
106
-		a = strchr(s, '@');
103
+		d = str_strchr(uri, ':');
104
+		if (d) {
105
+			s.s = d + 1;
106
+			s.len = uri->len - (s.s - uri->s);
107
+		}
108
+		else s = *uri;
109
+		a = str_strchr(&s, '@');
107 110
 		if (a) {
108
-			user->s = s;
109
-			user->len = a - s;
111
+			user->s = s.s;
112
+			user->len = a - s.s;
110 113
 		}
111
-		domain->s = s + user->len;
114
+		domain->s = s.s + user->len;
112 115
 		if (a) domain->s++;
113 116
 		domain->len = uri->len - (domain->s - uri->s);
114 117
 		
... ...
@@ -139,6 +142,10 @@ int is_rule_for_uri(cp_rule_t *rule, const str_t *uri)
139 142
 	i = id->ids;
140 143
 	while (i) {
141 144
 		parse_uri(&i->entity, &u_, &d_);
145
+/*		TRACE_LOG("comparing uris \'%.*s\' \'%.*s\' "
146
+				"domains \'%.*s\' \'%.*s\'\n", 
147
+				FMT_STR(user), FMT_STR(u_),
148
+				FMT_STR(domain), FMT_STR(d_));*/
142 149
 		if (str_case_equals(&user, &u_) == 0) {
143 150
 			if (str_nocase_equals(&domain, &d_) == 0) {
144 151
 /*				TRACE_LOG("id found\n");*/
... ...
@@ -150,6 +157,8 @@ int is_rule_for_uri(cp_rule_t *rule, const str_t *uri)
150 157
 	
151 158
 	d = id->domains;
152 159
 	while (d) {
160
+/*		TRACE_LOG("comparing domains \'%.*s\' \'%.*s\'\n",
161
+				FMT_STR(domain), FMT_STR(d->domain));*/
153 162
 		if (str_nocase_equals(&domain, &d->domain) == 0) ok = 1;
154 163
 		d = d->next;
155 164
 	}
... ...
@@ -194,6 +203,8 @@ int get_pres_rules_action(cp_ruleset_t *r, const str_t *wuri,
194 203
 	
195 204
 	rule = r->rules;
196 205
 	while (rule) {
206
+		TRACE_LOG("TRYING rule %.*s for uri %.*s\n", 
207
+					FMT_STR(rule->id), FMT_STR(*wuri));
197 208
 		if (is_rule_for_uri(rule, wuri)) {
198 209
 			TRACE_LOG("rule %.*s matches for uri %.*s\n", 
199 210
 					FMT_STR(rule->id), FMT_STR(*wuri));
... ...
@@ -30,6 +30,8 @@
30 30
 #include <xcap/xcap_client.h>
31 31
 #include <xcap/common_policy.h>
32 32
 
33
+typedef cp_ruleset_t presence_rules_t;
34
+
33 35
 /* Type defining action for pres_rules */
34 36
 typedef enum {
35 37
 	sub_handling_block,