ObjXMPP  Check-in [1f5b2b1bd8]

Overview
Comment:Implement SASL EXTERNAL
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1f5b2b1bd85aa9f07318660dbafe2eb67e07a8d7f8594b728077b3985d725138
User & Date: florob@babelmonkeys.de on 2012-01-25 15:42:29
Other Links: manifest | tags
Context
2012-01-25
16:20
Perform length checking on JID parts (0 < part < 1024) check-in: 3b429b0df5 user: florob@babelmonkeys.de tags: trunk
15:42
Implement SASL EXTERNAL check-in: 1f5b2b1bd8 user: florob@babelmonkeys.de tags: trunk
14:05
Generate stanza errors check-in: 65623177b5 user: florob@babelmonkeys.de tags: trunk
Changes

Modified src/Makefile from [c7688681a6] to [fd40e02aba].

1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19











+







include ../extra.mk

LIB = ${OBJXMPP_SHARED_LIB}
LIB_MAJOR = 0
LIB_MINOR = 0
STATIC_LIB = ${OBJXMPP_STATIC_LIB}

SRCS = XMPPAuthenticator.m	\
       XMPPCallback.m		\
       XMPPConnection.m		\
       XMPPExceptions.m		\
       XMPPEXTERNALAuth.m	\
       XMPPIQ.m			\
       XMPPJID.m		\
       XMPPMessage.m		\
       XMPPPLAINAuth.m		\
       XMPPPresence.m		\
       XMPPRoster.m		\
       XMPPRosterItem.m		\

Modified src/XMPPConnection.h from [628096fdc8] to [191f094bce].

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
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







+















+







    <OFXMLParserDelegate, OFXMLElementBuilderDelegate>
#endif
{
	id sock;
	OFXMLParser *parser, *oldParser;
	OFXMLElementBuilder *elementBuilder, *oldElementBuilder;
	OFString *username, *password, *server, *resource;
	OFString *privateKeyFile, *certificateFile;
	OFString *domain, *domainToASCII;
	XMPPJID *JID;
	uint16_t port;
	id <XMPPConnectionDelegate, OFObject> delegate;
	OFMutableDictionary *callbacks;
	XMPPAuthenticator *authModule;
	BOOL streamOpen;
	BOOL needsSession;
	BOOL encryptionRequired, encrypted;
	unsigned int lastID;
	XMPPRoster *roster;
}

#ifdef OF_HAVE_PROPERTIES
@property (copy) OFString *username, *password, *server, *domain, *resource;
@property (copy) OFString *privateKeyFile, *certificateFile;
@property (copy, readonly) XMPPJID *JID;
@property (assign) uint16_t port;
@property (assign) id <XMPPConnectionDelegate> delegate;
@property (readonly, retain) XMPPRoster *roster;
@property (readonly, retain, getter=socket) OFTCPSocket *sock;
@property (assign) BOOL encryptionRequired;
@property (readonly) BOOL encrypted;

Modified src/XMPPConnection.m from [938031a215] to [93e7490cdd].

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]