|
| 1 | +/* |
| 2 | + Copyright (c) 2015 Ki |
| 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 | + |
| 23 | +using System; |
| 24 | + |
| 25 | +namespace Mdcrypt { |
| 26 | + /// <summary> |
| 27 | + /// Various presets of protections. |
| 28 | + /// </summary> |
| 29 | + public enum ProtectionPreset { |
| 30 | + /// <summary> The protection does not belong to any preset. </summary> |
| 31 | + None = 0, |
| 32 | + |
| 33 | + /// <summary> The protection provides basic security. </summary> |
| 34 | + Minimum = 1, |
| 35 | + |
| 36 | + /// <summary> The protection provides normal security for public release. </summary> |
| 37 | + Normal = 2, |
| 38 | + |
| 39 | + /// <summary> The protection provides better security with observable performance impact. </summary> |
| 40 | + Aggressive = 3, |
| 41 | + |
| 42 | + /// <summary> The protection provides strongest security with possible incompatibility. </summary> |
| 43 | + Maximum = 4 |
| 44 | + } |
| 45 | + |
| 46 | + /// <summary> |
| 47 | + /// Indicates the <see cref="Protection" /> must initialize before the specified protections. |
| 48 | + /// </summary> |
| 49 | + [AttributeUsage(AttributeTargets.Class)] |
| 50 | + public sealed class BeforeProtectionAttribute : Attribute { |
| 51 | + /// <summary> |
| 52 | + /// Gets the full IDs of the specified protections. |
| 53 | + /// </summary> |
| 54 | + /// <value>The IDs of protections.</value> |
| 55 | + public string[] Ids { get; } |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Initializes a new instance of the <see cref="BeforeProtectionAttribute" /> class. |
| 59 | + /// </summary> |
| 60 | + /// <param name="ids">The full IDs of the specified protections.</param> |
| 61 | + public BeforeProtectionAttribute(params string[] ids) { |
| 62 | + Ids = ids; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + /// <summary> |
| 67 | + /// Indicates the <see cref="Protection" /> must initialize after the specified protections. |
| 68 | + /// </summary> |
| 69 | + [AttributeUsage(AttributeTargets.Class)] |
| 70 | + public sealed class AfterProtectionAttribute : Attribute { |
| 71 | + /// <summary> |
| 72 | + /// Gets the full IDs of the specified protections. |
| 73 | + /// </summary> |
| 74 | + /// <value>The IDs of protections.</value> |
| 75 | + public string[] Ids { get; } |
| 76 | + |
| 77 | + /// <summary> |
| 78 | + /// Initializes a new instance of the <see cref="BeforeProtectionAttribute" /> class. |
| 79 | + /// </summary> |
| 80 | + /// <param name="ids">The full IDs of the specified protections.</param> |
| 81 | + public AfterProtectionAttribute(params string[] ids) { |
| 82 | + Ids = ids; |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + /// <summary> |
| 87 | + /// Base class of Mdcrypt protections. |
| 88 | + /// </summary> |
| 89 | + /// <remarks> |
| 90 | + /// A parameterless constructor must exists in derived classes to enable plugin discovery. |
| 91 | + /// </remarks> |
| 92 | + public abstract class Protection { |
| 93 | + /// <summary> |
| 94 | + /// Gets the identifier of component used by users. |
| 95 | + /// </summary> |
| 96 | + /// <value>The identifier of component.</value> |
| 97 | + public abstract string Id { get; } |
| 98 | + |
| 99 | + /// <summary> |
| 100 | + /// Gets the name of component. |
| 101 | + /// </summary> |
| 102 | + /// <value>The name of component.</value> |
| 103 | + public abstract string Name { get; } |
| 104 | + |
| 105 | + /// <summary> |
| 106 | + /// Gets the description of component. |
| 107 | + /// </summary> |
| 108 | + /// <value>The description of component.</value> |
| 109 | + public abstract string Description { get; } |
| 110 | + |
| 111 | + /// <summary> |
| 112 | + /// Gets the preset this protection is in. |
| 113 | + /// </summary> |
| 114 | + /// <value>The protection's preset.</value> |
| 115 | + public abstract ProtectionPreset Preset { get; } |
| 116 | + } |
| 117 | +} |
0 commit comments