-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flytter kode for prosesseringssteg til fellesmodul
- Loading branch information
Showing
15 changed files
with
124 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...lin/no/nav/emottak/util/SertifikatUtil.kt → ...lin/no/nav/emottak/util/SertifikatUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
package no.nav.emottak.util | ||
|
||
import io.ktor.server.plugins.BadRequestException | ||
import java.io.ByteArrayInputStream | ||
import java.security.cert.CertificateException | ||
import java.security.cert.CertificateFactory | ||
import java.security.cert.X509Certificate | ||
|
||
internal fun isSelfSigned(certificate: X509Certificate) = | ||
fun isSelfSigned(certificate: X509Certificate) = | ||
certificate.subjectX500Principal == certificate.issuerX500Principal | ||
|
||
internal fun createX509Certificate(byteArray: ByteArray): X509Certificate { | ||
fun createX509Certificate(byteArray: ByteArray): X509Certificate { | ||
val cf = CertificateFactory.getInstance("X.509") | ||
return try { | ||
cf.generateCertificate(ByteArrayInputStream(byteArray)) as X509Certificate | ||
} | ||
catch (e: CertificateException) { | ||
throw BadRequestException("") | ||
throw RuntimeException("Kunne ikke opprette X509Certificate fra ByteArray", e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
felles/src/main/kotlin/no/nav/emottak/util/crypto/EncryptionException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package no.nav.emottak.util.crypto | ||
|
||
class EncryptionException(override val message: String, e: Exception? = null) : Exception(message, e) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
felles/src/main/kotlin/no/nav/emottak/util/signatur/SignatureException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package no.nav.emottak.util.signatur | ||
|
||
class SignatureException(override val message: String, e: Exception? = null) : Exception(message, e) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.