GME
13
|
00001 00023 #if !defined(AFX_PROMPTER_H__6833BB77_DDCC_4BF8_A995_5A5CBC48DF4C__INCLUDED_) 00024 #define AFX_PROMPTER_H__6833BB77_DDCC_4BF8_A995_5A5CBC48DF4C__INCLUDED_ 00025 00026 #if _MSC_VER > 1000 00027 #pragma once 00028 #endif // _MSC_VER > 1000 00029 00030 #include "svn_auth.h" 00031 #include <string> 00032 00038 class PromptImpl 00039 { 00040 public: 00041 PromptImpl() : m_maySave( false) { } 00042 virtual ~PromptImpl() { } 00043 00044 virtual bool prompt 00045 (const char *realm, const char *pi_username, bool maySave) = 0; 00046 00047 virtual bool askYesNo 00048 (const char *realm, const char *question, bool yesIsDefault) = 0; 00049 00050 virtual int askTrust 00051 (const char *question, bool maySave) = 0; 00052 00053 virtual std::string askQuestion 00054 ( const char *realm, const char *question, bool showAnswer, bool maySave) = 0; 00055 00056 virtual std::string password() = 0; 00057 virtual std::string username() = 0; 00058 00063 bool m_maySave; 00064 00065 00066 static void scanfBlind( std::string& ret); 00067 }; 00068 00069 class TextPromptImpl : public PromptImpl 00070 { 00071 protected: 00072 std::string m_uName; 00073 std::string m_pWord; 00074 00075 enum EntryType 00076 { 00077 UserName 00078 , Password 00079 }; 00080 std::string readcnf( const EntryType& p_type); 00081 00082 std::string m_answer; 00083 00084 public: 00085 TextPromptImpl(); 00086 virtual ~TextPromptImpl(); 00087 00088 virtual bool prompt(const char *realm, const char *pi_username, bool maySave); 00089 00090 virtual bool askYesNo(const char *realm, const char *question, bool yesIsDefault); 00091 00092 virtual int askTrust(const char *question, bool maySave); 00093 00094 virtual std::string askQuestion(const char *realm, const char *question, bool showAnswer, bool maySave); 00095 00096 virtual std::string password(); 00097 virtual std::string username(); 00098 }; 00099 00100 class GPromptImpl : public PromptImpl 00101 { 00102 protected: 00103 std::string m_uName; 00104 std::string m_pWord; 00105 bool m_credsFilled; 00106 00107 std::string m_answer; 00108 00109 public: 00110 GPromptImpl(); 00111 virtual ~GPromptImpl(); 00112 00113 virtual bool prompt(const char *realm, const char *pi_username, bool maySave); 00114 00115 virtual bool askYesNo(const char *realm, const char *question, bool yesIsDefault); 00116 00117 virtual int askTrust(const char *question, bool maySave); 00118 00119 virtual std::string askQuestion(const char *realm, const char *question, bool showAnswer, bool maySave); 00120 00121 virtual std::string password(); 00122 virtual std::string username(); 00123 }; 00124 00128 class Prompter 00129 { 00130 PromptImpl * m_impl; 00131 Prompter( PromptImpl* p_prompter); 00132 00133 public: 00134 static Prompter *makePrompter( PromptImpl* p_prompter); 00135 00136 ~Prompter(); 00137 00138 svn_auth_provider_object_t *getProviderUsername(apr_pool_t *pool); 00139 svn_auth_provider_object_t *getProviderSimple(apr_pool_t *pool); 00140 svn_auth_provider_object_t *getProviderServerSSLTrust(apr_pool_t *pool); 00141 svn_auth_provider_object_t *getProviderClientSSL(apr_pool_t *pool); 00142 svn_auth_provider_object_t *getProviderClientSSLPassword(apr_pool_t *pool); 00143 00144 enum PrompUserPass 00145 { 00146 AcceptPermanently 00147 , AcceptTemporary 00148 , Reject 00149 }; 00150 00151 class CallbackHelpers 00152 { 00153 public: 00154 static svn_error_t* simple_prompt( 00155 svn_auth_cred_simple_t **cred_p, 00156 void *baton, const char *realm, 00157 const char *username, 00158 svn_boolean_t may_save, 00159 apr_pool_t *pool); 00160 00161 static svn_error_t* username_prompt( 00162 svn_auth_cred_username_t **cred_p, 00163 void *baton, 00164 const char *realm, 00165 svn_boolean_t may_save, 00166 apr_pool_t *pool); 00167 00168 static svn_error_t* ssl_server_trust_prompt( 00169 svn_auth_cred_ssl_server_trust_t **cred_p, 00170 void *baton, 00171 const char *realm, 00172 apr_uint32_t failures, 00173 const svn_auth_ssl_server_cert_info_t *cert_info, 00174 svn_boolean_t may_save, 00175 apr_pool_t *pool); 00176 00177 static svn_error_t* ssl_client_cert_prompt( 00178 svn_auth_cred_ssl_client_cert_t **cred_p, 00179 void *baton, 00180 const char *realm, 00181 svn_boolean_t may_save, 00182 apr_pool_t *pool); 00183 00184 static svn_error_t* ssl_client_cert_pw_prompt( 00185 svn_auth_cred_ssl_client_cert_pw_t **cred_p, 00186 void *baton, 00187 const char *realm, 00188 svn_boolean_t may_save, 00189 apr_pool_t *pool); 00190 }; 00191 }; 00192 00193 #endif 00194 // !defined(AFX_PROMPTER_H__6833BB77_DDCC_4BF8_A995_5A5CBC48DF4C__INCLUDED_)