Skip to content

Commit b7988b4

Browse files
Add Repository Bearer Authentication
Signed-off-by: Valentijn Scholten <[email protected]>
1 parent 0634c82 commit b7988b4

File tree

2 files changed

+0
-8
lines changed

2 files changed

+0
-8
lines changed

src/main/java/org/dependencytrack/resources/v1/RepositoryResource.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ public Response createRepository(Repository jsonRepository) {
226226
})
227227
@PermissionRequired(Permissions.Constants.SYSTEM_CONFIGURATION)
228228
public Response updateRepository(Repository jsonRepository) {
229-
System.out.println("repo update");
230229
final Validator validator = super.getValidator();
231230
failOnValidationError(validator.validateProperty(jsonRepository, "identifier"),
232231
validator.validateProperty(jsonRepository, "url")
@@ -235,30 +234,24 @@ public Response updateRepository(Repository jsonRepository) {
235234
try (QueryManager qm = new QueryManager()) {
236235
Repository repository = qm.getObjectByUuid(Repository.class, jsonRepository.getUuid());
237236
if (repository != null) {
238-
System.out.println("repo update inner");
239237
final String url = StringUtils.trimToNull(jsonRepository.getUrl());
240238
String msg = "password";
241239
try {
242-
System.out.println("repo password decrypt");
243240
// The password is not passed to the front-end, so it should only be overwritten if it is not null or not set to default value coming from ui
244241
final String updatedPassword = jsonRepository.getPassword()!=null && !jsonRepository.getPassword().equals(ENCRYPTED_PLACEHOLDER)
245242
? DataEncryption.encryptAsString(jsonRepository.getPassword())
246243
: repository.getPassword();
247244

248245
// The bearerToken is not passed to the front-end, so it should only be overwritten if it is not null or not set to default value coming from ui
249-
System.out.println("repo bearer decrypt");
250246
msg = "bearerToken";
251247
final String updatedBearerToken = jsonRepository.getBearerToken()!=null && !jsonRepository.getBearerToken().equals(ENCRYPTED_PLACEHOLDER)
252248
? DataEncryption.encryptAsString(jsonRepository.getBearerToken())
253249
: repository.getBearerToken();
254250

255-
System.out.println("repo update real");
256251
repository = qm.updateRepository(jsonRepository.getUuid(), repository.getIdentifier(), url,
257252
jsonRepository.isInternal(), jsonRepository.isAuthenticationRequired(), jsonRepository.getUsername(), updatedPassword, updatedBearerToken, jsonRepository.isEnabled());
258-
System.out.println("repo update done");
259253
return Response.ok(repository).build();
260254
} catch (Exception e) {
261-
e.printStackTrace(System.out);
262255
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("The specified repository %s could not be encrypted.".formatted(msg)).build();
263256
}
264257
} else {

src/test/java/org/dependencytrack/resources/v1/RepositoryResourceTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ public void updateRepositoryTest() throws Exception {
289289
repository1.setAuthenticationRequired(false);
290290
response = jersey.target(V1_REPOSITORY).request().header(X_API_KEY, apiKey)
291291
.post(Entity.entity(repository1, MediaType.APPLICATION_JSON));
292-
System.out.println(response.readEntity(String.class));
293292
Assert.assertEquals(200, response.getStatus());
294293
break;
295294
}

0 commit comments

Comments
 (0)