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
3 changes: 3 additions & 0 deletions obp-api/src/main/resources/props/sample.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,9 @@ default_auth_context_update_request_key=CUSTOMER_NUMBER
# the alias prefix path for BerlinGroupV1.3 (OBP built-in is berlin-group/v1.3), the format must be xxx/yyy, eg: 0.6/v1
#berlin_group_v1_3_alias_path=

# Berlin Group URL version
#berlin_group_version_1_canonical_path=v1.3

# Show the path inside of Berlin Group error message
#berlin_group_error_message_show_path = true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package code.api.berlin.group

import code.api.util.APIUtil
import com.openbankproject.commons.util.ApiVersion.berlinGroupV13
import com.openbankproject.commons.util.ScannedApiVersion
import net.liftweb.common.Full

object ConstantsBG {
val berlinGroupVersion1: ScannedApiVersion = APIUtil.getPropsValue("berlin_group_version_1_canonical_path") match {
case Full(props) => berlinGroupV13.copy(apiShortVersion = props)
case _ => berlinGroupV13
}
object SigningBasketsStatus extends Enumeration {
type SigningBasketsStatus = Value
// Only the codes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package code.api.builder.AccountInformationServiceAISApi
import java.text.SimpleDateFormat
import code.api.APIFailureNewStyle
import code.api.Constant.{SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID}
import code.api.berlin.group.ConstantsBG
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.{PostConsentResponseJson, _}
import code.api.berlin.group.v1_3.model.{HrefType, LinksAll, ScaStatusResponse}
import code.api.berlin.group.v1_3.{BgSpecValidation, JSONFactory_BERLIN_GROUP_1_3, JvalueCaseClass, OBP_BERLIN_GROUP_1_3}
Expand Down Expand Up @@ -37,7 +38,7 @@ import scala.collection.mutable.ArrayBuffer
import scala.concurrent.Future

object APIMethods_AccountInformationServiceAISApi extends RestHelper {
val apiVersion = ApiVersion.berlinGroupV13
val apiVersion = ConstantsBG.berlinGroupVersion1
val resourceDocs = ArrayBuffer[ResourceDoc]()
val apiRelations = ArrayBuffer[ApiRelation]()
protected implicit def JvalueToSuper(what: JValue): JvalueCaseClass = JvalueCaseClass(what)
Expand Down Expand Up @@ -784,7 +785,7 @@ This method returns the SCA status of a consent initiation's authorisation sub-r
case "consents" :: consentId:: "status" :: Nil JsonGet _ => {
cc =>
for {
(Full(u), callContext) <- authenticatedAccess(cc)
(_, callContext) <- applicationAccess(cc)
_ <- passesPsd2Aisp(callContext)
consent <- Future(Consents.consentProvider.vend.getConsentByConsentId(consentId)) map {
unboxFullOrFail(_, callContext, ConsentNotFound, 403)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package code.api.builder.CommonServicesApi

import code.api.berlin.group.ConstantsBG
import code.api.berlin.group.v1_3.{JvalueCaseClass, OBP_BERLIN_GROUP_1_3}
import code.api.builder.AccountInformationServiceAISApi.APIMethods_AccountInformationServiceAISApi
import code.api.builder.PaymentInitiationServicePISApi.APIMethods_PaymentInitiationServicePISApi
Expand All @@ -14,7 +15,7 @@ import scala.collection.mutable.ArrayBuffer

//TODO maybe we can remove this common services, it just show other apis in this tag. no new ones.
object APIMethods_CommonServicesApi extends RestHelper {
val apiVersion = ApiVersion.berlinGroupV13
val apiVersion = ConstantsBG.berlinGroupVersion1
val resourceDocs = ArrayBuffer[ResourceDoc]()
val apiRelations = ArrayBuffer[ApiRelation]()
val codeContext = CodeContext(resourceDocs, apiRelations)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package code.api.builder.ConfirmationOfFundsServicePIISApi

import code.api.berlin.group.ConstantsBG
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3._
import code.api.berlin.group.v1_3.{JvalueCaseClass, OBP_BERLIN_GROUP_1_3}
import code.api.util.APIUtil._
Expand All @@ -20,7 +21,7 @@ import scala.collection.immutable.Nil
import scala.collection.mutable.ArrayBuffer

object APIMethods_ConfirmationOfFundsServicePIISApi extends RestHelper {
val apiVersion = ApiVersion.berlinGroupV13
val apiVersion = ConstantsBG.berlinGroupVersion1
val resourceDocs = ArrayBuffer[ResourceDoc]()
val apiRelations = ArrayBuffer[ApiRelation]()
protected implicit def JvalueToSuper(what: JValue): JvalueCaseClass = JvalueCaseClass(what)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package code.api.berlin.group.v1_3

import code.api.berlin.group.ConstantsBG
import code.api.berlin.group.v1_3.model.TransactionStatus.mapTransactionStatus
import code.api.berlin.group.v1_3.model._
import code.api.util.APIUtil._
Expand Down Expand Up @@ -513,7 +514,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
TransactionsV13Transactions(
booked= transactions.map(transaction => createTransactionJSON(bankAccount, transaction)),
pending = transactionRequests.filter(_.status!="COMPLETED").map(transactionRequest => createTransactionFromRequestJSON(bankAccount, transactionRequest)),
_links = TransactionsV13TransactionsLinks(LinkHrefJson(s"/v1.3/accounts/$accountId"))
_links = TransactionsV13TransactionsLinks(LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/accounts/$accountId"))
)
)
}
Expand Down Expand Up @@ -559,7 +560,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
CardTransactionsV13Transactions(
booked= transactions.map(t => createCardTransactionJson(t)),
pending = Nil,
_links = CardTransactionsLinksV13(LinkHrefJson(s"/v1.3/card-accounts/$accountId"))
_links = CardTransactionsLinksV13(LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/card-accounts/$accountId"))
)
)
}
Expand All @@ -570,7 +571,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
consentId = consent.consentId,
consentStatus = consent.status.toLowerCase(),
_links = ConsentLinksV13(
startAuthorisation = Some(Href(s"/v1.3/consents/${consent.consentId}/authorisations"))
startAuthorisation = Some(Href(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/consents/${consent.consentId}/authorisations"))
)
)
}
Expand All @@ -589,9 +590,9 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
consentStatus = consent.status.toLowerCase(),
_links = ConsentLinksV13(
scaRedirect = Some(Href(s"$scaRedirectUrl")),
status = Some(Href(s"/v1.3/consents/${consent.consentId}/status")),
status = Some(Href(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/consents/${consent.consentId}/status")),
// TODO Introduce a working link
// scaStatus = Some(Href(s"/v1.3/consents/${consent.consentId}/authorisations/AUTHORISATIONID")),
// scaStatus = Some(Href(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/consents/${consent.consentId}/authorisations/AUTHORISATIONID")),
)
)
case Full("redirection_with_dedicated_start_of_authorization") =>
Expand All @@ -601,15 +602,15 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
consentId = consent.consentId,
consentStatus = consent.status.toLowerCase(),
_links = ConsentLinksV13(
startAuthorisationWithPsuAuthentication = Some(Href(s"/v1.3/consents/${consent.consentId}/authorisations"))
startAuthorisationWithPsuAuthentication = Some(Href(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/consents/${consent.consentId}/authorisations"))
)
)
case Full("decoupled") =>
PostConsentResponseJson(
consentId = consent.consentId,
consentStatus = consent.status.toLowerCase(),
_links = ConsentLinksV13(
startAuthorisationWithPsuIdentification = Some(Href(s"/v1.3/consents/${consent.consentId}/authorisations"))
startAuthorisationWithPsuIdentification = Some(Href(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/consents/${consent.consentId}/authorisations"))
)
)
case _ =>
Expand All @@ -620,7 +621,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
def createPutConsentResponseJson(consent: ConsentTrait) : ScaStatusResponse = {
ScaStatusResponse(
scaStatus = consent.status.toLowerCase(),
_links = Some(LinksAll(scaStatus = Some(HrefType(Some(s"/v1.3/consents/${consent.consentId}/authorisations")))))
_links = Some(LinksAll(scaStatus = Some(HrefType(Some(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/consents/${consent.consentId}/authorisations")))))
)
}

Expand All @@ -645,7 +646,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
scaStatus = challenge.scaStatus.map(_.toString).getOrElse("None"),
authorisationId = challenge.authenticationMethodId.getOrElse("None"),
pushMessage = "started", //TODO Not implement how to fill this.
_links = ScaStatusJsonV13(s"/v1.3/consents/${consent.consentId}/authorisations/${challenge.challengeId}")//TODO, Not sure, what is this for??
_links = ScaStatusJsonV13(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/consents/${consent.consentId}/authorisations/${challenge.challengeId}")//TODO, Not sure, what is this for??
)
}

Expand Down Expand Up @@ -698,9 +699,9 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
paymentId = paymentId,
_links = InitiatePaymentResponseLinks(
scaRedirect = LinkHrefJson(s"$scaRedirectUrl/$paymentId"),
self = LinkHrefJson(s"/v1.3/payments/sepa-credit-transfers/$paymentId"),
status = LinkHrefJson(s"/v1.3/payments/$paymentId/status"),
scaStatus = LinkHrefJson(s"/v1.3/payments/$paymentId/authorisations/${paymentId}")
self = LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/payments/sepa-credit-transfers/$paymentId"),
status = LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/payments/$paymentId/status"),
scaStatus = LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/payments/$paymentId/authorisations/${paymentId}")
)
)
}
Expand All @@ -709,9 +710,9 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
CancelPaymentResponseJson(
"ACTC",
_links = CancelPaymentResponseLinks(
self = LinkHrefJson(s"/v1.3/payments/sepa-credit-transfers/$paymentId"),
status = LinkHrefJson(s"/v1.3/payments/sepa-credit-transfers/$paymentId/status"),
startAuthorisation = LinkHrefJson(s"/v1.3/payments/sepa-credit-transfers/cancellation-authorisations/${paymentId}")
self = LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/payments/sepa-credit-transfers/$paymentId"),
status = LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/payments/sepa-credit-transfers/$paymentId/status"),
startAuthorisation = LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/payments/sepa-credit-transfers/cancellation-authorisations/${paymentId}")
)
)
}
Expand All @@ -725,15 +726,15 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
scaStatus = challenge.scaStatus.map(_.toString).getOrElse(""),
authorisationId = challenge.challengeId,
psuMessage = "Please check your SMS at a mobile device.",
_links = ScaStatusJsonV13(s"/v1.3/payments/sepa-credit-transfers/${challenge.challengeId}")
_links = ScaStatusJsonV13(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/payments/sepa-credit-transfers/${challenge.challengeId}")
)
}

def createUpdatePaymentPsuDataTransactionAuthorisationJson(challenge: ChallengeTrait) = {
ScaStatusResponse(
scaStatus = challenge.scaStatus.map(_.toString).getOrElse(""),
psuMessage = Some("Please check your SMS at a mobile device."),
_links = Some(LinksAll(scaStatus = Some(HrefType(Some(s"/v1.3/payments/sepa-credit-transfers/${challenge.challengeId}"))))
_links = Some(LinksAll(scaStatus = Some(HrefType(Some(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/payments/sepa-credit-transfers/${challenge.challengeId}"))))
)
)
}
Expand All @@ -745,7 +746,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
ScaStatusResponse(
scaStatus = challenge.scaStatus.map(_.toString).getOrElse(""),
psuMessage = Some("Please check your SMS at a mobile device."),
_links = Some(LinksAll(scaStatus = Some(HrefType(Some(s"/v1.3/${paymentService}/${paymentProduct}/${paymentId}/cancellation-authorisations/${challenge.challengeId}"))))
_links = Some(LinksAll(scaStatus = Some(HrefType(Some(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/${paymentService}/${paymentProduct}/${paymentId}/cancellation-authorisations/${challenge.challengeId}"))))
)
)
}
Expand All @@ -761,7 +762,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
authorisationId = Some(challenge.challengeId),
psuMessage = Some("Please check your SMS at a mobile device."),
_links = Some(LinksUpdatePsuAuthentication(
scaStatus = Some(HrefType(Some(s"/v1.3/${paymentService}/${paymentProduct}/${paymentId}/cancellation-authorisations/${challenge.challengeId}"))))
scaStatus = Some(HrefType(Some(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/${paymentService}/${paymentProduct}/${paymentId}/cancellation-authorisations/${challenge.challengeId}"))))
)
)
}
Expand All @@ -772,7 +773,7 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
scaStatus = challenge.scaStatus.map(_.toString).getOrElse(""),
authorisationId = challenge.challengeId,
psuMessage = "Please check your SMS at a mobile device.",
_links = ScaStatusJsonV13(s"/v1.3/signing-baskets/${basketId}/authorisations/${challenge.challengeId}")
_links = ScaStatusJsonV13(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/signing-baskets/${basketId}/authorisations/${challenge.challengeId}")
)
}

Expand All @@ -781,9 +782,9 @@ object JSONFactory_BERLIN_GROUP_1_3 extends CustomJsonFormats with MdcLoggable{
basketId = basket.basketId,
transactionStatus = basket.status.toLowerCase(),
_links = SigningBasketLinksV13(
self = LinkHrefJson(s"/v1.3/signing-baskets/${basket.basketId}"),
status = LinkHrefJson(s"/v1.3/signing-baskets/${basket.basketId}/status"),
startAuthorisation = LinkHrefJson(s"/v1.3/signing-baskets/${basket.basketId}/authorisations")
self = LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/signing-baskets/${basket.basketId}"),
status = LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/signing-baskets/${basket.basketId}/status"),
startAuthorisation = LinkHrefJson(s"/${ConstantsBG.berlinGroupVersion1.apiShortVersion}/signing-baskets/${basket.basketId}/authorisations")
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
package code.api.berlin.group.v1_3

import code.api.OBPRestHelper
import code.api.berlin.group.ConstantsBG
import code.api.builder.AccountInformationServiceAISApi.APIMethods_AccountInformationServiceAISApi
import code.api.builder.CommonServicesApi.APIMethods_CommonServicesApi
import code.api.builder.ConfirmationOfFundsServicePIISApi.APIMethods_ConfirmationOfFundsServicePIISApi
Expand All @@ -40,7 +41,7 @@ import code.api.builder.SigningBasketsApi.APIMethods_SigningBasketsApi
import code.api.util.APIUtil.{OBPEndpoint, ResourceDoc, getAllowedEndpoints}
import code.api.util.ScannedApis
import code.util.Helper.MdcLoggable
import com.openbankproject.commons.util.{ApiVersion, ScannedApiVersion,ApiVersionStatus}
import com.openbankproject.commons.util.{ApiVersion, ApiVersionStatus, ScannedApiVersion}

import scala.collection.mutable.ArrayBuffer

Expand All @@ -52,7 +53,7 @@ This file defines which endpoints from all the versions are available in v1
*/
object OBP_BERLIN_GROUP_1_3 extends OBPRestHelper with MdcLoggable with ScannedApis {

override val apiVersion = ApiVersion.berlinGroupV13
override val apiVersion = ConstantsBG.berlinGroupVersion1
val versionStatus = ApiVersionStatus.DRAFT.toString

val endpoints =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package code.api.builder.PaymentInitiationServicePISApi

import code.api.berlin.group.ConstantsBG
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.{CancelPaymentResponseJson, CancelPaymentResponseLinks, LinkHrefJson, UpdatePaymentPsuDataJson, checkAuthorisationConfirmation, checkSelectPsuAuthenticationMethod, checkTransactionAuthorisation, checkUpdatePsuAuthentication, createCancellationTransactionRequestJson}
import code.api.berlin.group.v1_3.model.TransactionStatus.mapTransactionStatus
import code.api.berlin.group.v1_3.model._
Expand Down Expand Up @@ -30,7 +31,7 @@ import scala.collection.mutable.ArrayBuffer
import scala.concurrent.Future

object APIMethods_PaymentInitiationServicePISApi extends RestHelper {
val apiVersion = ApiVersion.berlinGroupV13
val apiVersion = ConstantsBG.berlinGroupVersion1
val resourceDocs = ArrayBuffer[ResourceDoc]()
val apiRelations = ArrayBuffer[ApiRelation]()
protected implicit def JvalueToSuper(what: JValue): JvalueCaseClass = JvalueCaseClass(what)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import scala.collection.mutable.ArrayBuffer
import scala.concurrent.Future

object APIMethods_SigningBasketsApi extends RestHelper {
val apiVersion = ApiVersion.berlinGroupV13
val apiVersion = ConstantsBG.berlinGroupVersion1
val resourceDocs = ArrayBuffer[ResourceDoc]()
val apiRelations = ArrayBuffer[ApiRelation]()
protected implicit def JvalueToSuper(what: JValue): JvalueCaseClass = JvalueCaseClass(what)
Expand Down
2 changes: 2 additions & 0 deletions obp-api/src/main/scala/code/api/constant/constant.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ object RequestHeader {
final lazy val `PSD2-CERT` = "PSD2-CERT"
final lazy val `If-None-Match` = "If-None-Match"

final lazy val `PSU-Geo-Location` = "PSU-Geo-Location" // Berlin Group
final lazy val `PSU-Device-Name` = "PSU-Device-Name" // Berlin Group
final lazy val `PSU-Device-ID` = "PSU-Device-ID" // Berlin Group
final lazy val `PSU-IP-Address` = "PSU-IP-Address" // Berlin Group
final lazy val `X-Request-ID` = "X-Request-ID" // Berlin Group
Expand Down
5 changes: 3 additions & 2 deletions obp-api/src/main/scala/code/api/util/APIUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import code.api.OAuthHandshake._
import code.api.UKOpenBanking.v2_0_0.OBP_UKOpenBanking_200
import code.api.UKOpenBanking.v3_1_0.OBP_UKOpenBanking_310
import code.api._
import code.api.berlin.group.ConstantsBG
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.{ErrorMessageBG, ErrorMessagesBG}
import code.api.cache.Caching
import code.api.dynamic.endpoint.OBPAPIDynamicEndpoint
Expand Down Expand Up @@ -520,7 +521,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
val mirrorByProperties = getPropsValue("mirror_request_headers_to_response", "").split(",").toList.map(_.trim)

val mirrorRequestHeadersToResponse: List[String] =
if (callContext.exists(_.url.contains(ApiVersion.berlinGroupV13.urlPrefix))) {
if (callContext.exists(_.url.contains(ConstantsBG.berlinGroupVersion1.urlPrefix))) {
// Berlin Group Specification
RequestHeader.`X-Request-ID` :: mirrorByProperties
} else {
Expand Down Expand Up @@ -725,7 +726,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{
}
def composeErrorMessage() = {
val path = callContextLight.map(_.url).getOrElse("")
if (path.contains(ApiVersion.berlinGroupV13.urlPrefix)) {
if (path.contains(ConstantsBG.berlinGroupVersion1.urlPrefix)) {
val path =
if(APIUtil.getPropsAsBoolValue("berlin_group_error_message_show_path", defaultValue = true))
callContextLight.map(_.url)
Expand Down
Loading