Skip to content

Commit b6736d2

Browse files
committed
refactor(challenge): change ChallengeNonceStore type from abstract class to interface
WE2-608 Signed-off-by: Mart Somermaa <[email protected]>
1 parent 2cbf9fd commit b6736d2

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/main/java/eu/webeid/security/challenge/ChallengeNonceStore.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@
3131
/**
3232
* A store for storing generated challenge nonces and accessing their generation time.
3333
*/
34-
public abstract class ChallengeNonceStore {
34+
public interface ChallengeNonceStore {
3535

36-
public abstract void put(ChallengeNonce challengeNonce);
36+
void put(ChallengeNonce challengeNonce);
3737

38-
public final ChallengeNonce getAndRemove() throws AuthTokenException {
38+
ChallengeNonce getAndRemoveImpl();
39+
40+
default ChallengeNonce getAndRemove() throws AuthTokenException {
3941
final ChallengeNonce challengeNonce = getAndRemoveImpl();
4042
if (challengeNonce == null) {
4143
throw new ChallengeNonceNotFoundException();
@@ -46,6 +48,4 @@ public final ChallengeNonce getAndRemove() throws AuthTokenException {
4648
return challengeNonce;
4749
}
4850

49-
protected abstract ChallengeNonce getAndRemoveImpl();
50-
5151
}

src/main/java/eu/webeid/security/exceptions/AuthTokenSignatureValidationException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public class AuthTokenSignatureValidationException extends AuthTokenException {
2929

3030
public AuthTokenSignatureValidationException() {
31-
super("Token signature validation has failed");
31+
super("Token signature validation has failed. Check that the origin and nonce are correct.");
3232
}
3333

3434
}

src/test/java/eu/webeid/security/challenge/InMemoryChallengeNonceStore.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222

2323
package eu.webeid.security.challenge;
2424

25-
public class InMemoryChallengeNonceStore extends ChallengeNonceStore {
25+
public class InMemoryChallengeNonceStore implements ChallengeNonceStore {
2626

2727
private ChallengeNonce challengeNonce;
2828

2929
@Override
30-
protected ChallengeNonce getAndRemoveImpl() {
31-
final ChallengeNonce result = challengeNonce;
32-
challengeNonce = null;
33-
return result;
30+
public void put(ChallengeNonce challengeNonce) {
31+
this.challengeNonce = challengeNonce;
3432
}
3533

3634
@Override
37-
public void put(ChallengeNonce challengeNonce) {
38-
this.challengeNonce = challengeNonce;
35+
public ChallengeNonce getAndRemoveImpl() {
36+
final ChallengeNonce result = challengeNonce;
37+
challengeNonce = null;
38+
return result;
3939
}
4040

4141
}

0 commit comments

Comments
 (0)