Skip to content

Commit

Permalink
refactor/added log for checkConsumerIsActiveAndMatched method
Browse files Browse the repository at this point in the history
  • Loading branch information
hongwei1 committed Jul 15, 2024
1 parent 1be6242 commit edf7632
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion obp-api/src/main/scala/code/api/util/ConsentUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ object Consent extends MdcLoggable {
}

private def checkConsumerIsActiveAndMatched(consent: ConsentJWT, callContext: CallContext): Box[Boolean] = {
Consumers.consumers.vend.getConsumerByConsumerId(consent.aud) match {
val consumerBox = Consumers.consumers.vend.getConsumerByConsumerId(consent.aud)
logger.debug(s"code.api.util.Consent.checkConsumerIsActiveAndMatched.getConsumerByConsumerId consumerBox:: consumerBox($consumerBox)")
consumerBox match {
case Full(consumerFromConsent) if consumerFromConsent.isActive.get == true => // Consumer is active
val validationMetod = APIUtil.getPropsValue(nameOfProperty = "consumer_validation_method_for_consent", defaultValue = "CONSUMER_CERTIFICATE")
if(validationMetod != "CONSUMER_CERTIFICATE" && Props.mode == Props.RunModes.Production) {
Expand All @@ -153,6 +155,7 @@ object Consent extends MdcLoggable {
validationMetod match {
case "CONSUMER_KEY_VALUE" =>
val requestHeaderConsumerKey = getConsumerKey(callContext.requestHeaders)
logger.debug(s"code.api.util.Consent.checkConsumerIsActiveAndMatched.consumerBox.requestHeaderConsumerKey:: requestHeaderConsumerKey($requestHeaderConsumerKey)")
requestHeaderConsumerKey match {
case Some(reqHeaderConsumerKey) =>
if (reqHeaderConsumerKey == consumerFromConsent.key.get)
Expand All @@ -163,6 +166,7 @@ object Consent extends MdcLoggable {
}
case "CONSUMER_CERTIFICATE" =>
val clientCert: String = APIUtil.`getPSD2-CERT`(callContext.requestHeaders).getOrElse(SecureRandomUtil.csprng.nextLong().toString)
logger.debug(s"code.api.util.Consent.checkConsumerIsActiveAndMatched.consumerBox clientCert:: clientCert($clientCert)")
def removeBreakLines(input: String) = input
.replace("\n", "")
.replace("\r", "")
Expand Down

0 comments on commit edf7632

Please sign in to comment.