mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
added HTTP*Credentials::empty() and HTTP*Credentials::clear()
This commit is contained in:
@@ -36,7 +36,7 @@ class Net_API HTTPBasicCredentials
|
||||
public:
|
||||
HTTPBasicCredentials();
|
||||
/// Creates an empty HTTPBasicCredentials object.
|
||||
|
||||
|
||||
HTTPBasicCredentials(const std::string& username, const std::string& password);
|
||||
/// Creates a HTTPBasicCredentials object with the given username and password.
|
||||
|
||||
@@ -55,18 +55,24 @@ public:
|
||||
~HTTPBasicCredentials();
|
||||
/// Destroys the HTTPBasicCredentials.
|
||||
|
||||
void clear();
|
||||
/// Clears both username and password.
|
||||
|
||||
void setUsername(const std::string& username);
|
||||
/// Sets the username.
|
||||
|
||||
|
||||
const std::string& getUsername() const;
|
||||
/// Returns the username.
|
||||
|
||||
|
||||
void setPassword(const std::string& password);
|
||||
/// Sets the password.
|
||||
|
||||
|
||||
const std::string& getPassword() const;
|
||||
/// Returns the password.
|
||||
|
||||
|
||||
bool empty() const;
|
||||
/// Returns true if both username and password are empty, otherwise false.
|
||||
|
||||
void authenticate(HTTPRequest& request) const;
|
||||
/// Adds authentication information to the given HTTPRequest.
|
||||
|
||||
@@ -84,7 +90,7 @@ protected:
|
||||
private:
|
||||
HTTPBasicCredentials(const HTTPBasicCredentials&);
|
||||
HTTPBasicCredentials& operator = (const HTTPBasicCredentials&);
|
||||
|
||||
|
||||
std::string _username;
|
||||
std::string _password;
|
||||
};
|
||||
@@ -105,6 +111,12 @@ inline const std::string& HTTPBasicCredentials::getPassword() const
|
||||
}
|
||||
|
||||
|
||||
inline bool HTTPBasicCredentials::empty() const
|
||||
{
|
||||
return _username.empty() && _password.empty();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
|
||||
|
||||
@@ -91,6 +91,9 @@ public:
|
||||
/// and password of the credentials object.
|
||||
/// Does nothing if URI has no user info part.
|
||||
|
||||
void clear();
|
||||
/// Clears username, password and host.
|
||||
|
||||
void setUsername(const std::string& username);
|
||||
/// Sets the username.
|
||||
|
||||
@@ -111,6 +114,9 @@ public:
|
||||
/// Returns the target host. Only used for SSPI-based NTLM authentication using
|
||||
/// the credentials of the currently logged-in user on Windows.
|
||||
|
||||
bool empty() const;
|
||||
/// Returns true if both username and password are empty, otherwise false.
|
||||
|
||||
void authenticate(HTTPRequest& request, const HTTPResponse& response);
|
||||
/// Inspects WWW-Authenticate header of the response, initializes
|
||||
/// the internal state (in case of digest authentication) and
|
||||
@@ -216,6 +222,12 @@ inline const std::string& HTTPCredentials::getHost() const
|
||||
}
|
||||
|
||||
|
||||
inline bool HTTPCredentials::empty() const
|
||||
{
|
||||
return _digest.empty();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ public:
|
||||
|
||||
void reset();
|
||||
/// Resets the HTTPDigestCredentials object to a clean state.
|
||||
/// Does not clear username and password.
|
||||
|
||||
void clear();
|
||||
/// Clears both username and password.
|
||||
|
||||
void setUsername(const std::string& username);
|
||||
/// Sets the username.
|
||||
@@ -65,6 +69,9 @@ public:
|
||||
const std::string& getPassword() const;
|
||||
/// Returns the password.
|
||||
|
||||
bool empty() const;
|
||||
/// Returns true if both username and password are empty, otherwise false.
|
||||
|
||||
void authenticate(HTTPRequest& request, const HTTPResponse& response);
|
||||
/// Parses WWW-Authenticate header of the HTTPResponse, initializes
|
||||
/// internal state, and adds authentication information to the given HTTPRequest.
|
||||
@@ -110,7 +117,7 @@ public:
|
||||
|
||||
bool verifyAuthParams(const HTTPRequest& request, const HTTPAuthenticationParams& params) const;
|
||||
/// Verifies the digest authentication information in the given HTTPRequest
|
||||
/// and HTTPAuthenticationParams by recomputing the response and comparing
|
||||
/// and HTTPAuthenticationParams by recomputing the response and comparing
|
||||
/// it with what's in the request.
|
||||
|
||||
static std::string createNonce();
|
||||
@@ -125,7 +132,7 @@ private:
|
||||
void createAuthParams(const HTTPRequest& request, const HTTPAuthenticationParams& responseAuthParams);
|
||||
void updateAuthParams(const HTTPRequest& request);
|
||||
int updateNonceCounter(const std::string& nonce);
|
||||
|
||||
|
||||
static const std::string DEFAULT_ALGORITHM;
|
||||
static const std::string DEFAULT_QOP;
|
||||
static const std::string NONCE_PARAM;
|
||||
@@ -146,7 +153,7 @@ private:
|
||||
std::string _password;
|
||||
HTTPAuthenticationParams _requestAuthParams;
|
||||
NonceCounterMap _nc;
|
||||
|
||||
|
||||
static int _nonceCounter;
|
||||
static Poco::FastMutex _nonceMutex;
|
||||
};
|
||||
@@ -167,6 +174,12 @@ inline const std::string& HTTPDigestCredentials::getPassword() const
|
||||
}
|
||||
|
||||
|
||||
inline bool HTTPDigestCredentials::empty() const
|
||||
{
|
||||
return _username.empty() && _password.empty();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ public:
|
||||
|
||||
void reset();
|
||||
/// Resets the HTTPNTLMCredentials object to a clean state.
|
||||
/// Does not clear username and password.
|
||||
|
||||
void clear();
|
||||
/// Clears username, password and host.
|
||||
|
||||
void setUsername(const std::string& username);
|
||||
/// Sets the username.
|
||||
@@ -64,6 +68,9 @@ public:
|
||||
const std::string& getPassword() const;
|
||||
/// Returns the password.
|
||||
|
||||
bool empty() const;
|
||||
/// Returns true if both username and password are empty, otherwise false.
|
||||
|
||||
void setHost(const std::string& host);
|
||||
/// Sets the target host.\
|
||||
///
|
||||
@@ -149,6 +156,12 @@ inline bool HTTPNTLMCredentials::useSSPINTLM() const
|
||||
}
|
||||
|
||||
|
||||
inline bool HTTPNTLMCredentials::empty() const
|
||||
{
|
||||
return _username.empty() && _password.empty();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user