Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ default_auth_context_update_request_key=CUSTOMER_NUMBER

# Check presence of the mandatory headers
#berlin_group_mandatory_headers = Content-Type,Date,Digest,PSU-Device-ID,PSU-Device-Name,PSU-IP-Address,Signature,TPP-Signature-Certificate,X-Request-ID
#berlin_group_mandatory_header_consent = TPP-Redirect-URL
#berlin_group_mandatory_header_consent = TPP-Redirect-URI

## Berlin Group Create Consent Frequency per Day Upper Limit
#berlin_group_frequency_per_day_upper_limit = 4
Expand Down
2 changes: 1 addition & 1 deletion obp-api/src/main/scala/code/api/constant/constant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ object RequestHeader {
final lazy val `If-None-Match` = "If-None-Match"

final lazy val `X-Request-ID` = "X-Request-ID" // Berlin Group
final lazy val `TPP-Redirect-URL` = "TPP-Redirect-URL" // Berlin Group
final lazy val `TPP-Redirect-URI` = "TPP-Redirect-URI" // Berlin Group
final lazy val Date = "Date" // Berlin Group
// Headers to support the signature function of Berlin Group
final lazy val Digest = "Digest" // Berlin Group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object BerlinGroupCheck extends MdcLoggable {
.split(",")
.map(_.trim.toLowerCase)
.toList.filterNot(_.isEmpty)
private val berlinGroupMandatoryHeaderConsent = APIUtil.getPropsValue("berlin_group_mandatory_header_consent", defaultValue = "TPP-Redirect-URL")
private val berlinGroupMandatoryHeaderConsent = APIUtil.getPropsValue("berlin_group_mandatory_header_consent", defaultValue = "TPP-Redirect-URI")
.split(",")
.map(_.trim.toLowerCase)
.toList.filterNot(_.isEmpty)
Expand Down
6 changes: 3 additions & 3 deletions obp-api/src/main/scala/code/api/util/BerlinGroupSigning.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object BerlinGroupSigning extends MdcLoggable {
RequestHeader.Digest,
RequestHeader.Date,
RequestHeader.`X-Request-ID`,
//RequestHeader.`TPP-Redirect-URL`,
//RequestHeader.`TPP-Redirect-URI`,
) // Example fields to be signed
orderedKeys.flatMap(key => headers.get(key).map(value => s"${key.toLowerCase()}: $value")).mkString("\n")
}
Expand Down Expand Up @@ -340,7 +340,7 @@ object BerlinGroupSigning extends MdcLoggable {
RequestHeader.Digest -> s"SHA-256=$digest",
RequestHeader.`X-Request-ID` -> xRequestId,
RequestHeader.Date -> dateHeader,
RequestHeader.`TPP-Redirect-URL` -> redirectUri,
RequestHeader.`TPP-Redirect-URI` -> redirectUri,
)

