Skip to content

Commit

Permalink
#54 Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
vityaman committed Nov 12, 2024
1 parent fc777d3 commit d101d6a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion backend/foundation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("buildlogic.spring-conventions")
id("buildlogic.kotlin-library-conventions")
id("buildlogic.jooq-conventions")
kotlin("plugin.spring")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import ru.ifmo.se.dating.exception.AuthenticationException
import java.security.PublicKey
import java.time.Clock
import java.util.*
import javax.crypto.SecretKey

class JwtTokenDecoder(
private val clock: Clock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ object Keys {

private fun split(string: String): Pair<String, ByteArray> {
val parts = string.split(":")
if (parts.size != 2) {
throw IllegalArgumentException("Invalid serialized key format")
}
require(parts.size == 2)
val algorithm = parts[0]
val encodedKey = parts[1]
return algorithm to Base64.getDecoder().decode(encodedKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ import javax.crypto.KeyGenerator
class KeysTest {
@Test
fun secretRoundTrip() {
for (i in 0..32) {
repeat(32) {
val key = KeyGenerator.getInstance("AES").generateKey()
assertEquals(key, Keys.serialize(key).let { Keys.deserializeSecret(it) })
}
}

@Test
fun publicRoundTrip() {
for (i in 0..8) {
repeat(8) {
val pair = KeyPairGenerator.getInstance("RSA").genKeyPair()
assertEquals(pair.public, Keys.serialize(pair.public).let { Keys.deserializePublic(it) })
assertEquals(pair.private, Keys.serialize(pair.private).let { Keys.deserializePrivate(it) })
val (public, private) = pair.public to pair.private
assertEquals(public, Keys.deserializePublic(Keys.serialize(public)))
assertEquals(private, Keys.deserializePrivate(Keys.serialize(private)))
}
}

Expand Down

0 comments on commit d101d6a

Please sign in to comment.