ObjXMPP  Check-in [a6c65a6aa2]

Overview
Comment:Adjust to recent ObjFW changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a6c65a6aa24a32c416822515821db7e18638ef65ff80b7768ad1f2f1e113cb7c
User & Date: js on 2011-09-22 23:38:03
Other Links: manifest | tags
Context
2011-10-04
12:54
Make use of -[OFXMLElement setStringValue:]. check-in: 1420288ed7 user: js tags: trunk
2011-09-22
23:38
Adjust to recent ObjFW changes. check-in: a6c65a6aa2 user: js tags: trunk
2011-09-18
19:33
Fix XMPPAuthenticator to support non-optimized message flow check-in: 0aab2fde67 user: florob@babelmonkeys.de tags: trunk
Changes

Modified src/XMPPConnection.m from [abf53f803c] to [2cc82e5d61].

94
95
96
97
98
99
100
101
102
103
104





105
106
107
108
109
110
111
94
95
96
97
98
99
100




101
102
103
104
105
106
107
108
109
110
111
112







-
-
-
-
+
+
+
+
+







{
	OFString *old = username;
	char *node;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([username_ UTF8String], &node,
	    "SASLprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException newWithClass: isa
							connection: self
							   profile: @"SASLprep"
							    string: username_];
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: self
			       profile: @"SASLprep"
				string: username_];

	@try {
		username = [[OFString alloc] initWithUTF8String: node];
	} @finally {
		free(node);
	}

122
123
124
125
126
127
128
129
130
131
132




133
134
135
136
137
138
139
123
124
125
126
127
128
129




130
131
132
133
134
135
136
137
138
139
140







-
-
-
-
+
+
+
+







	OFString *old = resource;
	char *res;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([resource_ UTF8String], &res,
	    "Resourceprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    newWithClass: isa
		      connection: self
			 profile: @"Resourceprep"
			  string: resource_];
		    exceptionWithClass: isa
			    connection: self
			       profile: @"Resourceprep"
				string: resource_];

	@try {
		resource = [[OFString alloc] initWithUTF8String: res];
	} @finally {
		free(res);
	}

150
151
152
153
154
155
156
157
158
159
160




161
162
163
164
165
166
167
151
152
153
154
155
156
157




158
159
160
161
162
163
164
165
166
167
168







-
-
-
-
+
+
+
+







	OFString *old = server;
	char *srv;
	Idna_rc rc;

	if ((rc = idna_to_ascii_8z([server_ UTF8String],
	    &srv, IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS)
		@throw [XMPPIDNATranslationFailedException
		    newWithClass: isa
		      connection: self
		       operation: @"ToASCII"
			  string: server_];
		    exceptionWithClass: isa
			    connection: self
			     operation: @"ToASCII"
				string: server_];

	@try {
		server = [[OFString alloc] initWithUTF8String: srv];
	} @finally {
		free(srv);
	}

177
178
179
180
181
182
183
184
185
186
187





188
189
190
191
192
193
194
178
179
180
181
182
183
184




185
186
187
188
189
190
191
192
193
194
195
196







-
-
-
-
+
+
+
+
+







{
	OFString *old = domain;
	char *srv;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([domain_ UTF8String], &srv,
	    "Nameprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException newWithClass: isa
							connection: self
							   profile: @"Nameprep"
							    string: domain_];
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: self
			       profile: @"Nameprep"
				string: domain_];

	@try {
		domain = [[OFString alloc] initWithUTF8String: srv];
	} @finally {
		free(srv);
	}

204
205
206
207
208
209
210
211
212
213
214





215
216
217
218
219
220
221
206
207
208
209
210
211
212




213
214
215
216
217
218
219
220
221
222
223
224







-
-
-
-
+
+
+
+
+







{
	OFString *old = password;
	char *pass;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([password_ UTF8String], &pass,
	    "SASLprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException newWithClass: isa
							connection: self
							   profile: @"SASLprep"
							    string: password_];
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: self
			       profile: @"SASLprep"
				string: password_];

	@try {
		password = [[OFString alloc] initWithUTF8String: pass];
	} @finally {
		free(pass);
	}

240
241
242
243
244
245
246
247
248
249
250




251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
243
244
245
246
247
248
249




250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265

266
267
268
269
270
271
272
273
274
275
276
277
278

279

280
281
282
283
284
285
286







-
-
-
-
+
+
+
+












-













-

-







	if (server)
		[sock connectToHost: server
			       port: port];
	else {
		if ((rc = idna_to_ascii_8z([domain UTF8String], &cDomainToASCII,
		    IDNA_USE_STD3_ASCII_RULES)) != IDNA_SUCCESS)
			@throw [XMPPIDNATranslationFailedException
				newWithClass: isa
				  connection: self
				   operation: @"ToASCII"
				      string: domain];
				exceptionWithClass: isa
					connection: self
					 operation: @"ToASCII"
					    string: domain];

		@try {
			domainToASCII = [OFString
			    stringWithUTF8String: cDomainToASCII];
		} @finally {
			free(cDomainToASCII);
		}

		@try {
			SRVLookup = [XMPPSRVLookup
			    lookupWithDomain: domainToASCII];
		} @catch (id e) {
			[e release];
		}

		enumerator = [SRVLookup objectEnumerator];

		/* Iterate over SRV records, if any */
		if ((candidate = [enumerator nextObject]) != nil) {
			do {
				@try {
					[sock connectToHost: [candidate target]
						       port: [candidate port]];
					break;
				} @catch (OFAddressTranslationFailedException
				    *e) {
					[e release];
				} @catch (OFConnectionFailedException *e) {
					[e release];
				}
			} while ((candidate = [enumerator nextObject]) != nil);
		} else
			/* No SRV records -> fall back to A / AAAA record */
			[sock connectToHost: domainToASCII
				       port: port];
	}