val signingString = createSigningString(headers)
Expand All @@ -355,7 +355,7 @@ object BerlinGroupSigning extends MdcLoggable {
println(s"1) Digest: $digest")
println(s"2) ${RequestHeader.`X-Request-ID`}: $xRequestId")
println(s"3) ${RequestHeader.Date}: $dateHeader")
println(s"4) ${RequestHeader.`TPP-Redirect-URL`}: $redirectUri")
println(s"4) ${RequestHeader.`TPP-Redirect-URI`}: $redirectUri")
val signatureHeaderValue =
s"""keyId="SN=43A, CA=CN=MAIB Prisacaru Sergiu (Test), O=MAIB", algorithm="rsa-sha256", headers="digest date x-request-id", signature="$signature""""
println(s"5) Signature: $signatureHeaderValue")
Expand Down
2 changes: 1 addition & 1 deletion obp-api/src/main/scala/code/api/util/ConsentUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ object Consent extends MdcLoggable {
)
}
}
val tppRedirectUrl: Option[HTTPParam] = callContext.map(_.requestHeaders).getOrElse(Nil).find(_.name == RequestHeader.`TPP-Redirect-URL`)
val tppRedirectUrl: Option[HTTPParam] = callContext.map(_.requestHeaders).getOrElse(Nil).find(_.name == RequestHeader.`TPP-Redirect-URI`)
Future.sequence(accounts ::: balances ::: transactions) map { views =>
val json = ConsentJWT(
createdByUserId = user.map(_.userId).getOrElse(""),
Expand Down
10 changes: 5 additions & 5 deletions obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import code.entitlement.Entitlement
import code.loginattempts.LoginAttempt
import code.metrics.APIMetrics
import code.metrics.MappedMetric.userId
import code.model.AppType
import code.model.{AppType, Consumer}
import code.model.dataAccess.{AuthUser, MappedBankAccount}
import code.regulatedentities.MappedRegulatedEntityProvider
import code.userlocks.UserLocksProvider
Expand Down Expand Up @@ -2061,9 +2061,9 @@ trait APIMethods510 {
}
)
}
(consumerId, applicationText) <- consentJson.consumer_id match {
(consumerFromRequestBody: Option[Consumer], applicationText) <- consentJson.consumer_id match {
case Some(id) => NewStyle.function.checkConsumerByConsumerId(id, callContext) map {
c => (Some(c.consumerId.get), c.description)
c => (Some(c), c.description)
}
case None => Future(None, "Any application")
}
Expand All @@ -2073,7 +2073,7 @@ trait APIMethods510 {
case Props.RunModes.Test => Consent.challengeAnswerAtTestEnvironment
case _ => SecureRandomUtil.numeric()
}
createdConsent <- Future(Consents.consentProvider.vend.createObpConsent(user, challengeAnswer, None)) map {
createdConsent <- Future(Consents.consentProvider.vend.createObpConsent(user, challengeAnswer, None, consumerFromRequestBody)) map {
i => connectorEmptyResponse(i, callContext)
}
consentJWT =
Expand All @@ -2082,7 +2082,7 @@ trait APIMethods510 {
consentJson,
createdConsent.secret,
createdConsent.consentId,
consumerId,
consumerFromRequestBody.map(_.consumerId.get),
consentJson.valid_from,
consentJson.time_to_live.getOrElse(3600),
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,20 @@ class MappedRegulatedEntity extends RegulatedEntityTrait with LongKeyedMapper[Ma
override def entityCountry: String = EntityCountry.get
override def entityWebSite: String = EntityWebSite.get
override def services: String = Services.get
// override def attributes: Option[List[RegulatedEntityAttributeSimple]] = Some(List(RegulatedEntityAttributeSimple(
// attributeType="attributeTypeExample.value",
// name="attributeNameExample.value",
// value="attributeValueExample.value")
// ))
override def attributes: Option[List[RegulatedEntityAttributeSimple]] = None //not for mapped mode yet, will add it later.
override def attributes: Option[List[RegulatedEntityAttributeSimple]] = Some(
List(
RegulatedEntityAttributeSimple(
attributeType="STRING",
name="CERTIFICATE_SERIAL_NUMBER",
value="1082"
),
RegulatedEntityAttributeSimple(
attributeType="STRING",
name="CERTIFICATE_CA_NAME",
value="BNM CA (test)"
),
))
// override def attributes: Option[List[RegulatedEntityAttributeSimple]] = None //not for mapped mode yet, will add it later.

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class BerlinGroupConsent extends MdcLoggable with RestHelper with APIMethods510
val consentJwt: Box[ConsentJWT] = JwtUtil.getSignedPayloadAsJson(consent.jsonWebToken).map(parse(_)
.extract[ConsentJWT])
val tppRedirectUri: immutable.Seq[String] = consentJwt.map { h =>
h.request_headers.filter(h => h.name == RequestHeader.`TPP-Redirect-URL`)
h.request_headers.filter(h => h.name == RequestHeader.`TPP-Redirect-URI`)
}.getOrElse(Nil).map((_.values.mkString("")))
val consumerRedirectUri: Option[String] = consumer.map(_.redirectURL.get).toOption
val uri: String = tppRedirectUri.headOption.orElse(consumerRedirectUri).getOrElse("https://not.defined.com")
Expand Down