Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/java/com/iexec/core/security/ChallengeService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 IEXEC BLOCKCHAIN TECH
* Copyright 2020-2026 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,19 +31,19 @@ public class ChallengeService {
.expiration(5, TimeUnit.MINUTES)
.expirationPolicy(ExpirationPolicy.CREATED)
.build();
private final SecureRandom secureRandom = new SecureRandom();

public String computeChallenge() {
SecureRandom secureRandom = new SecureRandom();
byte[] seed = new byte[32];
private String computeChallenge() {
final byte[] seed = new byte[32];
secureRandom.nextBytes(seed);
return Base64.getEncoder().encodeToString(seed);
}

public String getChallenge(String workerWallet) {
public String getChallenge(final String workerWallet) {
return challengesMap.computeIfAbsent(workerWallet, wallet -> computeChallenge());
}

public void removeChallenge(String workerWallet, String challenge) {
public void removeChallenge(final String workerWallet, final String challenge) {
challengesMap.remove(workerWallet, challenge);
}

Expand Down
Loading