diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2010-04-08 22:12:03 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2010-04-08 22:12:03 +0000 |
| commit | 8565fcc8631ccfa36836fcde4e1aebac476022a8 (patch) | |
| tree | 7af23ed08a68d9b4f30934c58a2fb781c8818770 /cpp/src/qpid/acl/AclValidator.h | |
| parent | e0a5bc013ae24199310df6711f2a603135b73792 (diff) | |
| download | qpid-python-8565fcc8631ccfa36836fcde4e1aebac476022a8.tar.gz | |
Committing the patch attached to QPID-2488
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@932148 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/acl/AclValidator.h')
| -rw-r--r-- | cpp/src/qpid/acl/AclValidator.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/cpp/src/qpid/acl/AclValidator.h b/cpp/src/qpid/acl/AclValidator.h new file mode 100644 index 0000000000..1176d2e89c --- /dev/null +++ b/cpp/src/qpid/acl/AclValidator.h @@ -0,0 +1,82 @@ +#ifndef QPID_ACL_ACLVALIDATOR_H +#define QPID_ACL_ACLVALIDATOR_H + + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "qpid/broker/AclModule.h" +#include "qpid/acl/AclData.h" +#include "qpid/sys/IntegerTypes.h" +#include <boost/shared_ptr.hpp> +#include <vector> +#include <sstream> + +namespace qpid { +namespace acl { + +class AclValidator { + + /* Base Property */ + class AclProperty{ + public: + enum PropertyType { INT, STRING, ENUM }; + + public: + virtual int getType()=0; + virtual bool validate(const std::string& val)=0; + virtual std::string allowedValues()=0; + }; + + class AclIntProperty : public AclProperty{ + int64_t min; + int64_t max; + + public: + AclIntProperty(int64_t min,int64_t max); + int getType(){ return AclProperty::INT; } + virtual bool validate(const std::string& val); + virtual std::string allowedValues(); + }; + + class AclEnumProperty : public AclProperty{ + std::vector<std::string> values; + + public: + AclEnumProperty(std::vector<std::string>& allowed); + int getType(){ return AclProperty::ENUM; } + virtual bool validate(const std::string& val); + virtual std::string allowedValues(); + }; + + typedef std::pair<acl::Property,boost::shared_ptr<AclProperty> > Validator; + typedef std::map<acl::Property,boost::shared_ptr<AclProperty> > ValidatorMap; + typedef ValidatorMap::iterator ValidatorItr; + + ValidatorMap validators; + +public: + + void validate(boost::shared_ptr<AclData> d); + AclValidator(); + ~AclValidator(); +}; + +}} // namespace qpid::acl + +#endif // QPID_ACL_ACLVALIDATOR_H |
