|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +using System.Text.Encodings.Web; |
| 5 | +using System.Text.Json; |
| 6 | + |
| 7 | +namespace Microsoft.IdentityModel.Tokens |
| 8 | +{ |
| 9 | + /// <summary> |
| 10 | + /// JsonEncodedText used with utf8Writer when writing property names for JsonWebKey. |
| 11 | + /// Common names are initialized on startup, lazy for others. |
| 12 | + /// </summary> |
| 13 | + internal static class EncodedJsonWebKeyParameterNames |
| 14 | + { |
| 15 | + internal static bool _algSet; |
| 16 | + internal static JsonEncodedText _alg; |
| 17 | + internal static bool _crvSet; |
| 18 | + internal static JsonEncodedText _crv; |
| 19 | + internal static bool _dSet; |
| 20 | + internal static JsonEncodedText _d; |
| 21 | + internal static bool _dpSet; |
| 22 | + internal static JsonEncodedText _dp; |
| 23 | + internal static bool _dqSet; |
| 24 | + internal static JsonEncodedText _dq; |
| 25 | + internal static bool _kSet; |
| 26 | + internal static JsonEncodedText _k; |
| 27 | + internal static bool _keyopsSet; |
| 28 | + internal static JsonEncodedText _keyOps; |
| 29 | + internal static bool _othSet; |
| 30 | + internal static JsonEncodedText _oth; |
| 31 | + internal static bool _pSet; |
| 32 | + internal static JsonEncodedText _p; |
| 33 | + internal static bool _qSet; |
| 34 | + internal static JsonEncodedText _q; |
| 35 | + internal static bool _qiSet; |
| 36 | + internal static JsonEncodedText _qi; |
| 37 | + internal static bool _x5tS256Set; |
| 38 | + internal static JsonEncodedText _x5tS256; |
| 39 | + internal static bool _x5uSet; |
| 40 | + internal static JsonEncodedText _x5u; |
| 41 | + internal static bool _xSet; |
| 42 | + internal static JsonEncodedText _x; |
| 43 | + internal static bool _ySet; |
| 44 | + internal static JsonEncodedText _y; |
| 45 | + |
| 46 | + public static JsonEncodedText Alg |
| 47 | + { |
| 48 | + get |
| 49 | + { |
| 50 | + if (!_algSet) |
| 51 | + { |
| 52 | + _alg = JsonEncodedText.Encode(JsonWebKeyParameterNames.Alg, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 53 | + _algSet = true; |
| 54 | + } |
| 55 | + |
| 56 | + return _alg; |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + public static JsonEncodedText Crv |
| 61 | + { |
| 62 | + get |
| 63 | + { |
| 64 | + if (!_crvSet) |
| 65 | + { |
| 66 | + _crv = JsonEncodedText.Encode(JsonWebKeyParameterNames.Crv, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 67 | + _crvSet = true; |
| 68 | + } |
| 69 | + |
| 70 | + return _crv; |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + public static JsonEncodedText D |
| 75 | + { |
| 76 | + get |
| 77 | + { |
| 78 | + if (!_dSet) |
| 79 | + { |
| 80 | + _d = JsonEncodedText.Encode(JsonWebKeyParameterNames.D, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 81 | + _dSet = true; |
| 82 | + } |
| 83 | + |
| 84 | + return _d; |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + public static JsonEncodedText DP |
| 89 | + { |
| 90 | + get |
| 91 | + { |
| 92 | + if (!_dpSet) |
| 93 | + { |
| 94 | + _dp = JsonEncodedText.Encode(JsonWebKeyParameterNames.DP, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 95 | + _dpSet = true; |
| 96 | + } |
| 97 | + |
| 98 | + return _dp; |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + public static JsonEncodedText DQ |
| 103 | + { |
| 104 | + get |
| 105 | + { |
| 106 | + if (!_dqSet) |
| 107 | + { |
| 108 | + _dq = JsonEncodedText.Encode(JsonWebKeyParameterNames.DQ, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 109 | + _dqSet = true; |
| 110 | + } |
| 111 | + |
| 112 | + return _dq; |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + public static readonly JsonEncodedText E = JsonEncodedText.Encode(JsonWebKeyParameterNames.E, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 117 | + |
| 118 | + public static JsonEncodedText K |
| 119 | + { |
| 120 | + get |
| 121 | + { |
| 122 | + if (!_kSet) |
| 123 | + { |
| 124 | + _k = JsonEncodedText.Encode(JsonWebKeyParameterNames.K, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 125 | + _kSet = true; |
| 126 | + } |
| 127 | + |
| 128 | + return _k; |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + public static JsonEncodedText KeyOps |
| 133 | + { |
| 134 | + get |
| 135 | + { |
| 136 | + if (!_keyopsSet) |
| 137 | + { |
| 138 | + _keyOps = JsonEncodedText.Encode(JsonWebKeyParameterNames.KeyOps, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 139 | + _keyopsSet = true; |
| 140 | + } |
| 141 | + |
| 142 | + return _keyOps; |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + public static readonly JsonEncodedText Keys = JsonEncodedText.Encode(JsonWebKeyParameterNames.Keys, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 147 | + |
| 148 | + public static readonly JsonEncodedText Kid = JsonEncodedText.Encode(JsonWebKeyParameterNames.Kid, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 149 | + |
| 150 | + public static readonly JsonEncodedText Kty = JsonEncodedText.Encode(JsonWebKeyParameterNames.Kty, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 151 | + |
| 152 | + public static readonly JsonEncodedText N = JsonEncodedText.Encode(JsonWebKeyParameterNames.N, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 153 | + |
| 154 | + public static JsonEncodedText Oth |
| 155 | + { |
| 156 | + get |
| 157 | + { |
| 158 | + if (!_othSet) |
| 159 | + { |
| 160 | + _oth = JsonEncodedText.Encode(JsonWebKeyParameterNames.Oth, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 161 | + _othSet = true; |
| 162 | + } |
| 163 | + |
| 164 | + return _oth; |
| 165 | + } |
| 166 | + } |
| 167 | + |
| 168 | + public static JsonEncodedText P |
| 169 | + { |
| 170 | + get |
| 171 | + { |
| 172 | + if (!_pSet) |
| 173 | + { |
| 174 | + _p = JsonEncodedText.Encode(JsonWebKeyParameterNames.P, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 175 | + _pSet = true; |
| 176 | + } |
| 177 | + |
| 178 | + return _p; |
| 179 | + } |
| 180 | + } |
| 181 | + public static JsonEncodedText Q |
| 182 | + { |
| 183 | + get |
| 184 | + { |
| 185 | + if (!_qSet) |
| 186 | + { |
| 187 | + _q = JsonEncodedText.Encode(JsonWebKeyParameterNames.Q, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 188 | + _qSet = true; |
| 189 | + } |
| 190 | + |
| 191 | + return _q; |
| 192 | + } |
| 193 | + } |
| 194 | + |
| 195 | + public static JsonEncodedText QI |
| 196 | + { |
| 197 | + get |
| 198 | + { |
| 199 | + if (!_qiSet) |
| 200 | + { |
| 201 | + _qi = JsonEncodedText.Encode(JsonWebKeyParameterNames.QI, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 202 | + _qiSet = true; |
| 203 | + } |
| 204 | + |
| 205 | + return _qi; |
| 206 | + } |
| 207 | + } |
| 208 | + |
| 209 | + public static readonly JsonEncodedText Use = JsonEncodedText.Encode(JsonWebKeyParameterNames.Use, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 210 | + |
| 211 | + public static readonly JsonEncodedText X5c = JsonEncodedText.Encode(JsonWebKeyParameterNames.X5c, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 212 | + |
| 213 | + public static readonly JsonEncodedText X5t = JsonEncodedText.Encode(JsonWebKeyParameterNames.X5t, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 214 | + |
| 215 | + public static JsonEncodedText X5tS256 |
| 216 | + { |
| 217 | + get |
| 218 | + { |
| 219 | + if (!_x5tS256Set) |
| 220 | + { |
| 221 | + _x5tS256 = JsonEncodedText.Encode(JsonWebKeyParameterNames.X5tS256, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 222 | + _x5tS256Set = true; |
| 223 | + } |
| 224 | + |
| 225 | + return _x5tS256; |
| 226 | + } |
| 227 | + } |
| 228 | + |
| 229 | + public static JsonEncodedText X5u |
| 230 | + { |
| 231 | + get |
| 232 | + { |
| 233 | + if (!_x5uSet) |
| 234 | + { |
| 235 | + _x5u = JsonEncodedText.Encode(JsonWebKeyParameterNames.X5u, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 236 | + _x5uSet = true; |
| 237 | + } |
| 238 | + |
| 239 | + return _x5u; |
| 240 | + } |
| 241 | + } |
| 242 | + |
| 243 | + public static JsonEncodedText X |
| 244 | + { |
| 245 | + get |
| 246 | + { |
| 247 | + if (!_xSet) |
| 248 | + { |
| 249 | + _x = JsonEncodedText.Encode(JsonWebKeyParameterNames.X, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 250 | + _xSet = true; |
| 251 | + } |
| 252 | + |
| 253 | + return _x; |
| 254 | + } |
| 255 | + } |
| 256 | + |
| 257 | + public static JsonEncodedText Y |
| 258 | + { |
| 259 | + get |
| 260 | + { |
| 261 | + if (!_ySet) |
| 262 | + { |
| 263 | + _y = JsonEncodedText.Encode(JsonWebKeyParameterNames.Y, JavaScriptEncoder.UnsafeRelaxedJsonEscaping); |
| 264 | + _ySet = true; |
| 265 | + } |
| 266 | + |
| 267 | + return _y; |
| 268 | + } |
| 269 | + } |
| 270 | + } |
| 271 | +} |
0 commit comments