35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
+
|
#import <ObjOpenSSL/SSLSocket.h>
#import <ObjOpenSSL/SSLInvalidCertificateException.h>
#import <ObjOpenSSL/X509Certificate.h>
#import "XMPPConnection.h"
#import "XMPPCallback.h"
#import "XMPPSRVLookup.h"
#import "XMPPEXTERNALAuth.h"
#import "XMPPSCRAMAuth.h"
#import "XMPPPLAINAuth.h"
#import "XMPPStanza.h"
#import "XMPPJID.h"
#import "XMPPIQ.h"
#import "XMPPMessage.h"
#import "XMPPPresence.h"
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
+
+
|
- (void)dealloc
{
[sock release];
[parser release];
[elementBuilder release];
[username release];
[password release];
[privateKeyFile release];
[certificateFile release];
[server release];
[domain release];
[resource release];
[JID release];
[callbacks release];
[authModule release];
[roster release];
|
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
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
245
246
247
248
249
250
251
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
[old release];
}
- (OFString*)password
{
return [[password copy] autorelease];
}
- (void)setPrivateKeyFile: (OFString*)file
{
OF_SETTER(privateKeyFile, file, YES, YES)
}
- (OFString*)privateKeyFile
{
OF_GETTER(privateKeyFile, YES)
}
- (void)setCertificateFile: (OFString*)file
{
OF_SETTER(certificateFile, file, YES, YES)
}
- (OFString*)certificateFile
{
OF_GETTER(certificateFile, YES)
}
- (void)connect
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
XMPPSRVEntry *candidate = nil;
XMPPSRVLookup *SRVLookup = nil;
OFEnumerator *enumerator;
|
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
|
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
|
-
+
+
+
|
/* FIXME: Catch errors here */
SSLSocket *newSock;
if ([delegate respondsToSelector:
@selector(connectionWillUpgradeToTLS:)])
[delegate connectionWillUpgradeToTLS: self];
newSock = [[SSLSocket alloc] initWithSocket: sock];
newSock = [[SSLSocket alloc] initWithSocket: sock
privateKeyFile: privateKeyFile
certificateFile: certificateFile];
[sock release];
sock = newSock;
encrypted = YES;
if ([delegate respondsToSelector:
@selector(connectionDidUpgradeToTLS:)])
|
814
815
816
817
818
819
820
821
822
823
824
825
826
827
|
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
|
+
+
+
+
+
+
+
|
if (mechs != nil) {
OFEnumerator *enumerator;
OFXMLElement *mech;
enumerator = [[mechs children] objectEnumerator];
while ((mech = [enumerator nextObject]) != nil)
[mechanisms addObject: [mech stringValue]];
if (privateKeyFile && certificateFile &&
[mechanisms containsObject: @"EXTERNAL"]) {
authModule = [[XMPPEXTERNALAuth alloc] init];
[self XMPP_sendAuth: @"EXTERNAL"];
return;
}
if ([mechanisms containsObject: @"SCRAM-SHA-1-PLUS"]) {
authModule = [[XMPPSCRAMAuth alloc]
initWithAuthcid: username
password: password
connection: self
hash: [OFSHA1Hash class]
|