Skip to content

Commit

Permalink
Merge pull request OSGP#51 from OSGP/feature/FDP-2600-lichte-refactoring
Browse files Browse the repository at this point in the history
FDP-2600: small readability improvement
  • Loading branch information
smvdheijden authored Sep 30, 2024
2 parents 21d6479 + f61ba25 commit f413c4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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<FirmwarePacket, FirmwarePacketCompositeKey>
@Repository interface FirmwarePacketRepository : CrudRepository<FirmwarePacket, FirmwarePacketCompositeKey>
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit f413c4d

Please sign in to comment.