diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2009-01-07 20:24:42 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2009-01-07 20:24:42 +0000 |
| commit | 816a99518e8f22b404b95975a415ce0daff21f2a (patch) | |
| tree | 0cb338ac5c542af5e38ecaf0c45c7a534065189a /cpp/src/qpid | |
| parent | d742c39392369a7de47997835bf0f3d97c34d5ec (diff) | |
| download | qpid-python-816a99518e8f22b404b95975a415ce0daff21f2a.tar.gz | |
This is related to QPID-1558.
The test case test_group_and_user_with_same_name covers the error condition in QPID-1545
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@732466 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid')
| -rw-r--r-- | cpp/src/qpid/acl/AclReader.cpp | 12 | ||||
| -rw-r--r-- | cpp/src/qpid/acl/AclReader.h | 5 |
2 files changed, 15 insertions, 2 deletions
diff --git a/cpp/src/qpid/acl/AclReader.cpp b/cpp/src/qpid/acl/AclReader.cpp index c407339390..8f5e4f5b57 100644 --- a/cpp/src/qpid/acl/AclReader.cpp +++ b/cpp/src/qpid/acl/AclReader.cpp @@ -312,6 +312,7 @@ bool AclReader::processGroupLine(tokList& toks, const bool cont) { errorStream << ACL_FORMAT_ERR_LOG_PREFIX << "Name \"" << toks[i] << "\" contains illegal characters."; return false; } + if (!isValidUserName(toks[i])) return false; addName(toks[i], citr->second); } } else { @@ -330,6 +331,7 @@ bool AclReader::processGroupLine(tokList& toks, const bool cont) { errorStream << ACL_FORMAT_ERR_LOG_PREFIX << "Name \"" << toks[i] << "\" contains illegal characters."; return false; } + if (!isValidUserName(toks[i])) return false; addName(toks[i], citr->second); } } @@ -508,4 +510,14 @@ AclReader::nvPair AclReader::splitNameValuePair(const std::string& nvpString) { return nvPair(nvpString.substr(0, pos), nvpString.substr(pos+1)); } +// Returns true if a username has the name@realm format +bool AclReader::isValidUserName(const std::string& name){ + size_t pos = name.find('@'); + if ( pos == std::string::npos || pos == name.length() -1){ + errorStream << ACL_FORMAT_ERR_LOG_PREFIX << "Username '" << name << "' must contain a realm"; + return false; + } + return true; +} + }} // namespace qpid::acl diff --git a/cpp/src/qpid/acl/AclReader.h b/cpp/src/qpid/acl/AclReader.h index d85dbeef6b..dccb450192 100644 --- a/cpp/src/qpid/acl/AclReader.h +++ b/cpp/src/qpid/acl/AclReader.h @@ -107,11 +107,12 @@ class AclReader { bool processAclLine(tokList& toks); void printRules() const; // debug aid - + bool isValidUserName(const std::string& name); + static bool checkName(const std::string& name); static nvPair splitNameValuePair(const std::string& nvpString); }; - + }} // namespace qpid::acl #endif // QPID_ACL_ACLREADER_H |
