diff --git a/components/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/entity/FirmwarePacket.kt b/components/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/entity/FirmwarePacket.kt index 09dc8e08..850d21e4 100644 --- a/components/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/entity/FirmwarePacket.kt +++ b/components/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/entity/FirmwarePacket.kt @@ -10,8 +10,4 @@ import jakarta.persistence.ManyToOne @Entity @IdClass(FirmwarePacketCompositeKey::class) -class FirmwarePacket( - @ManyToOne @Id val firmware: Firmware, - @Id val packetNumber: Int, - val packet: String -) +class FirmwarePacket(@ManyToOne @Id val firmware: Firmware, @Id val packetNumber: Int, val packet: String) diff --git a/components/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/repository/FirmwarePacketRepository.kt b/components/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/repository/FirmwarePacketRepository.kt index 53382f11..76ccb6de 100644 --- a/components/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/repository/FirmwarePacketRepository.kt +++ b/components/firmware/src/main/kotlin/org/gxf/crestdeviceservice/firmware/repository/FirmwarePacketRepository.kt @@ -8,5 +8,4 @@ import org.gxf.crestdeviceservice.firmware.entity.FirmwarePacketCompositeKey import org.springframework.data.repository.CrudRepository import org.springframework.stereotype.Repository -@Repository -interface FirmwarePacketRepository : CrudRepository +@Repository interface FirmwarePacketRepository : CrudRepository diff --git a/components/psk/src/main/kotlin/org/gxf/crestdeviceservice/psk/service/PskService.kt b/components/psk/src/main/kotlin/org/gxf/crestdeviceservice/psk/service/PskService.kt index eb3e6e81..6406c1e7 100644 --- a/components/psk/src/main/kotlin/org/gxf/crestdeviceservice/psk/service/PskService.kt +++ b/components/psk/src/main/kotlin/org/gxf/crestdeviceservice/psk/service/PskService.kt @@ -75,10 +75,12 @@ class PskService(private val pskRepository: PskRepository, private val pskConfig PreSharedKey(deviceId, newVersion, Instant.now(), newKey, previousPSK.secret, PreSharedKeyStatus.READY)) } - private fun generatePsk(): String = - secureRandom.ints(KEY_LENGTH, 0, ALLOWED_CHARACTERS.length).toArray().fold("") { acc, next -> - acc + ALLOWED_CHARACTERS[next] - } + private fun generatePsk() = + secureRandom + .ints(KEY_LENGTH, 0, ALLOWED_CHARACTERS.length) + .toArray() + .map { ALLOWED_CHARACTERS[it] } + .joinToString("") fun setPskToPendingForDevice(deviceId: String): PreSharedKey { val psk = getCurrentReadyPsk(deviceId) ?: throw NoExistingPskException("There is no new key ready to be set")