document_security.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Copyright (c) 2014-2021 Thomas Fussell
  2. // Copyright (c) 2010-2015 openpyxl
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE
  21. //
  22. // @license: http://www.opensource.org/licenses/mit-license.php
  23. // @author: see AUTHORS file
  24. #pragma once
  25. #include <string>
  26. #include <xlnt/xlnt_config.hpp>
  27. namespace xlnt {
  28. /// <summary>
  29. /// Properties governing how the data in a workbook should be protected.
  30. /// These values can be ignored by consumers.
  31. /// </summary>
  32. class XLNT_API document_security
  33. {
  34. public:
  35. /// <summary>
  36. /// Holds data describing the verifier that locks revisions or a workbook.
  37. /// </summary>
  38. struct lock_verifier
  39. {
  40. /// <summary>
  41. /// The algorithm used to create and verify this lock.
  42. /// </summary>
  43. std::string hash_algorithm;
  44. /// <summary>
  45. /// The initial salt combined with the password used to prevent rainbow table attacks
  46. /// </summary>
  47. std::string salt;
  48. /// <summary>
  49. /// The actual hash value represented as a string
  50. /// </summary>
  51. std::string hash;
  52. /// <summary>
  53. /// The number of times the hash should be applied to the password combined with the salt.
  54. /// This allows the difficulty of the hash to be increased as computing power increases.
  55. /// </summary>
  56. std::size_t spin_count;
  57. };
  58. /// <summary>
  59. /// Constructs a new document security object with default values.
  60. /// </summary>
  61. document_security() = default;
  62. /// <summary>
  63. /// If true, the workbook is locked for revisions.
  64. /// </summary>
  65. bool lock_revision = false;
  66. /// <summary>
  67. /// If true, worksheets can't be moved, renamed, (un)hidden, inserted, or deleted.
  68. /// </summary>
  69. bool lock_structure = false;
  70. /// <summary>
  71. /// If true, workbook windows will be opened at the same position with the same size
  72. /// every time they are loaded.
  73. /// </summary>
  74. bool lock_windows = false;
  75. /// <summary>
  76. /// The settings to allow the revision lock to be removed.
  77. /// </summary>
  78. lock_verifier revision_lock;
  79. /// <summary>
  80. /// The settings to allow the structure and windows lock to be removed.
  81. /// </summary>
  82. lock_verifier workbook_lock;
  83. };
  84. } // namespace xlnt