565
566
567
568
569
570
571
572
573
574
575




576
577
578
579
580
581
582
565
566
567
568
569
570
571




572
573
574
575
576
577
578
579
580
581
582







-
-
-
-
+
+
+
+







		else
			condition = @"undefined";

		reason = [[element
		    elementForName: @"text"
			 namespace: XMPP_NS_XMPP_STREAM] stringValue];

		@throw [XMPPStreamErrorException newWithClass: isa
						   connection: self
						    condition: condition
						       reason: reason];
		@throw [XMPPStreamErrorException exceptionWithClass: isa
							 connection: self
							  condition: condition
							     reason: reason];
		return;
	}

	assert(0);
}

- (void)XMPP_handleTLS: (OFXMLElement*)element
603
604
605
606
607
608
609
610

611
612
613
614
615
616
617
603
604
605
606
607
608
609

610
611
612
613
614
615
616
617







-
+







		[self XMPP_startStream];

		return;
	}

	if ([[element name] isEqual: @"failure"])
		/* TODO: Find/create an exception to throw here */
		@throw [OFException newWithClass: isa];
		@throw [OFException exceptionWithClass: isa];

	assert(0);
}

- (void)XMPP_handleSASL: (OFXMLElement*)element
{
	if ([[element name] isEqual: @"challenge"]) {
651
652
653
654
655
656
657
658
659
660



661
662
663
664
665
666
667
651
652
653
654
655
656
657



658
659
660
661
662
663
664
665
666
667







-
-
-
+
+
+







		return;
	}

	if ([[element name] isEqual: @"failure"]) {
		of_log(@"Auth failed!");
		// FIXME: Do more parsing/handling
		@throw [XMPPAuthFailedException
		    newWithClass: isa
		      connection: self
			  reason: [element XMLString]];
		    exceptionWithClass: isa
			    connection: self
				reason: [element XMLString]];
	}

	assert(0);
}

