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

box / box-java-sdk / #4924

29 Sep 2025 02:13PM UTC coverage: 13.654% (-0.009%) from 13.663%
#4924

push

github

web-flow
chore: Adjust build process (#1444)

8368 of 61284 relevant lines covered (13.65%)

0.14 hits per line

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

0.0
/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();
×
49
    this.privateKeyDecryptor = new DefaultPrivateKeyDecryptor();
×
50
  }
×
51

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

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

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

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

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

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

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

109
  public static JWTConfig fromConfigFile(
110
      String configFilePath, PrivateKeyDecryptor privateKeyDecryptor) {
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);
×
117
    return JWTConfig.fromConfigJsonString(configJsonString, tokenStorage, privateKeyDecryptor);
×
118
  }
119

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

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

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

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

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

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

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

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

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

156
  public PrivateKeyDecryptor getPrivateKeyDecryptor() {
157
    return privateKeyDecryptor;
×
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) {
×
188
      this.clientId = clientId;
×
189
      this.clientSecret = clientSecret;
×
190
      this.jwtKeyId = jwtKeyId;
×
191
      this.privateKey = privateKey;
×
192
      this.privateKeyPassphrase = privateKeyPassphrase;
×
193
      this.algorithm = new EnumWrapper<JwtAlgorithm>(JwtAlgorithm.RS256);
×
194
      this.tokenStorage = new InMemoryTokenStorage();
×
195
      this.privateKeyDecryptor = new DefaultPrivateKeyDecryptor();
×
196
    }
×
197

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

203
    public Builder userId(String userId) {
204
      this.userId = userId;
×
205
      return this;
×
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;
×
220
      return this;
×
221
    }
222

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

228
    public JWTConfig build() {
229
      return new JWTConfig(this);
×
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