001package com.nimbusds.jose;
002
003
004import com.nimbusds.jwt.JWTClaimNames;
005
006/**
007 * JSON Web Signature (JWS) and JSON Web Encryption (JWE) header parameter
008 * names.
009 *
010 * <p>The header parameter names defined in
011 * <a href="https://datatracker.ietf.org/doc/html/rfc7515">RFC 7515</a> (JWS),
012 * <a href="https://datatracker.ietf.org/doc/html/rfc7516">RFC 7516</a> (JWE)
013 * and other JOSE related standards are tracked in a
014 * <a href="https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-header-parameters">JWS
015 * and JWE header parameters registry</a> administered by IANA.
016 *
017 * <p>Note, some header parameters here may not be present in the IANA registry
018 * (yet).
019 *
020 * @author Nathaniel Hart
021 * @author Vladimir Dzhuvinov
022 * @version 2024-06-27
023 */
024public final class HeaderParameterNames {
025        
026        
027        ////////////////////////////////////////////////////////////////////////////////
028        // Generic JWS and JWE Header Parameters
029        ////////////////////////////////////////////////////////////////////////////////
030        
031        
032        /**
033         * Used in {@link JWSHeader} and {@link JWEHeader}.
034         *
035         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.1">RFC 7515 "alg" (JWS Algorithm) Header Parameter</a>
036         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.1">RFC 7516 "alg" (JWE Algorithm) Header Parameter</a>
037         */
038        public static final String ALGORITHM = "alg";
039        
040        
041        /**
042         * Used in {@link JWEHeader}.
043         *
044         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.2">RFC 7516 "enc" (Encryption Algorithm) Header Parameter</a>
045         */
046        public static final String ENCRYPTION_ALGORITHM = "enc";
047        
048        
049        /**
050         * Used in {@link JWEHeader}.
051         *
052         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.3">RFC 7516 "zip" (Compression Algorithm) Header Parameter</a>
053         */
054        public static final String COMPRESSION_ALGORITHM = "zip";
055        
056        
057        /**
058         * Used in {@link JWSHeader} and {@link JWEHeader}.
059         *
060         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.2">RFC 7515 "jku" (JWK Set URL) Header Parameter</a>
061         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.4">RFC 7516 "jku" (JWK Set URL) Header Parameter</a>
062         */
063        public static final String JWK_SET_URL = "jku";
064        
065        
066        /**
067         * Used in {@link JWSHeader} and {@link JWEHeader}.
068         *
069         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.3">RFC 7515 "jwk" (JSON Web Key) Header Parameter</a>
070         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.5">RFC 7516 "jwk" (JSON Web Key) Header Parameter</a>
071         */
072        public static final String JWK = "jwk";
073        
074        
075        /**
076         * Used in {@link JWSHeader} and {@link JWEHeader}.
077         *
078         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.4">RFC 7515 "kid" (Key ID) Header Parameter</a>
079         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.6">RFC 7516 "kid" (Key ID) Header Parameter</a>
080         */
081        public static final String KEY_ID = "kid";
082        
083        
084        /**
085         * Used in {@link JWSHeader} and {@link JWEHeader}.
086         *
087         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.5">RFC 7515 "x5u" (X.509 Certificate URL) Header Parameter</a>
088         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.7">RFC 7516 "x5u" (X.509 Certificate URL) Header Parameter</a>
089         */
090        public static final String X_509_CERT_URL = "x5u";
091        
092        
093        /**
094         * Used in {@link JWSHeader} and {@link JWEHeader}.
095         *
096         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.6">RFC 7515 "x5c" (X.509 Certificate Chain) Header Parameter</a>
097         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.8">RFC 7516 "x5c" (X.509 Certificate Chain) Header Parameter</a>
098         */
099        public static final String X_509_CERT_CHAIN = "x5c";
100        
101        
102        /**
103         * Used in {@link JWSHeader} and {@link JWEHeader}.
104         *
105         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.7">RFC 7515 "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter</a>
106         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.9">RFC 7516 "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter</a>
107         */
108        public static final String X_509_CERT_SHA_1_THUMBPRINT = "x5t";
109        
110        
111        /**
112         * Used in {@link JWSHeader} and {@link JWEHeader}.
113         *
114         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.8">RFC 7515 "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header Parameter</a>
115         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.10">RFC 7516 "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header Parameter</a>
116         */
117        public static final String X_509_CERT_SHA_256_THUMBPRINT = "x5t#S256";
118        
119        
120        /**
121         * Used in {@link JWSHeader} and {@link JWEHeader}.
122         *
123         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.9">RFC 7515 "typ" (Type) Header Parameter</a>
124         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.11">RFC 7516 "typ" (Type) Header Parameter</a>
125         */
126        public static final String TYPE = "typ";
127        
128        
129        /**
130         * Used in {@link JWSHeader} and {@link JWEHeader}.
131         *
132         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.10">RFC 7515 "cty" (Content Type) Header Parameter</a>
133         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.12">RFC 7516 "cty" (Content Type) Header Parameter</a>
134         */
135        public static final String CONTENT_TYPE = "cty";
136        
137        
138        /**
139         * Used in {@link JWSHeader} and {@link JWEHeader}.
140         *
141         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.11">RFC 7515 "crit" (Critical) Header Parameter</a>
142         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7516#section-4.1.13">RFC 7516 "crit" (Critical) Header Parameter</a>
143         */
144        public static final String CRITICAL = "crit";
145        
146        
147        ////////////////////////////////////////////////////////////////////////////////
148        // Algorithm-Specific Header Parameters
149        ////////////////////////////////////////////////////////////////////////////////
150        
151        
152        /**
153         * Used in {@link JWEHeader} with ECDH key agreement.
154         *
155         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7518#section-4.6.1.1">RFC 7518 "epk" (Ephemeral Public Key) Header Parameter</a>
156         */
157        public static final String EPHEMERAL_PUBLIC_KEY = "epk";
158
159        
160        /**
161         * Used in {@link JWEHeader} with ECDH key agreement.
162         *
163         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7518#section-4.6.1.2">RFC 7518 "apu" (Agreement PartyUInfo) Header Parameter</a>
164         */
165        public static final String AGREEMENT_PARTY_U_INFO = "apu";
166        
167        
168        /**
169         * Used in {@link JWEHeader} with ECDH key agreement.
170         *
171         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7518#section-4.6.1.3">RFC 7518 "apv" (Agreement PartyVInfo) Header Parameter</a>
172         */
173        public static final String AGREEMENT_PARTY_V_INFO = "apv";
174        
175        
176        /**
177         * Used in {@link JWEHeader} with AES GCN key encryption.
178         *
179         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7518#section-4.7.1.1">RFC 7518 "iv" (Initialization Vector) Header Parameter</a>
180         */
181        public static final String INITIALIZATION_VECTOR = "iv";
182        
183        
184        /**
185         * Used in {@link JWEHeader} with AES GCN key encryption.
186         *
187         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7518#section-4.7.1.2">RFC 7518 "tag" (Authentication Tag) Header Parameter</a>
188         */
189        public static final String AUTHENTICATION_TAG = "tag";
190        
191        
192        /**
193         * Used in {@link JWEHeader} with PBES2 key encryption.
194         *
195         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7518#section-4.8.1.1">RFC 7518 "p2s" (PBES2 Salt Input) Header Parameter</a>
196         */
197        public static final String PBES2_SALT_INPUT = "p2s";
198        
199        
200        /**
201         * Used in {@link JWEHeader} with PBES2 key encryption.
202         *
203         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7518#section-4.8.1.2">RFC 7518 "p2c" (PBES2 Count) Header Parameter</a>
204         */
205        public static final String PBES2_COUNT = "p2c";
206        
207        
208        /**
209         * Used in {@link JWEHeader} with ECDH-1PU key agreement.
210         *
211         * @see <a href="https://datatracker.ietf.org/doc/html/draft-madden-jose-ecdh-1pu-04#section-2.2.1">"skid" Header Parameter</a>
212         */
213        public static final String SENDER_KEY_ID = "skid";
214        
215        
216        ////////////////////////////////////////////////////////////////////////////////
217        // RFC 7797 (JWS Unencoded Payload Option) Header Parameters
218        ////////////////////////////////////////////////////////////////////////////////
219        
220        
221        /**
222         * Used in {@link JWSHeader} with unencoded {@link Payload}.
223         *
224         * @see <a href="https://datatracker.ietf.org/doc/html/rfc7797#section-3">RFC 7797 "b64" (base64url-encode payload) Header Parameter</a>
225         */
226        public static final String BASE64_URL_ENCODE_PAYLOAD = "b64";
227
228
229        ////////////////////////////////////////////////////////////////////////////////
230        // RFC 7519 (JWT) claims replicated as JWE header parameters
231        ////////////////////////////////////////////////////////////////////////////////
232
233        /**
234         * Used in {@link JWEHeader} where the issuer claim is replicated as a
235         * header parameter.
236         */
237        public static final String ISSUER = JWTClaimNames.ISSUER;
238
239
240        /**
241         * Used in {@link JWEHeader} where the issuer claim is replicated as a
242         * header parameter.
243         */
244        public static final String SUBJECT = JWTClaimNames.SUBJECT;
245
246
247        /**
248         * Used in {@link JWEHeader} where the issuer claim is replicated as a
249         * header parameter.
250         */
251        public static final String AUDIENCE = JWTClaimNames.AUDIENCE;
252        
253        
254        private HeaderParameterNames() {}
255}