1 // 2 // Copyright (C) 2013 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #ifndef SHILL_SUPPLICANT_SUPPLICANT_EAP_STATE_HANDLER_H_ 18 #define SHILL_SUPPLICANT_SUPPLICANT_EAP_STATE_HANDLER_H_ 19 20 #include <string> 21 22 #include "shill/service.h" 23 24 namespace shill { 25 26 // This object tracks the state of wpa_supplicant's EAP association. 27 // It parses events from wpa_supplicant and can notify callers when 28 // wpa_supplicant succeeds or fails authentication. In the latter 29 // case it can explain the failure in detail based on the course of 30 // events leading up to it. 31 class SupplicantEAPStateHandler { 32 public: 33 SupplicantEAPStateHandler(); 34 virtual ~SupplicantEAPStateHandler(); 35 36 // Receive the |status| and |parameter| from an EAP event and returns 37 // true if this state transition indicates that the EAP authentication 38 // process has succeeded. If instead the EAP authentication has failed, 39 // |failure| will be set to reflect the type of failure that occurred, 40 // false will be returned. If this EAP event has no direct outcome, 41 // this function returns false without changing |failure|. 42 virtual bool ParseStatus(const std::string& status, 43 const std::string& parameter, 44 Service::ConnectFailure* failure); 45 46 // Resets the internal state of the handler. 47 virtual void Reset(); 48 is_eap_in_progress()49 virtual bool is_eap_in_progress() { return is_eap_in_progress_; } 50 51 private: 52 friend class SupplicantEAPStateHandlerTest; 53 54 // The stored TLS error type which may lead to an EAP failure. 55 std::string tls_error_; 56 57 // Whether or not an EAP authentication is in progress. Note 58 // specifically that an EAP failure in wpa_supplicant does not 59 // automatically cause the EAP process to stop, while success does. 60 bool is_eap_in_progress_; 61 }; 62 63 } // namespace shill 64 65 #endif // SHILL_SUPPLICANT_SUPPLICANT_EAP_STATE_HANDLER_H_ 66