All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.chatwork.scala.jwk.KeyUseAndOpsConsistency.scala Maven / Gradle / Ivy

package com.chatwork.scala.jwk

object KeyUseAndOpsConsistency {

  val rules: Map[PublicKeyUseType, Set[KeyOperationType]] = Map(
    PublicKeyUseType.Signature -> Set(
      KeyOperationType.Sign,
      KeyOperationType.Verify
    ),
    PublicKeyUseType.Encryption -> Set(
      KeyOperationType.Encrypt,
      KeyOperationType.Decrypt,
      KeyOperationType.WrapKey,
      KeyOperationType.UnwrapKey
    )
  )

  def areConsistent(use: PublicKeyUseType, ops: KeyOperations): Boolean = {
    ops.breachEncapsulationOfValues.forall { v => rules(use).contains(v) }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy