/src/common/types/PolicyKey.cpp

https://gitlab.com/github-cloud-corporation/cynara · C++ · 58 lines · 26 code · 11 blank · 21 comment · 1 complexity · 2822a5a53d2e405ecd1e60d861b6b679 MD5 · raw file

  1. /*
  2. * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @file src/common/types/PolicyKey.cpp
  18. * @author Aleksander Zdyb <a.zdyb@samsung.com>
  19. * @version 1.0
  20. * @brief Implementation of Cynara:PolicyKey methods
  21. */
  22. #include "PolicyKey.h"
  23. #include <sstream>
  24. #include <cynara-admin-types.h>
  25. namespace Cynara {
  26. const std::string &PolicyKeyFeature::wildcardValue(void) {
  27. static const std::string value(CYNARA_ADMIN_WILDCARD);
  28. return value;
  29. }
  30. const std::string &PolicyKeyFeature::anyValue(void) {
  31. static const std::string value(CYNARA_ADMIN_ANY);
  32. return value;
  33. }
  34. const std::string &PolicyKeyFeature::toString(void) const {
  35. return value();
  36. }
  37. std::string PolicyKey::toString(void) const {
  38. std::stringstream ss;
  39. ss << client().toString() << "\t"
  40. << user().toString() << "\t"
  41. << privilege().toString();
  42. return ss.str();
  43. }
  44. bool operator ==(const PolicyKeyFeature::ValueType &pkf1, const PolicyKeyFeature &pkf2) {
  45. return pkf2 == pkf1;
  46. }
  47. } /* namespace Cynara */