added HTTP*Credentials::empty() and HTTP*Credentials::clear()

This commit is contained in:
Günter Obiltschnig
2019-06-04 18:33:50 +02:00
parent 86b448ecf5
commit 96a7263219
8 changed files with 107 additions and 28 deletions

View File

@@ -55,6 +55,9 @@ public:
~HTTPBasicCredentials();
/// Destroys the HTTPBasicCredentials.
void clear();
/// Clears both username and password.
void setUsername(const std::string& username);
/// Sets the username.
@@ -67,6 +70,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;
/// Adds authentication information to the given HTTPRequest.
@@ -105,6 +111,12 @@ inline const std::string& HTTPBasicCredentials::getPassword() const
}
inline bool HTTPBasicCredentials::empty() const
{
return _username.empty() && _password.empty();
}
} } // namespace Poco::Net

View File

@@ -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

View File

@@ -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.
@@ -167,6 +174,12 @@ inline const std::string& HTTPDigestCredentials::getPassword() const
}
inline bool HTTPDigestCredentials::empty() const
{
return _username.empty() && _password.empty();
}
} } // namespace Poco::Net

View File

@@ -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

View File

@@ -69,6 +69,13 @@ HTTPBasicCredentials::~HTTPBasicCredentials()
}
void HTTPBasicCredentials::clear()
{
_username.clear();
_password.clear();
}
void HTTPBasicCredentials::setUsername(const std::string& username)
{
_username = username;

View File

@@ -47,6 +47,13 @@ HTTPCredentials::~HTTPCredentials()
}
void HTTPCredentials::clear()
{
_digest.clear();
_ntlm.clear();
}
void HTTPCredentials::fromUserInfo(const std::string& userInfo)
{
std::string username;

View File

@@ -121,6 +121,13 @@ void HTTPDigestCredentials::setPassword(const std::string& password)
}
void HTTPDigestCredentials::clear()
{
_username.clear();
_password.clear();
}
void HTTPDigestCredentials::authenticate(HTTPRequest& request, const HTTPResponse& response)
{
authenticate(request, HTTPAuthenticationParams(response));

View File

@@ -52,6 +52,14 @@ void HTTPNTLMCredentials::reset()
}
void HTTPNTLMCredentials::clear()
{
_username.clear();
_password.clear();
_host.clear();
}
void HTTPNTLMCredentials::setUsername(const std::string& username)
{
_username = username;