|
40 | 40 | */ |
41 | 41 | public interface Claims extends Map<String, Object>, ClaimsMutator<Claims> { |
42 | 42 |
|
43 | | - /** JWT {@code Issuer} claims parameter name: <code>"iss"</code> */ |
44 | | - public static final String ISSUER = "iss"; |
45 | | - |
46 | | - /** JWT {@code Subject} claims parameter name: <code>"sub"</code> */ |
47 | | - public static final String SUBJECT = "sub"; |
48 | | - |
49 | | - /** JWT {@code Audience} claims parameter name: <code>"aud"</code> */ |
50 | | - public static final String AUDIENCE = "aud"; |
51 | | - |
52 | | - /** JWT {@code Expiration} claims parameter name: <code>"exp"</code> */ |
53 | | - public static final String EXPIRATION = "exp"; |
54 | | - |
55 | | - /** JWT {@code Not Before} claims parameter name: <code>"nbf"</code> */ |
56 | | - public static final String NOT_BEFORE = "nbf"; |
57 | | - |
58 | | - /** JWT {@code Issued At} claims parameter name: <code>"iat"</code> */ |
59 | | - public static final String ISSUED_AT = "iat"; |
60 | | - |
61 | | - /** JWT {@code JWT ID} claims parameter name: <code>"jti"</code> */ |
62 | | - public static final String ID = "jti"; |
63 | | - |
64 | | - /** |
65 | | - * Returns the JWT <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.1"> |
66 | | - * <code>iss</code></a> (issuer) value or {@code null} if not present. |
67 | | - * |
68 | | - * @return the JWT {@code iss} value or {@code null} if not present. |
69 | | - */ |
70 | | - String getIssuer(); |
71 | | - |
72 | | - /** |
73 | | - * {@inheritDoc} |
74 | | - */ |
75 | | - @Override //only for better/targeted JavaDoc |
76 | | - Claims setIssuer(String iss); |
77 | | - |
78 | | - /** |
79 | | - * Returns the JWT <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.2"> |
80 | | - * <code>sub</code></a> (subject) value or {@code null} if not present. |
81 | | - * |
82 | | - * @return the JWT {@code sub} value or {@code null} if not present. |
83 | | - */ |
84 | | - String getSubject(); |
85 | | - |
86 | | - /** |
87 | | - * {@inheritDoc} |
88 | | - */ |
89 | | - @Override //only for better/targeted JavaDoc |
90 | | - Claims setSubject(String sub); |
91 | | - |
92 | | - /** |
93 | | - * Returns the JWT <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.3"> |
94 | | - * <code>aud</code></a> (audience) value or {@code null} if not present. |
95 | | - * |
96 | | - * @return the JWT {@code aud} value or {@code null} if not present. |
97 | | - */ |
98 | | - String getAudience(); |
99 | | - |
100 | | - /** |
101 | | - * {@inheritDoc} |
102 | | - */ |
103 | | - @Override //only for better/targeted JavaDoc |
104 | | - Claims setAudience(String aud); |
105 | | - |
106 | | - /** |
107 | | - * Returns the JWT <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.4"> |
108 | | - * <code>exp</code></a> (expiration) timestamp or {@code null} if not present. |
109 | | - * |
110 | | - * <p>A JWT obtained after this timestamp should not be used.</p> |
111 | | - * |
112 | | - * @return the JWT {@code exp} value or {@code null} if not present. |
113 | | - */ |
114 | | - Date getExpiration(); |
115 | | - |
116 | | - /** |
117 | | - * {@inheritDoc} |
118 | | - */ |
119 | | - @Override //only for better/targeted JavaDoc |
120 | | - Claims setExpiration(Date exp); |
121 | | - |
122 | | - /** |
123 | | - * Returns the JWT <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.5"> |
124 | | - * <code>nbf</code></a> (not before) timestamp or {@code null} if not present. |
125 | | - * |
126 | | - * <p>A JWT obtained before this timestamp should not be used.</p> |
127 | | - * |
128 | | - * @return the JWT {@code nbf} value or {@code null} if not present. |
129 | | - */ |
130 | | - Date getNotBefore(); |
131 | | - |
132 | | - /** |
133 | | - * {@inheritDoc} |
134 | | - */ |
135 | | - @Override //only for better/targeted JavaDoc |
136 | | - Claims setNotBefore(Date nbf); |
137 | | - |
138 | | - /** |
139 | | - * Returns the JWT <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.6"> |
140 | | - * <code>iat</code></a> (issued at) timestamp or {@code null} if not present. |
141 | | - * |
142 | | - * <p>If present, this value is the timestamp when the JWT was created.</p> |
143 | | - * |
144 | | - * @return the JWT {@code iat} value or {@code null} if not present. |
145 | | - */ |
146 | | - Date getIssuedAt(); |
147 | | - |
148 | | - /** |
149 | | - * {@inheritDoc} |
150 | | - */ |
151 | | - @Override //only for better/targeted JavaDoc |
152 | | - Claims setIssuedAt(Date iat); |
153 | | - |
154 | | - /** |
155 | | - * Returns the JWTs <a href="https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-25#section-4.1.7"> |
156 | | - * <code>jti</code></a> (JWT ID) value or {@code null} if not present. |
157 | | - * |
158 | | - * <p>This value is a CaSe-SenSiTiVe unique identifier for the JWT. If available, this value is expected to be |
159 | | - * assigned in a manner that ensures that there is a negligible probability that the same value will be |
160 | | - * accidentally |
161 | | - * assigned to a different data object. The ID can be used to prevent the JWT from being replayed.</p> |
162 | | - * |
163 | | - * @return the JWT {@code jti} value or {@code null} if not present. |
164 | | - */ |
165 | | - String getId(); |
166 | | - |
167 | | - /** |
168 | | - * {@inheritDoc} |
169 | | - */ |
170 | | - @Override //only for better/targeted JavaDoc |
171 | | - Claims setId(String jti); |
172 | | - |
173 | | - /** |
174 | | - * Returns the JWTs claim ({@code claimName}) value as a type {@code requiredType}, or {@code null} if not present. |
175 | | - * |
176 | | - * <p>JJWT only converts simple String, Date, Long, Integer, Short and Byte types automatically. Anything more |
177 | | - * complex is expected to be already converted to your desired type by the JSON |
178 | | - * {@link io.jsonwebtoken.io.Deserializer Deserializer} implementation. You may specify a custom Deserializer for a |
179 | | - * JwtParser with the desired conversion configuration via the {@link JwtParserBuilder#deserializeJsonWith} method. |
180 | | - * See <a href="https://github.com/jwtk/jjwt#custom-json-processor">custom JSON processor</a></a> for more |
181 | | - * information. If using Jackson, you can specify custom claim POJO types as described in |
182 | | - * <a href="https://github.com/jwtk/jjwt#json-jackson-custom-types">custom claim types</a>. |
183 | | - * |
184 | | - * @param claimName name of claim |
185 | | - * @param requiredType the type of the value expected to be returned |
186 | | - * @param <T> the type of the value expected to be returned |
187 | | - * @return the JWT {@code claimName} value or {@code null} if not present. |
188 | | - * @throws RequiredTypeException throw if the claim value is not null and not of type {@code requiredType} |
189 | | - */ |
190 | | - <T> T get(String claimName, Class<T> requiredType); |
191 | 43 | } |
0 commit comments