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

box / box-java-sdk-gen / #331

10 Jul 2025 05:13PM UTC coverage: 35.58%. First build
#331

Pull #359

github

web-flow
Merge e49be1aba into b7374ec91
Pull Request #359: chore: Update .codegen.json with commit hash of codegen and openapi spec

41 of 91 new or added lines in 11 files covered. (45.05%)

16957 of 47659 relevant lines covered (35.58%)

0.36 hits per line

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

73.42
/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.DefaultPrivateKeyDecryptor;
9
import com.box.sdkgen.internal.utils.JwtAlgorithm;
10
import com.box.sdkgen.internal.utils.PrivateKeyDecryptor;
11
import com.box.sdkgen.serialization.json.EnumWrapper;
12
import com.box.sdkgen.serialization.json.JsonManager;
13

14
public class JWTConfig {
15

16
  public final String clientId;
17

18
  public final String clientSecret;
19

20
  public final String jwtKeyId;
21

22
  public final String privateKey;
23

24
  public final String privateKeyPassphrase;
25

26
  public String enterpriseId;
27

28
  public String userId;
29

30
  public EnumWrapper<JwtAlgorithm> algorithm;
31

32
  public TokenStorage tokenStorage;
33

34
  public PrivateKeyDecryptor privateKeyDecryptor;
35

36
  public JWTConfig(
37
      String clientId,
38
      String clientSecret,
39
      String jwtKeyId,
40
      String privateKey,
41
      String privateKeyPassphrase) {
×
42
    this.clientId = clientId;
×
43
    this.clientSecret = clientSecret;
×
44
    this.jwtKeyId = jwtKeyId;
×
45
    this.privateKey = privateKey;
×
46
    this.privateKeyPassphrase = privateKeyPassphrase;
×
47
    this.algorithm = new EnumWrapper<JwtAlgorithm>(JwtAlgorithm.RS256);
×
48
    this.tokenStorage = new InMemoryTokenStorage();
×
NEW
49
    this.privateKeyDecryptor = new DefaultPrivateKeyDecryptor();
×
50
  }
×
51

52
  protected JWTConfig(Builder builder) {
1✔
53
    this.clientId = builder.clientId;
1✔
54
    this.clientSecret = builder.clientSecret;
1✔
55
    this.jwtKeyId = builder.jwtKeyId;
1✔
56
    this.privateKey = builder.privateKey;
1✔
57
    this.privateKeyPassphrase = builder.privateKeyPassphrase;
1✔
58
    this.enterpriseId = builder.enterpriseId;
1✔
59
    this.userId = builder.userId;
1✔
60
    this.algorithm = builder.algorithm;
1✔
61
    this.tokenStorage = builder.tokenStorage;
1✔
62
    this.privateKeyDecryptor = builder.privateKeyDecryptor;
1✔
63
  }
1✔
64

65
  public static JWTConfig fromConfigJsonString(String configJsonString) {
66
    return fromConfigJsonString(configJsonString, null, null);
1✔
67
  }
68

69
  public static JWTConfig fromConfigJsonString(String configJsonString, TokenStorage tokenStorage) {
NEW
70
    return fromConfigJsonString(configJsonString, tokenStorage, null);
×
71
  }
72

73
  public static JWTConfig fromConfigJsonString(
74
      String configJsonString, PrivateKeyDecryptor privateKeyDecryptor) {
NEW
75
    return fromConfigJsonString(configJsonString, null, privateKeyDecryptor);
×
76
  }
77

78
  public static JWTConfig fromConfigJsonString(
79
      String configJsonString, TokenStorage tokenStorage, PrivateKeyDecryptor privateKeyDecryptor) {
80
    JwtConfigFile configJson =
1✔
81
        JsonManager.deserialize(jsonToSerializedData(configJsonString), JwtConfigFile.class);
1✔
82
    TokenStorage tokenStorageToUse =
1✔
83
        (tokenStorage == null ? new InMemoryTokenStorage() : tokenStorage);
84
    PrivateKeyDecryptor privateKeyDecryptorToUse =
1✔
85
        (privateKeyDecryptor == null ? new DefaultPrivateKeyDecryptor() : privateKeyDecryptor);
86
    JWTConfig newConfig =
1✔
87
        new JWTConfig.Builder(
88
                configJson.getBoxAppSettings().getClientId(),
1✔
89
                configJson.getBoxAppSettings().getClientSecret(),
1✔
90
                configJson.getBoxAppSettings().getAppAuth().getPublicKeyId(),
1✔
91
                configJson.getBoxAppSettings().getAppAuth().getPrivateKey(),
1✔
92
                configJson.getBoxAppSettings().getAppAuth().getPassphrase())
1✔
93
            .enterpriseId(configJson.getEnterpriseId())
1✔
94
            .userId(configJson.getUserId())
1✔
95
            .tokenStorage(tokenStorageToUse)
1✔
96
            .privateKeyDecryptor(privateKeyDecryptorToUse)
1✔
97
            .build();
1✔
98
    return newConfig;
1✔
99
  }
100

101
  public static JWTConfig fromConfigFile(String configFilePath) {
NEW
102
    return fromConfigFile(configFilePath, null, null);
×
103
  }
104

105
  public static JWTConfig fromConfigFile(String configFilePath, TokenStorage tokenStorage) {
NEW
106
    return fromConfigFile(configFilePath, tokenStorage, null);
×
107
  }
108

109
  public static JWTConfig fromConfigFile(
110
      String configFilePath, PrivateKeyDecryptor privateKeyDecryptor) {
NEW
111
    return fromConfigFile(configFilePath, null, privateKeyDecryptor);
×
112
  }
113

114
  public static JWTConfig fromConfigFile(
115
      String configFilePath, TokenStorage tokenStorage, PrivateKeyDecryptor privateKeyDecryptor) {
116
    String configJsonString = readTextFromFile(configFilePath);
×
NEW
117
    return JWTConfig.fromConfigJsonString(configJsonString, tokenStorage, privateKeyDecryptor);
×
118
  }
119

120
  public String getClientId() {
121
    return clientId;
1✔
122
  }
123

124
  public String getClientSecret() {
125
    return clientSecret;
1✔
126
  }
127

128
  public String getJwtKeyId() {
129
    return jwtKeyId;
1✔
130
  }
131

132
  public String getPrivateKey() {
133
    return privateKey;
1✔
134
  }
135

136
  public String getPrivateKeyPassphrase() {
137
    return privateKeyPassphrase;
1✔
138
  }
139

140
  public String getEnterpriseId() {
141
    return enterpriseId;
1✔
142
  }
143

144
  public String getUserId() {
145
    return userId;
1✔
146
  }
147

148
  public EnumWrapper<JwtAlgorithm> getAlgorithm() {
149
    return algorithm;
1✔
150
  }
151

152
  public TokenStorage getTokenStorage() {
153
    return tokenStorage;
1✔
154
  }
155

156
  public PrivateKeyDecryptor getPrivateKeyDecryptor() {
157
    return privateKeyDecryptor;
1✔
158
  }
159

160
  public static class Builder {
161

162
    protected final String clientId;
163

164
    protected final String clientSecret;
165

166
    protected final String jwtKeyId;
167

168
    protected final String privateKey;
169

170
    protected final String privateKeyPassphrase;
171

172
    protected String enterpriseId;
173

174
    protected String userId;
175

176
    protected EnumWrapper<JwtAlgorithm> algorithm;
177

178
    protected TokenStorage tokenStorage;
179

180
    protected PrivateKeyDecryptor privateKeyDecryptor;
181

182
    public Builder(
183
        String clientId,
184
        String clientSecret,
185
        String jwtKeyId,
186
        String privateKey,
187
        String privateKeyPassphrase) {
1✔
188
      this.clientId = clientId;
1✔
189
      this.clientSecret = clientSecret;
1✔
190
      this.jwtKeyId = jwtKeyId;
1✔
191
      this.privateKey = privateKey;
1✔
192
      this.privateKeyPassphrase = privateKeyPassphrase;
1✔
193
      this.algorithm = new EnumWrapper<JwtAlgorithm>(JwtAlgorithm.RS256);
1✔
194
      this.tokenStorage = new InMemoryTokenStorage();
1✔
195
      this.privateKeyDecryptor = new DefaultPrivateKeyDecryptor();
1✔
196
    }
1✔
197

198
    public Builder enterpriseId(String enterpriseId) {
199
      this.enterpriseId = enterpriseId;
1✔
200
      return this;
1✔
201
    }
202

203
    public Builder userId(String userId) {
204
      this.userId = userId;
1✔
205
      return this;
1✔
206
    }
207

208
    public Builder algorithm(JwtAlgorithm algorithm) {
209
      this.algorithm = new EnumWrapper<JwtAlgorithm>(algorithm);
×
210
      return this;
×
211
    }
212

213
    public Builder algorithm(EnumWrapper<JwtAlgorithm> algorithm) {
214
      this.algorithm = algorithm;
×
215
      return this;
×
216
    }
217

218
    public Builder tokenStorage(TokenStorage tokenStorage) {
219
      this.tokenStorage = tokenStorage;
1✔
220
      return this;
1✔
221
    }
222

223
    public Builder privateKeyDecryptor(PrivateKeyDecryptor privateKeyDecryptor) {
224
      this.privateKeyDecryptor = privateKeyDecryptor;
1✔
225
      return this;
1✔
226
    }
227

228
    public JWTConfig build() {
229
      return new JWTConfig(this);
1✔
230
    }
231
  }
232
}
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