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

stripe / stripe-java / #16493

03 Oct 2024 07:15PM UTC coverage: 12.942% (+0.08%) from 12.864%
#16493

push

github

web-flow
Merge Stripe-java v27.0.0 to beta branch (#1888)

409 of 1651 new or added lines in 88 files covered. (24.77%)

31 existing lines in 7 files now uncovered.

18773 of 145050 relevant lines covered (12.94%)

0.13 hits per line

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

92.31
/src/main/java/com/stripe/net/BearerTokenAuthenticator.java
1
package com.stripe.net;
2

3
import com.stripe.exception.AuthenticationException;
4
import com.stripe.exception.StripeException;
5
import com.stripe.util.StringUtils;
6
import lombok.EqualsAndHashCode;
7

8
@EqualsAndHashCode
9
public final class BearerTokenAuthenticator implements Authenticator {
10
  private final String apiKey;
11

12
  public BearerTokenAuthenticator(String apiKey) {
1✔
13
    if (apiKey == null) {
1✔
NEW
14
      throw new IllegalArgumentException("apiKey should be not-null");
×
15
    }
16
    this.apiKey = apiKey;
1✔
17
  }
1✔
18

19
  public String getApiKey() {
20
    return this.apiKey;
1✔
21
  }
22

23
  @Override
24
  public StripeRequest authenticate(StripeRequest request) throws StripeException {
25
    if (apiKey.isEmpty()) {
1✔
26
      throw new AuthenticationException(
1✔
27
          "Your API key is invalid, as it is an empty string. You can double-check your API key "
28
              + "from the Stripe Dashboard. See "
29
              + "https://stripe.com/docs/api/authentication for details or contact support at "
30
              + "https://support.stripe.com/email if you have any questions.",
31
          null,
32
          null,
33
          0);
1✔
34
    } else if (StringUtils.containsWhitespace(apiKey)) {
1✔
35
      throw new AuthenticationException(
1✔
36
          "Your API key is invalid, as it contains whitespace. You can double-check your API key "
37
              + "from the Stripe Dashboard. See "
38
              + "https://stripe.com/docs/api/authentication for details or contact support at "
39
              + "https://support.stripe.com/email if you have any questions.",
40
          null,
41
          null,
42
          0);
1✔
43
    }
44
    return request.withAdditionalHeader("Authorization", String.format("Bearer %s", apiKey));
1✔
45
  }
46
}
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