| Index: remoting/protocol/validating_authenticator.h
|
| diff --git a/remoting/protocol/validating_authenticator.h b/remoting/protocol/validating_authenticator.h
|
| index 73f5d953166d57df385e286901fed0db3d504b80..3ea591a069c89cd163bb1b84508b2192ba6bdccd 100644
|
| --- a/remoting/protocol/validating_authenticator.h
|
| +++ b/remoting/protocol/validating_authenticator.h
|
| @@ -22,14 +22,20 @@ namespace protocol {
|
| // logic supplied by the caller is run when the first message is received from
|
| // the client. If the connection details are valid (e.g. conform to the current
|
| // policies), then the initial message, and all subsequent messages, are passed
|
| -// to the underlying authenticator instance for processing.
|
| +// to the underlying authenticator instance for processing. Once the connection
|
| +// is accepted, a second callback (provided during construction) is used to
|
| +// ultimately accept or reject the connection. Splitting the validation into
|
| +// two parts allows pre-validation to occur before passing the info on to
|
| +// the lower-level validators and a final validation step once all other checks
|
| +// have passed.
|
| class ValidatingAuthenticator : public Authenticator {
|
| public:
|
| enum class Result {
|
| SUCCESS,
|
| ERROR_INVALID_CREDENTIALS,
|
| ERROR_INVALID_ACCOUNT,
|
| - ERROR_REJECTED_BY_USER
|
| + ERROR_REJECTED_BY_USER,
|
| + ERROR_TOO_MANY_CONNECTIONS
|
| };
|
|
|
| typedef base::Callback<void(Result validation_result)> ResultCallback;
|
| @@ -39,7 +45,8 @@ class ValidatingAuthenticator : public Authenticator {
|
| ValidationCallback;
|
|
|
| ValidatingAuthenticator(const std::string& remote_jid,
|
| - const ValidationCallback& validation_callback,
|
| + const ValidationCallback& incoming_callback,
|
| + const ValidationCallback& accepted_callback,
|
| std::unique_ptr<Authenticator> current_authenticator);
|
| ~ValidatingAuthenticator() override;
|
|
|
| @@ -55,11 +62,11 @@ class ValidatingAuthenticator : public Authenticator {
|
| std::unique_ptr<buzz::XmlElement> GetNextMessage() override;
|
|
|
| private:
|
| - // Checks |validation_result|. On success, |message| and |resume_callback|
|
| - // are passed on to |current_authenticator_|. If the connection was rejected,
|
| - // |state_| and |rejection_reason_| are updated and |resume_callback| is run.
|
| - void OnValidateComplete(const buzz::XmlElement* message,
|
| - const base::Closure& resume_callback,
|
| + // Checks |validation_result|. On success, |success_callback| is called.
|
| + // If the connection was rejected, |state_| and |rejection_reason_| are
|
| + // updated and |failure_callback| is run.
|
| + void OnValidateComplete(const base::Closure& success_callback,
|
| + const base::Closure& failure_callback,
|
| Result validation_result);
|
|
|
| // Updates |state_| to reflect the current underlying authenticator state.
|
| @@ -71,7 +78,11 @@ class ValidatingAuthenticator : public Authenticator {
|
| // The JID of the remote user.
|
| std::string remote_jid_;
|
|
|
| - ValidationCallback validation_callback_;
|
| + // Called for pre-validation of incoming connection requests.
|
| + ValidationCallback incoming_callback_;
|
| +
|
| + // Called for final validation of accepted connection requests.
|
| + ValidationCallback accepted_callback_;
|
|
|
| // Returns the current state of the authenticator.
|
| State state_ = Authenticator::WAITING_MESSAGE;
|
| @@ -81,6 +92,8 @@ class ValidatingAuthenticator : public Authenticator {
|
|
|
| std::unique_ptr<Authenticator> current_authenticator_;
|
|
|
| + std::unique_ptr<buzz::XmlElement> pending_auth_message_;
|
| +
|
| base::WeakPtrFactory<ValidatingAuthenticator> weak_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ValidatingAuthenticator);
|
|
|