Overview
Comment: | Add support for anonymous authentication |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f09ee1db55d16f888b1ae73f70cf664e |
User & Date: | js on 2018-11-11 12:17:03 |
Other Links: | manifest | tags |
Context
2018-11-11
| ||
15:30 | Do not set presence type to available check-in: f2793cf7cb user: js tags: trunk | |
12:17 | Add support for anonymous authentication check-in: f09ee1db55 user: js tags: trunk | |
2018-11-05
| ||
22:30 | Kill #ifdef HAVE_CONFIG_H check-in: cd21ff1157 user: js tags: trunk | |
Changes
Modified src/Makefile from [aecd29812e] to [6e0c6cc9a7].
1 2 3 4 5 6 7 8 | include ../extra.mk SHARED_LIB = ${OBJXMPP_SHARED_LIB} STATIC_LIB = ${OBJXMPP_STATIC_LIB} FRAMEWORK = ${OBJXMPP_FRAMEWORK} LIB_MAJOR = 0 LIB_MINOR = 0 | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | include ../extra.mk SHARED_LIB = ${OBJXMPP_SHARED_LIB} STATIC_LIB = ${OBJXMPP_STATIC_LIB} FRAMEWORK = ${OBJXMPP_FRAMEWORK} LIB_MAJOR = 0 LIB_MINOR = 0 SRCS = XMPPANONYMOUSAuth.m \ XMPPAuthenticator.m \ XMPPCallback.m \ XMPPConnection.m \ XMPPContact.m \ XMPPContactManager.m \ XMPPDiscoEntity.m \ XMPPDiscoIdentity.m \ XMPPDiscoNode.m \ |
︙ | ︙ |
Added src/XMPPANONYMOUSAuth.h version [865fdd1521].
Added src/XMPPANONYMOUSAuth.m version [a9888d3e04].
Modified src/XMPPConnection.h from [9de35f3a6c] to [4fbe933481].
︙ | ︙ | |||
143 144 145 146 147 148 149 | */ @interface XMPPConnection: OFObject <OFXMLParserDelegate, OFXMLElementBuilderDelegate> { OF_KINDOF(OFTCPSocket *) _socket; OFXMLParser *_parser, *_oldParser; OFXMLElementBuilder *_elementBuilder, *_oldElementBuilder; | > | > | | | | | | | < < | < | | | | | > > > > > | | | | | | | | | | | | | | 143 144 145 146 147 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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | */ @interface XMPPConnection: OFObject <OFXMLParserDelegate, OFXMLElementBuilderDelegate> { OF_KINDOF(OFTCPSocket *) _socket; OFXMLParser *_parser, *_oldParser; OFXMLElementBuilder *_elementBuilder, *_oldElementBuilder; OFString *_Nullable _username, *_Nullable _password, *_Nullable _server; OFString *_Nullable _resource; bool _usesAnonymousAuthentication; OFString *_Nullable _privateKeyFile, *_Nullable _certificateFile; const char *_Nullable _privateKeyPassphrase; OFString *_Nullable _domain, *_Nullable _domainToASCII; XMPPJID *_Nullable _JID; uint16_t _port; id <XMPPStorage> _Nullable _dataStorage; OFString *_Nullable _language; XMPPMulticastDelegate *_delegates; OFMutableDictionary OF_GENERIC(OFString *, XMPPCallback *) *_callbacks; XMPPAuthenticator *_authModule; bool _streamOpen, _needsSession, _encryptionRequired, _encrypted; bool _supportsRosterVersioning, _supportsStreamManagement; unsigned int _lastID; } /*! * @brief The username to use for authentication. */ @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *username; /*! * @brief The password to use for authentication. */ @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *password; /*! * @brief The server to use for the connection. * * This is useful if the address of the server is different from the domain. */ @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *server; /*! * @brief The domain to connect to. */ @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *domain; /*! * @brief The resource to request for the connection. */ @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *resource; /*! * @brief Whether the connection uses SASL ANONYMOUS authentication. */ @property (nonatomic) bool usesAnonymousAuthentication; /*! * @brief The language to request for the connection. */ @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *language; /*! * @brief A private key file to use for authentication. */ @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *privateKeyFile; /*! * @brief A certificate file to use for authentication. */ @property OF_NULLABLE_PROPERTY (nonatomic, copy) OFString *certificateFile; /*! * @brief The JID the server assigned to the connection after binding. */ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) XMPPJID *JID; /*! * @brief The port to connect to. */ @property (nonatomic) uint16_t port; /*! * @brief An object for data storage, conforming to the XMPPStorage protocol. */ @property OF_NULLABLE_PROPERTY (nonatomic, assign) id <XMPPStorage> dataStorage; /*! * @brief The socket used for the connection. */ @property (readonly, nonatomic) OF_KINDOF(OFTCPSocket *) socket; /*! * @brief Whether encryption is required. */ @property (nonatomic) bool encryptionRequired; /*! * @brief Whether the connection is encrypted. */ @property (readonly, nonatomic) bool encrypted; /*! * @brief Whether roster versioning is supported. */ @property (readonly, nonatomic) bool supportsRosterVersioning; /*! * @brief Whether stream management is supported. */ @property (readonly, nonatomic) bool supportsStreamManagement; /*! * @brief Creates a new autoreleased XMPPConnection. * * @return A new autoreleased XMPPConnection */ + (instancetype)connection; /*! * @brief Adds the specified delegate. |
︙ | ︙ |
Modified src/XMPPConnection.m from [c3592e505e] to [7227381b06].
︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 | #import <ObjOpenSSL/SSLSocket.h> #import <ObjOpenSSL/SSLInvalidCertificateException.h> #import <ObjOpenSSL/X509Certificate.h> #import <ObjFW/OFInvalidArgumentException.h> #import "XMPPConnection.h" #import "XMPPCallback.h" #import "XMPPEXTERNALAuth.h" | > | | | | | | | | > | 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 | #import <ObjOpenSSL/SSLSocket.h> #import <ObjOpenSSL/SSLInvalidCertificateException.h> #import <ObjOpenSSL/X509Certificate.h> #import <ObjFW/OFInvalidArgumentException.h> #import "XMPPConnection.h" #import "XMPPANONYMOUSAuth.h" #import "XMPPCallback.h" #import "XMPPEXTERNALAuth.h" #import "XMPPExceptions.h" #import "XMPPIQ.h" #import "XMPPJID.h" #import "XMPPMessage.h" #import "XMPPMulticastDelegate.h" #import "XMPPPLAINAuth.h" #import "XMPPPresence.h" #import "XMPPSCRAMAuth.h" #import "XMPPStanza.h" #import "XMPPXMLElementBuilder.h" #import "namespaces.h" #import <ObjFW/macros.h> #define BUFFER_LENGTH 512 @interface XMPPConnection () |
︙ | ︙ | |||
95 96 97 98 99 100 101 102 103 104 105 106 107 108 | - (OFString *)xmpp_IDNAToASCII: (OFString *)domain; - (XMPPMulticastDelegate *)xmpp_delegates; @end @implementation XMPPConnection @synthesize username = _username, resource = _resource, server = _server; @synthesize domain = _domain, password = _password, JID = _JID, port = _port; @synthesize language = _language, privateKeyFile = _privateKeyFile; @synthesize certificateFile = _certificateFile, socket = _socket; @synthesize encryptionRequired = _encryptionRequired, encrypted = _encrypted; @synthesize supportsRosterVersioning = _supportsRosterVersioning; @synthesize supportsStreamManagement = _supportsStreamManagement; + (instancetype)connection | > | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | - (OFString *)xmpp_IDNAToASCII: (OFString *)domain; - (XMPPMulticastDelegate *)xmpp_delegates; @end @implementation XMPPConnection @synthesize username = _username, resource = _resource, server = _server; @synthesize domain = _domain, password = _password, JID = _JID, port = _port; @synthesize usesAnonymousAuthentication = _usesAnonymousAuthentication; @synthesize language = _language, privateKeyFile = _privateKeyFile; @synthesize certificateFile = _certificateFile, socket = _socket; @synthesize encryptionRequired = _encryptionRequired, encrypted = _encrypted; @synthesize supportsRosterVersioning = _supportsRosterVersioning; @synthesize supportsStreamManagement = _supportsStreamManagement; + (instancetype)connection |
︙ | ︙ | |||
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 | if ([element elementForName: @"sm" namespace: XMPP_NS_SM] != nil) _supportsStreamManagement = true; if (mechs != nil) { for (OFXMLElement *mech in [mechs children]) [mechanisms addObject: [mech stringValue]]; if (_privateKeyFile != nil && _certificateFile != nil && [mechanisms containsObject: @"EXTERNAL"]) { _authModule = [[XMPPEXTERNALAuth alloc] init]; [self xmpp_sendAuth: @"EXTERNAL"]; return; } | > > > > > > > > > > > > | 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 | if ([element elementForName: @"sm" namespace: XMPP_NS_SM] != nil) _supportsStreamManagement = true; if (mechs != nil) { for (OFXMLElement *mech in [mechs children]) [mechanisms addObject: [mech stringValue]]; if (_usesAnonymousAuthentication) { if (![mechanisms containsObject: @"ANONYMOUS"]) @throw [XMPPAuthFailedException exceptionWithConnection: self reason: @"No supported " @"auth mechanism"]; _authModule = [[XMPPANONYMOUSAuth alloc] init]; [self xmpp_sendAuth: @"ANONYMOUS"]; return; } if (_privateKeyFile != nil && _certificateFile != nil && [mechanisms containsObject: @"EXTERNAL"]) { _authModule = [[XMPPEXTERNALAuth alloc] init]; [self xmpp_sendAuth: @"EXTERNAL"]; return; } |
︙ | ︙ | |||
1047 1048 1049 1050 1051 1052 1053 | _authModule = [[XMPPPLAINAuth alloc] initWithAuthcid: _username password: _password]; [self xmpp_sendAuth: @"PLAIN"]; return; } | > > > | | 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | _authModule = [[XMPPPLAINAuth alloc] initWithAuthcid: _username password: _password]; [self xmpp_sendAuth: @"PLAIN"]; return; } @throw [XMPPAuthFailedException exceptionWithConnection: self reason: @"No supported auth mechanism"]; } if (session != nil && [session elementForName: @"optional" namespace: XMPP_NS_SESSION] == nil) _needsSession = true; if (bind != nil) { |
︙ | ︙ | |||
1071 1072 1073 1074 1075 1076 1077 | OFXMLElement *authTag; OFData *initialMessage = [_authModule initialMessage]; authTag = [OFXMLElement elementWithName: @"auth" namespace: XMPP_NS_SASL]; [authTag addAttributeWithName: @"mechanism" stringValue: authName]; | | | 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 | OFXMLElement *authTag; OFData *initialMessage = [_authModule initialMessage]; authTag = [OFXMLElement elementWithName: @"auth" namespace: XMPP_NS_SASL]; [authTag addAttributeWithName: @"mechanism" stringValue: authName]; if (initialMessage != nil) { if ([initialMessage count] == 0) [authTag setStringValue: @"="]; else [authTag setStringValue: [initialMessage stringByBase64Encoding]]; } |
︙ | ︙ |