| 1 | package org.sanmibuh.tedee.lock.infrastructure.secondary; | |
| 2 | ||
| 3 | import java.nio.charset.StandardCharsets; | |
| 4 | import java.security.MessageDigest; | |
| 5 | import java.util.HexFormat; | |
| 6 | import lombok.RequiredArgsConstructor; | |
| 7 | import lombok.SneakyThrows; | |
| 8 | ||
| 9 | @RequiredArgsConstructor | |
| 10 | final class TedeeApiTokenGenerator { | |
| 11 | ||
| 12 | private static final String HASH_ALGORITHM = "SHA-256"; | |
| 13 | ||
| 14 | private final String token; | |
| 15 | ||
| 16 | String generate(final long timestampMillis) { | |
| 17 |
1
1. generate : replaced return value with "" for org/sanmibuh/tedee/lock/infrastructure/secondary/TedeeApiTokenGenerator::generate → KILLED |
return sha256Hex(token + timestampMillis) + timestampMillis; |
| 18 | } | |
| 19 | ||
| 20 | @SneakyThrows | |
| 21 | private String sha256Hex(final String value) { | |
| 22 | final var digest = | |
| 23 | MessageDigest.getInstance(HASH_ALGORITHM).digest(value.getBytes(StandardCharsets.UTF_8)); | |
| 24 |
1
1. sha256Hex : replaced return value with "" for org/sanmibuh/tedee/lock/infrastructure/secondary/TedeeApiTokenGenerator::sha256Hex → KILLED |
return HexFormat.of().formatHex(digest); |
| 25 | } | |
| 26 | } | |
Mutations | ||
| 17 |
1.1 |
|
| 24 |
1.1 |