def compare()

in pan-domain-auth-verification/src/main/scala/com/gu/pandomainauth/service/CryptoConf.scala [98:115]


    def compare(oldConf: Verification, newConf: Verification): Option[CryptoConf.Change] =
      Option.when(newConf != oldConf)(Change(
        activeKey = Option.when(newConf.activePublicKey != oldConf.activePublicKey)(ActiveKey(
          oldConf.activeKeyId,
          newConf.activeKeyId,
          TransitionCriteria.failedCriteriaFor(oldConf, newConf)
        )),
        newConf.alsoAcceptedKeyIds, SeqDiff.compare(oldConf.alsoAcceptedKeyIds, newConf.alsoAcceptedKeyIds)
      ))

    /**
     * CryptoConf.Change.ActiveKey details the consequences of a change to the active key,
     * allowing us to know if the change could disrupt existing user sessions.
     */
    case class ActiveKey(oldId: KeyHashId, newId: KeyHashId, failedTransitionCriteria: Seq[TransitionCriteria]) {
      val isBreakingChange: Boolean = failedTransitionCriteria.nonEmpty
      val summary: String = s"Active key changed from $oldId to $newId${if (isBreakingChange) s" (FAILED transition criteria: ${failedTransitionCriteria.mkString(", ")})" else ""}."
    }