• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zalando / logbook / 5242

09 Jan 2026 05:56PM UTC coverage: 98.199% (-1.8%) from 100.0%
5242

push

github

web-flow
Fix coveral on main builds (#2201)

* Switch to com.github.hazendaz.maven:coveralls-maven-plugin as org.eluder.coveralls is deprecated

* tmp allow coveral on PRs

* revert the tmp allow coveral on PRs

* use ${project.artifactId} instaed of ${artifactId} in pom.xml

754 of 768 branches covered (98.18%)

3871 of 3942 relevant lines covered (98.2%)

0.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/logbook-core/src/main/java/org/zalando/logbook/core/attributes/JwtAllMatchingClaimsExtractor.java
1
package org.zalando.logbook.core.attributes;
2

3
import lombok.EqualsAndHashCode;
4
import lombok.extern.slf4j.Slf4j;
5
import org.apiguardian.api.API;
6
import org.zalando.logbook.HttpRequest;
7
import org.zalando.logbook.attributes.AttributeExtractor;
8
import org.zalando.logbook.attributes.HttpAttributes;
9

10
import jakarta.annotation.Nonnull;
11
import jakarta.annotation.Nullable;
12
import java.util.ArrayList;
13
import java.util.Collections;
14
import java.util.List;
15
import java.util.Map;
16
import java.util.Optional;
17
import tools.jackson.databind.json.JsonMapper;
18

19
import static java.util.stream.Collectors.toMap;
20
import static org.apiguardian.api.API.Status.EXPERIMENTAL;
21

22
/**
23
 * Extracts all matching claims from the JWT bearer token in the request Authorization header.
24
 * Jackson 3.x (tools.jackson namespace) version.
25
 */
26
@API(status = EXPERIMENTAL)
27
@Slf4j
×
28
@EqualsAndHashCode
29
public final class JwtAllMatchingClaimsExtractor implements AttributeExtractor {
30

31
    // RFC 7519 section-4.1.2: The "sub" (subject) claim identifies the principal that is the subject of the JWT.
32
    private static final String DEFAULT_SUBJECT_CLAIM = "sub";
33

34
    private final List<String> claimNames;
35
    private final JwtClaimsExtractor jwtClaimsExtractor;
36

37
    public JwtAllMatchingClaimsExtractor(
38
            final JsonMapper jsonMapper,
39
            final List<String> claimNames
40
    ) {
×
41
        this.claimNames = claimNames;
×
42
        jwtClaimsExtractor = new JwtClaimsExtractor(jsonMapper, new ArrayList<>(claimNames));
×
43
    }
×
44

45
    @API(status = EXPERIMENTAL)
46
    public static final class Builder {
47

48
    }
49

50
    @SuppressWarnings("unused")
51
    @lombok.Builder(builderClassName = "Builder")
52
    @Nonnull
53
    private static JwtAllMatchingClaimsExtractor create(
54
            @Nullable final JsonMapper jsonMapper,
55
            @Nullable final List<String> claimNames
56
    ) {
57
        return new JwtAllMatchingClaimsExtractor(
×
58
                Optional.ofNullable(jsonMapper).orElse(new JsonMapper()),
×
59
                Optional.ofNullable(claimNames).orElse(Collections.singletonList(DEFAULT_SUBJECT_CLAIM))
×
60
        );
61
    }
62

63
    @Nonnull
64
    @Override
65
    public HttpAttributes extract(final HttpRequest request) {
66
        try {
67
            final Map<String, Object> attributeMap = jwtClaimsExtractor.extractClaims(request).entrySet().stream()
×
68
                    .filter(entry -> claimNames.contains(entry.getKey()))
×
69
                    .collect(toMap(Map.Entry::getKey, entry -> jwtClaimsExtractor.toStringValue(entry.getValue())));
×
70

71
            return new HttpAttributes(attributeMap);
×
72
        } catch (Exception e) {
×
73
            log.trace(
×
74
                    "Encountered error while extracting attributes: `{}`",
75
                    (Optional.ofNullable(e.getCause()).orElse(e)).getMessage()
×
76
            );
77
            return HttpAttributes.EMPTY;
×
78
        }
79
    }
80

81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc