MetadataBLOBHeader.java

1
package com.yubico.fido.metadata;
2
3
import com.fasterxml.jackson.annotation.JsonIgnore;
4
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
5
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
6
import java.net.URL;
7
import java.security.cert.X509Certificate;
8
import java.util.List;
9
import java.util.Optional;
10
import lombok.Builder;
11
import lombok.NonNull;
12
import lombok.Value;
13
import lombok.extern.jackson.Jacksonized;
14
15
/**
16
 * The metadata BLOB is a JSON Web Token (see [<a
17
 * href="https://fidoalliance.org/specs/mds/fido-metadata-service-v3.0-ps-20210518.html#biblio-jwt">JWT</a>]
18
 * and [<a
19
 * href="https://fidoalliance.org/specs/mds/fido-metadata-service-v3.0-ps-20210518.html#biblio-jws">JWS</a>]).
20
 *
21
 * <p>This type represents the contents of the JWT header.
22
 *
23
 * @see <a
24
 *     href="https://fidoalliance.org/specs/mds/fido-metadata-service-v3.0-ps-20210518.html#metadata-blob">FIDO
25
 *     Metadata Service §3.1.7. Metadata BLOB</a>
26
 * @see <a href="https://datatracker.ietf.org/doc/html/rfc7519">RFC 7519: JSON Web Token (JWT)</a>
27
 */
28
@Value
29
@Builder(toBuilder = true)
30
@Jacksonized
31
public class MetadataBLOBHeader {
32
33
  /**
34
   * @see <a href="https://datatracker.ietf.org/doc/html/rfc7519#section-5.1">RFC 7519 §5.1. "typ"
35
   *     (Type) Header Parameter</a>
36
   */
37
  String typ;
38
39
  /**
40
   * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.1">RFC 7515 §4.1.1.
41
   *     "alg" (Algorithm) Header Parameter</a>
42
   */
43
  @NonNull String alg;
44
45
  /**
46
   * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.5">RFC 7515 §4.1.5.
47
   *     "x5u" (X.509 URL) Header Parameter</a>
48
   */
49
  URL x5u;
50
51
  /**
52
   * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.6">RFC 7515 §4.1.6.
53
   *     "x5c" (X.509 Certificate Chain) Header Parameter</a>
54
   */
55
  @JsonDeserialize(contentConverter = CertFromBase64Converter.class)
56
  @JsonSerialize(contentConverter = CertToBase64Converter.class)
57
  List<X509Certificate> x5c;
58
59 1 1. <init> : negated conditional → KILLED
  private MetadataBLOBHeader(String typ, @NonNull String alg, URL x5u, List<X509Certificate> x5c) {
60
    this.typ = typ;
61
    this.alg = alg;
62
    this.x5u = x5u;
63
    this.x5c = x5c;
64
65 2 1. <init> : negated conditional → KILLED
2. <init> : negated conditional → KILLED
    if (typ != null && !typ.equals("JWT")) {
66
      throw new IllegalArgumentException("Unsupported JWT type: " + typ);
67
    }
68
  }
69
70
  /**
71
   * @see <a href="https://datatracker.ietf.org/doc/html/rfc7519#section-5.1">RFC 7519 §5.1. "typ"
72
   *     (Type) Header Parameter</a>
73
   */
74
  public Optional<String> getTyp() {
75 1 1. getTyp : replaced return value with Optional.empty for com/yubico/fido/metadata/MetadataBLOBHeader::getTyp → SURVIVED
    return Optional.ofNullable(typ);
76
  }
77
78
  /**
79
   * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.5">RFC 7515 §4.1.5.
80
   *     "x5u" (X.509 URL) Header Parameter</a>
81
   */
82
  public Optional<URL> getX5u() {
83 1 1. getX5u : replaced return value with Optional.empty for com/yubico/fido/metadata/MetadataBLOBHeader::getX5u → KILLED
    return Optional.ofNullable(x5u);
84
  }
85
86
  /**
87
   * @see <a href="https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.6">RFC 7515 §4.1.6.
88
   *     "x5c" (X.509 Certificate Chain) Header Parameter</a>
89
   */
90
  // @JsonIgnore needed because of:
91
  // https://github.com/FasterXML/jackson-databind/issues/4413#issuecomment-1977989776
92
  @JsonIgnore
93
  public Optional<List<X509Certificate>> getX5c() {
94 1 1. getX5c : replaced return value with Optional.empty for com/yubico/fido/metadata/MetadataBLOBHeader::getX5c → KILLED
    return Optional.ofNullable(x5c);
95
  }
96
}

Mutations

59

1.1
Location : <init>
Killed by : com.yubico.fido.metadata.FidoMds3Spec
negated conditional → KILLED

65

1.1
Location : <init>
Killed by : com.yubico.fido.metadata.JsonIoSpec
negated conditional → KILLED

2.2
Location : <init>
Killed by : com.yubico.fido.metadata.FidoMds3Spec
negated conditional → KILLED

75

1.1
Location : getTyp
Killed by : none
replaced return value with Optional.empty for com/yubico/fido/metadata/MetadataBLOBHeader::getTyp → SURVIVED

83

1.1
Location : getX5u
Killed by : com.yubico.fido.metadata.FidoMetadataDownloaderSpec
replaced return value with Optional.empty for com/yubico/fido/metadata/MetadataBLOBHeader::getX5u → KILLED

94

1.1
Location : getX5c
Killed by : com.yubico.fido.metadata.FidoMetadataDownloaderSpec
replaced return value with Optional.empty for com/yubico/fido/metadata/MetadataBLOBHeader::getX5c → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0