- (void)XMPP_handleIQ: (XMPPIQ*)iq
{
726
727
728
729
730
731
732
733

734
735
736
737
738
739
740
726
727
728
729
730
731
732

733
734
735
736
737
738
739
740







-
+







		    [OFXMLElement elementWithName: @"starttls"
					namespace: XMPP_NS_STARTTLS]];
		return;
	}

	if (encryptionRequired && !encrypted)
		/* TODO: Find/create an exception to throw here */
		@throw [OFException newWithClass: isa];
		@throw [OFException exceptionWithClass: isa];

	if (mechs != nil) {
		OFEnumerator *enumerator;
		OFXMLElement *mech;

		enumerator = [[mechs children] objectEnumerator];
		while ((mech = [enumerator nextObject]) != nil)

Modified src/XMPPExceptions.h from [74f141b417] to [51ba3fe543].

30
31
32
33
34
35
36
37
38


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80




81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102




103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122



123
124
125
126
127
30
31
32
33
34
35
36


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76




77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98




99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119



120
121
122
123
124
125
126
127







-
-
+
+
















-
-
+
+




















-
-
-
-
+
+
+
+


















-
-
-
-
+
+
+
+

















-
-
-
+
+
+





	XMPPConnection *connection;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) XMPPConnection *connection;
#endif

+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn;
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn;
- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn;
- (XMPPConnection*)connection;
@end

