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

box / box-java-sdk-gen / #197

12 Jun 2025 08:30AM UTC coverage: 35.817% (+0.001%) from 35.816%
#197

push

github

web-flow
test: Remove predefined dates from events integration test (box/box-codegen#740) (#329)

1 of 2 new or added lines in 1 file covered. (50.0%)

9 existing lines in 5 files now uncovered.

16249 of 45367 relevant lines covered (35.82%)

0.36 hits per line

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

66.22
/src/main/java/com/box/sdkgen/box/jwtauth/JWTConfig.java
1
package com.box.sdkgen.box.jwtauth;
2

3
import static com.box.sdkgen.internal.utils.UtilsManager.readTextFromFile;
4
import static com.box.sdkgen.serialization.json.JsonManager.jsonToSerializedData;
5

6
import com.box.sdkgen.box.tokenstorage.InMemoryTokenStorage;
7
import com.box.sdkgen.box.tokenstorage.TokenStorage;
8
import com.box.sdkgen.internal.utils.JwtAlgorithm;
9
import com.box.sdkgen.serialization.json.EnumWrapper;
10
import com.box.sdkgen.serialization.json.JsonManager;
11

12
public class JWTConfig {
13

14
  public final String clientId;
15

16
  public final String clientSecret;
17

18
  public final String jwtKeyId;
19

20
  public final String privateKey;
21

22
  public final String privateKeyPassphrase;
23

24
  public String enterpriseId;
25

26
  public String userId;
27

28
  public EnumWrapper<JwtAlgorithm> algorithm;
29

30
  public TokenStorage tokenStorage;
31

32
  public JWTConfig(
33
      String clientId,
34
      String clientSecret,
35
      String jwtKeyId,
36
      String privateKey,
37
      String privateKeyPassphrase) {
×
38
    this.clientId = clientId;
×
39
    this.clientSecret = clientSecret;
×
40
    this.jwtKeyId = jwtKeyId;
×
41
    this.privateKey = privateKey;
×
42
    this.privateKeyPassphrase = privateKeyPassphrase;
×
43
    this.algorithm = new EnumWrapper<JwtAlgorithm>(JwtAlgorithm.RS256);
×
44
    this.tokenStorage = new InMemoryTokenStorage();
×
45
  }
×
46

47
  protected JWTConfig(JWTConfigBuilder builder) {
1✔
48
    this.clientId = builder.clientId;
1✔
49
    this.clientSecret = builder.clientSecret;
1✔
50
    this.jwtKeyId = builder.jwtKeyId;
1✔
51
    this.privateKey = builder.privateKey;
1✔
52
    this.privateKeyPassphrase = builder.privateKeyPassphrase;
1✔
53
    this.enterpriseId = builder.enterpriseId;
1✔
54
    this.userId = builder.userId;
1✔
55
    this.algorithm = builder.algorithm;
1✔
56
    this.tokenStorage = builder.tokenStorage;
1✔
57
  }
1✔
58

59
  public static JWTConfig fromConfigJsonString(String configJsonString) {
60
    return fromConfigJsonString(configJsonString, null);
1✔
61
  }
62

63
  public static JWTConfig fromConfigJsonString(String configJsonString, TokenStorage tokenStorage) {
64
    JwtConfigFile configJson =
1✔
65
        JsonManager.deserialize(jsonToSerializedData(configJsonString), JwtConfigFile.class);
1✔
66
    JWTConfig newConfig =
67
        (!(tokenStorage == null)
1✔
68
            ? new JWTConfig.JWTConfigBuilder(
69
                    configJson.getBoxAppSettings().getClientId(),
×
70
                    configJson.getBoxAppSettings().getClientSecret(),
×
71
                    configJson.getBoxAppSettings().getAppAuth().getPublicKeyId(),
×
72
                    configJson.getBoxAppSettings().getAppAuth().getPrivateKey(),
×
73
                    configJson.getBoxAppSettings().getAppAuth().getPassphrase())
×
74
                .enterpriseId(configJson.getEnterpriseId())
×
75
                .userId(configJson.getUserId())
×
76
                .tokenStorage(tokenStorage)
×
UNCOV
77
                .build()
×
78
            : new JWTConfig.JWTConfigBuilder(
79
                    configJson.getBoxAppSettings().getClientId(),
1✔
80
                    configJson.getBoxAppSettings().getClientSecret(),
1✔
81
                    configJson.getBoxAppSettings().getAppAuth().getPublicKeyId(),
1✔
82
                    configJson.getBoxAppSettings().getAppAuth().getPrivateKey(),
1✔
83
                    configJson.getBoxAppSettings().getAppAuth().getPassphrase())
1✔
84
                .enterpriseId(configJson.getEnterpriseId())
1✔
85
                .userId(configJson.getUserId())
1✔
86
                .build());
1✔
87
    return newConfig;
1✔
88
  }
89

90
  public static JWTConfig fromConfigFile(String configFilePath) {
91
    return fromConfigFile(configFilePath, null);
×
92
  }
93

94
  public static JWTConfig fromConfigFile(String configFilePath, TokenStorage tokenStorage) {
95
    String configJsonString = readTextFromFile(configFilePath);
×
96
    return JWTConfig.fromConfigJsonString(configJsonString, tokenStorage);
×
97
  }
98

99
  public String getClientId() {
100
    return clientId;
1✔
101
  }
102

103
  public String getClientSecret() {
104
    return clientSecret;
1✔
105
  }
106

107
  public String getJwtKeyId() {
108
    return jwtKeyId;
1✔
109
  }
110

111
  public String getPrivateKey() {
112
    return privateKey;
1✔
113
  }
114

115
  public String getPrivateKeyPassphrase() {
116
    return privateKeyPassphrase;
1✔
117
  }
118

119
  public String getEnterpriseId() {
120
    return enterpriseId;
1✔
121
  }
122

123
  public String getUserId() {
124
    return userId;
1✔
125
  }
126

127
  public EnumWrapper<JwtAlgorithm> getAlgorithm() {
128
    return algorithm;
1✔
129
  }
130

131
  public TokenStorage getTokenStorage() {
132
    return tokenStorage;
1✔
133
  }
134

135
  public static class JWTConfigBuilder {
136

137
    protected final String clientId;
138

139
    protected final String clientSecret;
140

141
    protected final String jwtKeyId;
142

143
    protected final String privateKey;
144

145
    protected final String privateKeyPassphrase;
146

147
    protected String enterpriseId;
148

149
    protected String userId;
150

151
    protected EnumWrapper<JwtAlgorithm> algorithm;
152

153
    protected TokenStorage tokenStorage;
154

155
    public JWTConfigBuilder(
156
        String clientId,
157
        String clientSecret,
158
        String jwtKeyId,
159
        String privateKey,
160
        String privateKeyPassphrase) {
1✔
161
      this.clientId = clientId;
1✔
162
      this.clientSecret = clientSecret;
1✔
163
      this.jwtKeyId = jwtKeyId;
1✔
164
      this.privateKey = privateKey;
1✔
165
      this.privateKeyPassphrase = privateKeyPassphrase;
1✔
166
      this.algorithm = new EnumWrapper<JwtAlgorithm>(JwtAlgorithm.RS256);
1✔
167
      this.tokenStorage = new InMemoryTokenStorage();
1✔
168
    }
1✔
169

170
    public JWTConfigBuilder enterpriseId(String enterpriseId) {
171
      this.enterpriseId = enterpriseId;
1✔
172
      return this;
1✔
173
    }
174

175
    public JWTConfigBuilder userId(String userId) {
176
      this.userId = userId;
1✔
177
      return this;
1✔
178
    }
179

180
    public JWTConfigBuilder algorithm(JwtAlgorithm algorithm) {
181
      this.algorithm = new EnumWrapper<JwtAlgorithm>(algorithm);
×
182
      return this;
×
183
    }
184

185
    public JWTConfigBuilder algorithm(EnumWrapper<JwtAlgorithm> algorithm) {
186
      this.algorithm = algorithm;
×
187
      return this;
×
188
    }
189

190
    public JWTConfigBuilder tokenStorage(TokenStorage tokenStorage) {
191
      this.tokenStorage = tokenStorage;
1✔
192
      return this;
1✔
193
    }
194

195
    public JWTConfig build() {
196
      return new JWTConfig(this);
1✔
197
    }
198
  }
199
}
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