[CXF-7519] The cxf-rt-transports-http-jetty should not rely on the old blueprint...
[cxf.git] / rt / rs / security / jose-parent / jose / src / main / java / org / apache / cxf / rs / security / jose / jwt / JwtToken.java
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.cxf.rs.security.jose.jwt;
20
21 import org.apache.cxf.rs.security.jose.jwe.JweHeaders;
22 import org.apache.cxf.rs.security.jose.jws.JwsHeaders;
23
24
25
26 public class JwtToken {
27 private JwsHeaders jwsHeaders;
28 private JweHeaders jweHeaders;
29 private JwtClaims claims;
30
31 public JwtToken(JwtClaims claims) {
32 this(new JwsHeaders() { }, new JweHeaders() { }, claims);
33 }
34 public JwtToken(JwsHeaders jwsHeaders, JwtClaims claims) {
35 this(jwsHeaders, new JweHeaders() { }, claims);
36 }
37 public JwtToken(JweHeaders jweHeaders, JwtClaims claims) {
38 this(new JwsHeaders() { }, jweHeaders, claims);
39 }
40 public JwtToken(JwsHeaders jwsHeaders, JweHeaders jweHeaders, JwtClaims claims) {
41 this.jwsHeaders = jwsHeaders;
42 this.jweHeaders = jweHeaders;
43 this.claims = claims;
44 }
45 public JwsHeaders getJwsHeaders() {
46 return jwsHeaders;
47 }
48 public JweHeaders getJweHeaders() {
49 return jweHeaders;
50 }
51 public JwtClaims getClaims() {
52 return claims;
53 }
54 public Object getJwsHeader(String name) {
55 return jwsHeaders.getHeader(name);
56 }
57 public Object getJweHeader(String name) {
58 return jweHeaders.getHeader(name);
59 }
60 public Object getClaim(String name) {
61 return claims.getClaim(name);
62 }
63 public int hashCode() {
64 return jwsHeaders.hashCode() + 37 * claims.hashCode() + 37 * jweHeaders.hashCode();
65 }
66
67 public boolean equals(Object obj) {
68 return obj instanceof JwtToken
69 && ((JwtToken)obj).jwsHeaders.equals(this.jwsHeaders)
70 && ((JwtToken)obj).jweHeaders.equals(this.jweHeaders)
71 && ((JwtToken)obj).claims.equals(this.claims);
72 }
73 }