Skip to content

Commit

Permalink
Rename Enum classes
Browse files Browse the repository at this point in the history
  • Loading branch information
n0900 committed Nov 12, 2024
1 parent 2e4557c commit 0b1d2ea
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ data class CredentialRequestParameters(
* specific parameters such as those defined in Appendix A MUST NOT be present
*/
@SerialName("credential_identifier")
// TODO Update
val credentialIdentifier: String? = null,

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import at.asitplus.openid.AuthorizationDetails
import at.asitplus.rqes.collection_entries.DocumentLocation
import at.asitplus.rqes.collection_entries.OAuthDocumentDigest
import at.asitplus.rqes.enums.SignatureQualifierEnum
import at.asitplus.rqes.enums.SignatureQualifier
import at.asitplus.signum.indispensable.asn1.ObjectIdSerializer
import at.asitplus.signum.indispensable.asn1.ObjectIdentifier
import kotlinx.serialization.SerialName
Expand All @@ -25,7 +25,7 @@ data class CscAuthorizationDetails(
* signature to be created
*/
@SerialName("signatureQualifier")
val signatureQualifier: SignatureQualifierEnum? = null,
val signatureQualifier: SignatureQualifier? = null,

/**
* CSC: An array composed of entries for every document to be signed. This applies for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import at.asitplus.KmmResult.Companion.wrap
import at.asitplus.rqes.Hashes
import at.asitplus.rqes.contentEquals
import at.asitplus.rqes.contentHashCode
import at.asitplus.rqes.enums.SignatureQualifierEnum
import at.asitplus.rqes.enums.SignatureQualifier
import at.asitplus.rqes.serializers.HashesSerializer
import at.asitplus.signum.indispensable.asn1.ObjectIdentifier
import at.asitplus.signum.indispensable.io.ByteArrayBase64UrlSerializer
Expand Down Expand Up @@ -122,7 +122,7 @@ data class CscAuthenticationRequestParameters(
* signature to be created
*/
@SerialName("signatureQualifier")
val signatureQualifier: SignatureQualifierEnum? = null,
val signatureQualifier: SignatureQualifier? = null,

/**
* CSC: Required-"credential"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package at.asitplus.rqes

import at.asitplus.rqes.collection_entries.CscDocumentDigest
import at.asitplus.rqes.enums.OperationModeEnum
import at.asitplus.rqes.enums.SignatureQualifierEnum
import at.asitplus.rqes.enums.OperationMode
import at.asitplus.rqes.enums.SignatureQualifier
import at.asitplus.rqes.serializers.CscSignatureRequestParameterSerializer
import at.asitplus.signum.indispensable.Digest
import at.asitplus.signum.indispensable.SignatureAlgorithm
Expand Down Expand Up @@ -34,7 +34,7 @@ sealed interface CscSignatureRequestParameters {
* The default value is “S”, so if the parameter is omitted then the remote signing
* server will manage the request in synchronous operation mode.
*/
val operationMode: OperationModeEnum?
val operationMode: OperationMode?

/**
* Maximum period of time, expressed in milliseconds, until which the server
Expand Down Expand Up @@ -68,7 +68,7 @@ data class SignHashParameters(
override val sad: String? = null,

@SerialName("operationMode")
override val operationMode: OperationModeEnum = OperationModeEnum.SYNCHRONOUS,
override val operationMode: OperationMode = OperationMode.SYNCHRONOUS,

@SerialName("validity_period")
override val validityPeriod: Int? = null,
Expand Down Expand Up @@ -164,7 +164,7 @@ data class SignDocParameters(
override val sad: String? = null,

@SerialName("operationMode")
override val operationMode: OperationModeEnum = OperationModeEnum.SYNCHRONOUS,
override val operationMode: OperationMode = OperationMode.SYNCHRONOUS,

@SerialName("validity_period")
override val validityPeriod: Int? = null,
Expand All @@ -180,7 +180,7 @@ data class SignDocParameters(
* a Qualified Electronic Signature according to eIDAS
*/
@SerialName("signatureQualifier")
val signatureQualifier: SignatureQualifierEnum? = null,
val signatureQualifier: SignatureQualifier? = null,

@SerialName("documentDigests")
val documentDigests: Collection<CscDocumentDigest>? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal fun getSignAlgorithm(signAlgoOid: ObjectIdentifier, signAlgoParams: Asn
}

@Throws(Exception::class)
fun getHashAlgorithm(hashAlgorithmOid: ObjectIdentifier?, signatureAlgorithm: SignatureAlgorithm? = null) =
internal fun getHashAlgorithm(hashAlgorithmOid: ObjectIdentifier?, signatureAlgorithm: SignatureAlgorithm? = null) =
hashAlgorithmOid?.let {
Digest.entries.find { digest -> digest.oid == it }
} ?: when(signatureAlgorithm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import at.asitplus.openid.RequestParameters
import at.asitplus.rqes.collection_entries.CscDocumentDigest
import at.asitplus.rqes.collection_entries.DocumentLocation
import at.asitplus.rqes.collection_entries.OAuthDocumentDigest
import at.asitplus.rqes.enums.ConformanceLevelEnum
import at.asitplus.rqes.enums.ConformanceLevel
import at.asitplus.rqes.enums.SignatureFormat
import at.asitplus.rqes.enums.SignatureQualifierEnum
import at.asitplus.rqes.enums.SignatureQualifier
import at.asitplus.rqes.enums.SignedEnvelopeProperty
import at.asitplus.signum.indispensable.Digest
import at.asitplus.signum.indispensable.X509SignatureAlgorithm
Expand Down Expand Up @@ -104,7 +104,7 @@ data class SignatureRequestParameters(
* signature to be created
*/
@SerialName("signatureQualifier")
val signatureQualifier: SignatureQualifierEnum = SignatureQualifierEnum.EU_EIDAS_QES,
val signatureQualifier: SignatureQualifier = SignatureQualifier.EU_EIDAS_QES,

/**
* UC5 Draft REQUIRED.
Expand Down Expand Up @@ -158,14 +158,14 @@ data class SignatureRequestParameters(
signAlgorithm: X509SignatureAlgorithm,
signAlgoParam: Asn1Element? = null,
signedProps: List<JsonObject>? = null,
conformanceLevelEnum: ConformanceLevelEnum? = ConformanceLevelEnum.ADESBB,
conformanceLevel: ConformanceLevel? = ConformanceLevel.ADESBB,
signedEnvelopeProperty: SignedEnvelopeProperty? = SignedEnvelopeProperty.defaultProperty(signatureFormat),
): CscDocumentDigest =
CscDocumentDigest(
hashes = this.documentDigests.map { it.hash },
hashAlgorithmOid = this.hashAlgorithmOid,
signatureFormat = signatureFormat,
conformanceLevel = conformanceLevelEnum,
conformanceLevel = conformanceLevel,
signAlgoOid = signAlgorithm.oid,
signAlgoParams = signAlgoParam,
signedProps = signedProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package at.asitplus.rqes.collection_entries
import at.asitplus.rqes.Hashes
import at.asitplus.rqes.contentEquals
import at.asitplus.rqes.contentHashCode
import at.asitplus.rqes.enums.ConformanceLevelEnum
import at.asitplus.rqes.enums.ConformanceLevel
import at.asitplus.rqes.enums.SignatureFormat
import at.asitplus.rqes.enums.SignedEnvelopeProperty
import at.asitplus.rqes.getHashAlgorithm
Expand Down Expand Up @@ -52,7 +52,7 @@ data class CscDocumentDigest(
* Requested conformance level. If omitted its value is "AdES-B-B"
*/
@SerialName("conformance_level")
val conformanceLevel: ConformanceLevelEnum? = null,
val conformanceLevel: ConformanceLevel? = null,

/**
* The OID of the algorithm to use for signing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package at.asitplus.rqes.collection_entries

import at.asitplus.rqes.enums.ConformanceLevelEnum
import at.asitplus.rqes.enums.ConformanceLevel
import at.asitplus.rqes.enums.SignatureFormat
import at.asitplus.rqes.enums.SignedEnvelopeProperty
import at.asitplus.rqes.getSignAlgorithm
Expand Down Expand Up @@ -36,7 +36,7 @@ data class Document(
* Requested conformance level. If omitted its value is "Ades-B-B"
*/
@SerialName("conformance_level")
val conformanceLevel: ConformanceLevelEnum? = null,
val conformanceLevel: ConformanceLevel? = null,

/**
* The OID of the algorithm to use for signing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package at.asitplus.rqes.collection_entries

import at.asitplus.KmmResult
import at.asitplus.KmmResult.Companion.wrap
import at.asitplus.rqes.enums.SignatureQualifierEnum
import at.asitplus.rqes.enums.SignatureQualifier
import at.asitplus.signum.indispensable.asn1.ObjectIdSerializer
import at.asitplus.signum.indispensable.asn1.ObjectIdentifier
import at.asitplus.signum.indispensable.io.ByteArrayBase64Serializer
Expand Down Expand Up @@ -31,7 +31,7 @@ sealed class TransactionData {
* to denote a Qualified Electronic Signature according to eIDAS.
*/
@SerialName("signatureQualifier")
val signatureQualifier: SignatureQualifierEnum? = null,
val signatureQualifier: SignatureQualifier? = null,

/**
* CSC: OPTIONAL.
Expand Down Expand Up @@ -78,7 +78,7 @@ sealed class TransactionData {
* Safe way to construct the object as init throws
*/
fun create(
signatureQualifier: SignatureQualifierEnum?,
signatureQualifier: SignatureQualifier?,
credentialId: String?,
documentDigest: List<RqesDocumentDigestEntry>,
processID: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlinx.serialization.Serializable
*/
@Suppress("unused")
@Serializable
enum class ConformanceLevelEnum {
enum class ConformanceLevel {

/**
* “AdES-B” SHALL be used to request the creation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlinx.serialization.Serializable
*/
@Suppress("unused")
@Serializable
enum class OperationModeEnum {
enum class OperationMode {
/**
* “A”: an asynchronous operation mode is requested.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable

@Suppress("unused")
@Serializable
enum class SignatureQualifierEnum {
enum class SignatureQualifier {

@SerialName("eu_eidas_qes")
EU_EIDAS_QES,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import at.asitplus.rqes.SignDocParameters
import at.asitplus.rqes.SignHashParameters
import at.asitplus.rqes.collection_entries.CscDocumentDigest
import at.asitplus.rqes.collection_entries.Document
import at.asitplus.rqes.enums.ConformanceLevelEnum
import at.asitplus.rqes.enums.ConformanceLevel
import at.asitplus.rqes.enums.SignatureFormat
import at.asitplus.rqes.enums.SignedEnvelopeProperty
import at.asitplus.rqes.rdcJsonSerializer
Expand Down Expand Up @@ -158,7 +158,7 @@ class AuthenticationRequestParameterFromSerializerTest : FreeSpec({
Document(
document = "1234".decodeToByteArray(Base64Strict),
signatureFormat = SignatureFormat.JADES,
conformanceLevel = ConformanceLevelEnum.ADESBLTA,
conformanceLevel = ConformanceLevel.ADESBLTA,
signAlgoOid = X509SignatureAlgorithm.ES256.oid,
signAlgoParams = null,
signedProps = null,
Expand All @@ -167,7 +167,7 @@ class AuthenticationRequestParameterFromSerializerTest : FreeSpec({
Document(
document = "1234".decodeToByteArray(Base64Strict),
signatureFormat = SignatureFormat.CADES,
conformanceLevel = ConformanceLevelEnum.ADEST,
conformanceLevel = ConformanceLevel.ADEST,
signAlgoOid = X509SignatureAlgorithm.RS256.oid,
signAlgoParams = null,
signedProps = null,
Expand All @@ -182,7 +182,7 @@ class AuthenticationRequestParameterFromSerializerTest : FreeSpec({
hashes = listOf("1234".decodeToByteArray(Base64Strict)),
hashAlgorithmOid = Digest.SHA256.oid,
signatureFormat = SignatureFormat.XADES,
conformanceLevel = ConformanceLevelEnum.ADESB,
conformanceLevel = ConformanceLevel.ADESB,
signAlgoOid = X509SignatureAlgorithm.ES384.oid,
signAlgoParams = null,
signedProps = null,
Expand All @@ -192,7 +192,7 @@ class AuthenticationRequestParameterFromSerializerTest : FreeSpec({
hashes = listOf("1234".decodeToByteArray(Base64Strict)),
hashAlgorithmOid = null,
signatureFormat = SignatureFormat.PADES,
conformanceLevel = ConformanceLevelEnum.ADESTLT,
conformanceLevel = ConformanceLevel.ADESTLT,
signAlgoOid = X509SignatureAlgorithm.RS512.oid,
signAlgoParams = null,
signedProps = null,
Expand Down

0 comments on commit 0b1d2ea

Please sign in to comment.