Skip to content

Commit

Permalink
refactor: Port remaining code to kotlin.io.encoding.Base64
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Aug 24, 2024
1 parent fe0a41c commit c309ada
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions plugins/package-managers/bazel/src/main/kotlin/Bazel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ package org.ossreviewtoolkit.plugins.packagemanagers.bazel

import java.io.File
import java.net.URI
import java.util.Base64

import kotlin.io.encoding.Base64

import org.apache.logging.log4j.kotlin.logger

Expand Down Expand Up @@ -306,7 +307,7 @@ class Bazel(

val hash = archiveOverride.integrity?.let { integrity ->
val (algo, b64digest) = integrity.split('-', limit = 2)
val digest = Base64.getDecoder().decode(b64digest).toHexString()
val digest = Base64.decode(b64digest).toHexString()
Hash(
value = digest,
algorithm = HashAlgorithm.fromString(algo)
Expand Down Expand Up @@ -420,7 +421,7 @@ private fun ModuleMetadata.toVcsInfo() =

private fun ModuleSourceInfo.toRemoteArtifact(): RemoteArtifact {
val (algo, b64digest) = integrity.split("-", limit = 2)
val digest = Base64.getDecoder().decode(b64digest).toHexString()
val digest = Base64.decode(b64digest).toHexString()

val hash = Hash(
value = digest,
Expand Down
6 changes: 4 additions & 2 deletions plugins/reporters/web-app/src/main/kotlin/WebAppReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ package org.ossreviewtoolkit.plugins.reporters.webapp

import java.io.File
import java.io.FileOutputStream
import java.util.Base64
import java.util.zip.Deflater

import kotlin.io.encoding.Base64
import kotlin.io.encoding.encodingWith

import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream
import org.apache.commons.compress.compressors.gzip.GzipParameters

Expand Down Expand Up @@ -71,7 +73,7 @@ class WebAppReporter : Reporter {
outputFile.writeText(prefix)

FileOutputStream(outputFile, /* append = */ true).use { outputStream ->
val b64OutputStream = Base64.getEncoder().wrap(outputStream)
val b64OutputStream = outputStream.encodingWith(Base64.Mime)

val gzipParameters = GzipParameters().apply {
compressionLevel = Deflater.BEST_COMPRESSION
Expand Down

0 comments on commit c309ada

Please sign in to comment.