OLD | NEW |
(Empty) | |
| 1 // Copyright 2004 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBRTC_LIBJINGLE_XMPP_SASLMECHANISM_H_ |
| 6 #define WEBRTC_LIBJINGLE_XMPP_SASLMECHANISM_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 namespace buzz { |
| 11 |
| 12 class XmlElement; |
| 13 |
| 14 |
| 15 // Defines a mechnanism to do SASL authentication. |
| 16 // Subclass instances should have a self-contained way to present |
| 17 // credentials. |
| 18 class SaslMechanism { |
| 19 |
| 20 public: |
| 21 |
| 22 // Intended to be subclassed |
| 23 virtual ~SaslMechanism() {} |
| 24 |
| 25 // Should return the name of the SASL mechanism, e.g., "PLAIN" |
| 26 virtual std::string GetMechanismName() = 0; |
| 27 |
| 28 // Should generate the initial "auth" request. Default is just <auth/>. |
| 29 virtual XmlElement * StartSaslAuth(); |
| 30 |
| 31 // Should respond to a SASL "<challenge>" request. Default is |
| 32 // to abort (for mechanisms that do not do challenge-response) |
| 33 virtual XmlElement * HandleSaslChallenge(const XmlElement * challenge); |
| 34 |
| 35 // Notification of a SASL "<success>". Sometimes information |
| 36 // is passed on success. |
| 37 virtual void HandleSaslSuccess(const XmlElement * success); |
| 38 |
| 39 // Notification of a SASL "<failure>". Sometimes information |
| 40 // for the user is passed on failure. |
| 41 virtual void HandleSaslFailure(const XmlElement * failure); |
| 42 |
| 43 protected: |
| 44 static std::string Base64Encode(const std::string & plain); |
| 45 static std::string Base64Decode(const std::string & encoded); |
| 46 static std::string Base64EncodeFromArray(const char * plain, size_t length); |
| 47 }; |
| 48 |
| 49 } |
| 50 |
| 51 #endif // WEBRTC_LIBJINGLE_XMPP_SASLMECHANISM_H_ |
OLD | NEW |