@interface XMPPStreamErrorException: XMPPException
{
	OFString *condition;
	OFString *reason;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFString *condition;
@property (readonly, nonatomic) OFString *reason;
#endif

+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn
     condition: (OFString*)condition_
	reason: (OFString*)reason_;
- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
      condition: (OFString*)condition_
	 reason: (OFString*)reason_;
- (OFString*)condition;
- (OFString*)reason;
@end

@interface XMPPStringPrepFailedException: XMPPException
{
	OFString *profile;
	OFString *string;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFString *profile, *string;
#endif

+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
       profile: (OFString*)profile
	string: (OFString*)string;
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn
	     profile: (OFString*)profile
	      string: (OFString*)string;
- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
	profile: (OFString*)profile
	 string: (OFString*)string;
- (OFString*)profile;
- (OFString*)string;
@end

@interface XMPPIDNATranslationFailedException: XMPPException
{
	OFString *operation;
	OFString *string;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFString *operation, *string;
#endif

+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
     operation: (OFString*)operation
	string: (OFString*)string;
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn
	   operation: (OFString*)operation
	      string: (OFString*)string;
- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
      operation: (OFString*)operation
	 string: (OFString*)string;
- (OFString*)operation;
- (OFString*)string;
@end

@interface XMPPAuthFailedException: XMPPException
{
	OFString *reason;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFString *reason;
#endif

+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
	reason: (OFString*)reason_;
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn
	      reason: (OFString*)reason_;
- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
	 reason: (OFString*)reason_;
- (OFString*)reason;
@end

Modified src/XMPPExceptions.m from [8850499811] to [28cd0632a1].

23
24
25
26
27
28
29
30
31


32
33
34


35
36
37
38
39
40
41
42


43
44
45
46
47
48
49
23
24
25
26
27
28
29


30
31
32


33
34
35
36
37
38
39
40


41
42
43
44
45
46
47
48
49







-
-
+
+

-
-
+
+






-
-
+
+







#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#import "XMPPExceptions.h"

@implementation XMPPException
+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn
{
	return [[self alloc] initWithClass: class_
				connection: conn];
	return [[[self alloc] initWithClass: class_
				 connection: conn] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	self = [super initWithClass: class_];

78
79
80
81
82
83
84
85
86
87
88




89
90
91
92
93




94
95
96
97
98
99
100
101
102


103
104
105
106
107
108
109
78
79
80
81
82
83
84




85
86
87
88
89




90
91
92
93
94
95
96
97
98
99
100


101
102
103
104
105
106
107
108
109







-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+







-
-
+
+







- (XMPPConnection*)connection
{
	return connection;
}
@end

@implementation XMPPStreamErrorException
+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
     condition: (OFString*)condition_
	reason: (OFString*)reason_;
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn
	   condition: (OFString*)condition_
	      reason: (OFString*)reason_;
{
	return [[self alloc] initWithClass: class_
				connection: conn
				 condition: condition_
				    reason: reason_];
	return [[[self alloc] initWithClass: class_
				 connection: conn
				  condition: condition_
				     reason: reason_] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
      condition: (OFString*)condition_
	 reason: (OFString*)reason_
{
148
149
150
151
152
153
154
155
156
157
158




159
160
161
162
163




164
165
166
167
168
169
170
171
172


173
174
175
176
177
178
179
148
149
150
151
152
153
154




155
156
157
158
159




160
161
162
163
164
165
166
167
168
169
170


171
172
173
174
175
176
177
178
179







-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+







-
-
+
+







- (OFString*)reason
{
	return reason;
}
@end

@implementation XMPPStringPrepFailedException
+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
       profile: (OFString*)profile
	string: (OFString*)string
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn
	     profile: (OFString*)profile
	      string: (OFString*)string
{
	return [[self alloc] initWithClass: class_
				connection: conn
				   profile: profile
				    string: string];
	return [[[self alloc] initWithClass: class_
				 connection: conn
				    profile: profile
				     string: string] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
	profile: (OFString*)profile_
	 string: (OFString*)string_
{
219
220
221
222
223
224
225
226
227
228
229




230
231
232
233
234




235
236
237
238
239
240
241
242
243


244
245
246
247
248
249
250
219
220
221
222
223
224
225




226
227
228
229
230




231
232
233
234
235
236
237
238
239
240
241


242
243
244
245
246
247
248
249
250







-
-
-
-
+
+
+
+

-
-
-
-
+
+
+
+







-
-
+
+







- (OFString*)string
{
	return string;
}
@end

@implementation XMPPIDNATranslationFailedException
+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
     operation: (OFString*)operation
	string: (OFString*)string
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn
	   operation: (OFString*)operation
	      string: (OFString*)string
{
	return [[self alloc] initWithClass: class_
				connection: conn
				 operation: operation
				    string: string];
	return [[[self alloc] initWithClass: class_
				 connection: conn
				  operation: operation
				     string: string] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
      operation: (OFString*)operation_
	 string: (OFString*)string_
{
289
290
291
292
293
294
295
296
297
298



299
300
301
302



303
304
305
306
307
308
309
310
311


312
313
314
315
316
317
318
289
290
291
292
293
294
295



296
297
298
299



300
301
302
303
304
305
306
307
308
309


310
311
312
313
314
315
316
317
318







-
-
-
+
+
+

-
-
-
+
+
+







-
-
+
+







- (OFString*)string
{
	return string;
}
@end

@implementation XMPPAuthFailedException
+ newWithClass: (Class)class_
    connection: (XMPPConnection*)conn
	reason: (OFString*)reason_;
+ exceptionWithClass: (Class)class_
	  connection: (XMPPConnection*)conn
	      reason: (OFString*)reason_;
{
	return [[self alloc] initWithClass: class_
				connection: conn
				    reason: reason_];
	return [[[self alloc] initWithClass: class_
				 connection: conn
				     reason: reason_] autorelease];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
     connection: (XMPPConnection*)conn
	 reason: (OFString*)reason_
{
	self = [super initWithClass: class_

Modified src/XMPPIQ.m from [c6eb5c9016] to [291cb330c2].

42
43
44
45
46
47
48
49
50



51
52
53
54
55
56
57
42
43
44
45
46
47
48


49
50
51
52
53
54
55
56
57
58







-
-
+
+
+







	self = [super initWithName: @"iq"
			      type: type_
				ID: ID_];

	@try {
		if (![type_ isEqual: @"get"] && ![type_ isEqual: @"set"] &&
		    ![type_ isEqual: @"result"] && ![type_ isEqual: @"error"])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

Modified src/XMPPJID.m from [29e551d558] to [f46e581111].

108
109
110
111
112
113
114
115
116
117
118





119
120
121
122
123
124
125
108
109
110
111
112
113
114




115
116
117
118
119
120
121
122
123
124
125
126







-
-
-
-
+
+
+
+
+







		[old release];
		node = nil;
		return;
	}

	if ((rc = stringprep_profile([node_ UTF8String], &nodepart,
	    "Nodeprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException newWithClass: isa
							connection: nil
							   profile: @"Nodeprep"
							    string: node_];
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: nil
			       profile: @"Nodeprep"
				string: node_];

	@try {
		node = [[OFString alloc] initWithUTF8String: nodepart];
	} @finally {
		free(nodepart);
	}

135
136
137
138
139
140
141
142
143
144
145





146
147
148
149
150
151
152
136
137
138
139
140
141
142




143
144
145
146
147
148
149
150
151
152
153
154







-
-
-
-
+
+
+
+
+







{
	OFString *old = domain;
	char *srv;
	Stringprep_rc rc;

	if ((rc = stringprep_profile([domain_ UTF8String], &srv,
	    "Nameprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException newWithClass: isa
							connection: nil
							   profile: @"Nameprep"
							    string: domain_];
		@throw [XMPPStringPrepFailedException
		    exceptionWithClass: isa
			    connection: nil
			       profile: @"Nameprep"
				string: domain_];

	@try {
		domain = [[OFString alloc] initWithUTF8String: srv];
	} @finally {
		free(srv);
	}

169
170
171
172
173
174
175
176
177
178
179




180
181
182
183
184
185
186
171
172
173
174
175
176
177




178
179
180
181
182
183
184
185
186
187
188







-
-
-
-
+
+
+
+







		resource = nil;
		return;
	}

	if ((rc = stringprep_profile([resource_ UTF8String], &res,
	    "Resourceprep", 0)) != STRINGPREP_OK)
		@throw [XMPPStringPrepFailedException
		    newWithClass: isa
		      connection: nil
			 profile: @"Resourceprep"
			  string: resource_];
		    exceptionWithClass: isa
			    connection: nil
			       profile: @"Resourceprep"
				string: resource_];

	@try {
		resource = [[OFString alloc] initWithUTF8String: res];
	} @finally {
		free(res);
	}

Modified src/XMPPSCRAMAuth.m from [6cfa1bc3c0] to [50454e1c4a].

227
228
229
230
231
232
233
234
235
236




237
238
239
240
241
242
243
244
245
246
247
248
249
250
251

252
253
254
255
256
257
258
227
228
229
230
231
232
233



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251

252
253
254
255
256
257
258
259







-
-
-
+
+
+
+














-
+







	while ((comp = [enumerator nextObject]) != nil) {
		OFString *entry = [comp substringWithRange:
		    of_range(2, [comp length] - 2)];

		if ([comp hasPrefix: @"r="]) {
			if (![entry hasPrefix: cNonce])
				@throw [XMPPAuthFailedException
				    newWithClass: isa
				      connection: nil
					  reason: @"Received wrong nonce"];
				    exceptionWithClass: isa
					    connection: nil
						reason: @"Received wrong "
							@"nonce"];

			sNonce = entry;
			got |= GOT_SNONCE;
		} else if ([comp hasPrefix: @"s="]) {
			salt = [OFDataArray
			    dataArrayWithBase64EncodedString: entry];
			got |= GOT_SALT;
		} else if ([comp hasPrefix: @"i="]) {
			iterCount = [entry decimalValue];
			got |= GOT_ITERCOUNT;
		}
	}

	if (got != (GOT_SNONCE | GOT_SALT | GOT_ITERCOUNT))
		@throw [OFInvalidServerReplyException newWithClass: isa];
		@throw [OFInvalidServerReplyException exceptionWithClass: isa];

	// Add c=<base64(GS2Header+channelBindingData)>
	tmpArray = [OFDataArray dataArrayWithItemSize: 1];
	[tmpArray addNItems: [GS2Header UTF8StringLength]
		 fromCArray: [GS2Header UTF8String]];
	if (plusAvailable && [connection encrypted]) {
		OFDataArray *channelBinding = [((SSLSocket*)[connection socket])
385
386
387
388
389
390
391
392
393
394




395
396
397
398
399



400
401
402
403
404
405
406
386
387
388
389
390
391
392



393
394
395
396
397
398



399
400
401
402
403
404
405
406
407
408







-
-
-
+
+
+
+


-
-
-
+
+
+







				       length: [data count] *
					       [data itemSize]];
	value = [mess substringWithRange: of_range(2, [mess length] - 2)];

	if ([mess hasPrefix: @"v="]) {
		if (![value isEqual: [serverSignature stringByBase64Encoding]])
			@throw [XMPPAuthFailedException
			    newWithClass: isa
			      connection: nil
				  reason: @"Received wrong ServerSignature"];
			    exceptionWithClass: isa
				    connection: nil
					reason: @"Received wrong "
						@"ServerSignature"];
		authenticated = YES;
	} else
		@throw [XMPPAuthFailedException newWithClass: isa
						  connection: nil
						      reason: value];
		@throw [XMPPAuthFailedException exceptionWithClass: isa
							connection: nil
							    reason: value];

	return nil;
}

- (OFString*)XMPP_genNonce
{
	uint8_t buf[64];

Modified src/XMPPSRVLookup.m from [50f66c7748] to [5cc1b1a048].

55
56
57
58
59
60
61
62
63


64
65
66
67
68
69
70
55
56
57
58
59
60
61


62
63
64
65
66
67
68
69
70







-
-
+
+







					      handle: handle] autorelease];
}

- init
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithPriority: (uint16_t)priority_
	    weight: (uint16_t)weight_
	      port: (uint16_t)port_
	    target: (OFString*)target_
{
96
97
98
99
100
101
102
103

104
105
106
107
108
109
110
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110







-
+







		priority = ntohs(rdata[0]);
		weight = ntohs(rdata[1]);
		port = ntohs(rdata[2]);

		if (dn_expand(ns_msg_base(handle), ns_msg_end(handle),
		    (uint8_t*)&rdata[3], buffer, NS_MAXDNAME) < 1)
			@throw [OFInitializationFailedException
			    newWithClass: isa];
			    exceptionWithClass: isa];

		target = [[OFString alloc]
		    initWithCString: buffer
			   encoding: OF_STRING_ENCODING_NATIVE];
	} @catch (id e) {
		[self release];
		@throw e;
206
207
208
209
210
211
212
213
214
215



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230



231
232
233
234
235
236
237



238
239
240
241
242
243
244
206
207
208
209
210
211
212



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227



228
229
230
231
232
233
234



235
236
237
238
239
240
241
242
243
244







-
-
-
+
+
+












-
-
-
+
+
+




-
-
-
+
+
+







	@try {
		int answerLen, resourceRecordCount, i;
		ns_rr resourceRecord;
		ns_msg handle;

		if (res_ninit(&resState))
			@throw [OFAddressTranslationFailedException
			    newWithClass: isa
				  socket: nil
				    host: domain];
			    exceptionWithClass: isa
					socket: nil
					  host: domain];

		answer = [self allocMemoryWithSize: of_pagesize];
		answerLen = res_nsearch(&resState, [request cStringWithEncoding:
		    OF_STRING_ENCODING_NATIVE], ns_c_in, ns_t_srv, answer,
		    (int)of_pagesize);

		if ((answerLen == -1) && ((h_errno == HOST_NOT_FOUND) ||
		    (h_errno == NO_DATA)))
			return;

		if (answerLen < 1 || answerLen > of_pagesize) {
			@throw [OFAddressTranslationFailedException
			    newWithClass: isa
				  socket: nil
				    host: domain];
			    exceptionWithClass: isa
					socket: nil
					  host: domain];
		}

		if (ns_initparse(answer, answerLen, &handle))
			@throw [OFAddressTranslationFailedException
			    newWithClass: isa
				  socket: nil
				    host: domain];
			    exceptionWithClass: isa
					socket: nil
					  host: domain];

		resourceRecordCount = ns_msg_count(handle, ns_s_an);
		for (i = 0; i < resourceRecordCount; i++) {
			if (ns_parserr(&handle, ns_s_an, i, &resourceRecord))
				continue;

			if (ns_rr_type(resourceRecord) != ns_t_srv ||

Modified src/XMPPStanza.m from [63b3b8769a] to [446ca28bd0].

92
93
94
95
96
97
98
99
100



101
102
103
104
105
106
107
92
93
94
95
96
97
98


99
100
101
102
103
104
105
106
107
108







-
-
+
+
+







{
	self = [super initWithName: name_
			 namespace: XMPP_NS_CLIENT];

	@try {
		if (![name_ isEqual: @"iq"] && ![name_ isEqual: @"message"] &&
		    ![name_ isEqual: @"presence"])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
			@throw [OFInvalidArgumentException
			    exceptionWithClass: isa
				      selector: _cmd];

		[self setDefaultNamespace: XMPP_NS_CLIENT];
		[self setPrefix: @"stream"
		   forNamespace: XMPP_NS_STREAM];

		if (type_ != nil)
			[self setType: type_];