From 8565fcc8631ccfa36836fcde4e1aebac476022a8 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Thu, 8 Apr 2010 22:12:03 +0000 Subject: 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 --- cpp/src/qpid/acl/AclValidator.h | 82 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 cpp/src/qpid/acl/AclValidator.h (limited to 'cpp/src/qpid/acl/AclValidator.h') 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 +#include +#include + +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 values; + + public: + AclEnumProperty(std::vector& allowed); + int getType(){ return AclProperty::ENUM; } + virtual bool validate(const std::string& val); + virtual std::string allowedValues(); + }; + + typedef std::pair > Validator; + typedef std::map > ValidatorMap; + typedef ValidatorMap::iterator ValidatorItr; + + ValidatorMap validators; + +public: + + void validate(boost::shared_ptr d); + AclValidator(); + ~AclValidator(); +}; + +}} // namespace qpid::acl + +#endif // QPID_ACL_ACLVALIDATOR_H -- cgit v1.2.1