Skip to content

Commit 3d8933e

Browse files
committed
Merge remote-tracking branch 'Simon/develop' into develop
2 parents c7398e2 + b8a0aec commit 3d8933e

14 files changed

+95
-31
lines changed

obp-api/src/main/scala/bootstrap/liftweb/Boot.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ class Boot extends MdcLoggable {
293293
SYSTEM_READ_TRANSACTIONS_DEBITS_VIEW_ID, SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID,
294294
SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID,
295295
SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID,
296-
SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID
296+
SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID,
297+
SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID
297298
)
298299
for {
299300
systemView <- viewSetUKOpenBanking

obp-api/src/main/scala/code/api/OAuth2.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ object OAuth2Login extends RestHelper with MdcLoggable {
165165
hydraAdmin.createOAuth2Client(oAuth2Client)
166166
} else if(!CertificateUtil.comparePemX509Certificates(certInConsumer, cert)) {
167167
// Cannot mat.ch the value from PSD2-CERT header and the database value Consumer.clientCertificate
168-
logger.debug("Cert in Consumer: " + certInConsumer)
168+
logger.debug(s"Cert in Consumer with the name ***${foundConsumer.name}*** : " + certInConsumer)
169169
logger.debug("Cert in Request: " + cert)
170170
logger.debug(s"Token: $value")
171171
logger.debug(s"Client ID: ${introspectOAuth2Token.getClientId}")

obp-api/src/main/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApi.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ As a last option, an ASPSP might in addition accept a command with access rights
188188
callContext.flatMap(_.consumer).map(_.consumerId.get),
189189
Some(validUntil),
190190
callContext
191-
)
191+
) map {
192+
i => connectorEmptyResponse(i, callContext)
193+
}
192194
_ <- Future(Consents.consentProvider.vend.setJsonWebToken(createdConsent.consentId, consentJWT)) map {
193195
i => connectorEmptyResponse(i, callContext)
194196
}
@@ -570,7 +572,7 @@ Reads account data from a given card account addressed by "account-id".
570572
_ <- passesPsd2Aisp(callContext)
571573
(bankAccount: BankAccount, callContext) <- NewStyle.function.getBankAccountByAccountId(accountId, callContext)
572574
(bank, callContext) <- NewStyle.function.getBank(bankAccount.bankId, callContext)
573-
viewId = ViewId(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID)
575+
viewId = ViewId(SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID)
574576
bankIdAccountId = BankIdAccountId(bankAccount.bankId, bankAccount.accountId)
575577
view <- NewStyle.function.checkAccountAccessAndGetView(viewId, bankIdAccountId, Full(u), callContext)
576578
params <- Future { createQueriesByHttpParams(callContext.get.requestHeaders)} map {

obp-api/src/main/scala/code/api/berlin/group/v1_3/PaymentInitiationServicePISApi.scala

+4-7
Original file line numberDiff line numberDiff line change
@@ -581,15 +581,12 @@ Check the transaction status of a payment initiation.""",
581581
}
582582
(toAccount, callContext) <- NewStyle.function.getToBankAccountByIban(toAccountIban, callContext)
583583

584-
viewId = ViewId(SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID)
584+
viewId = ViewId(SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID)
585585
bankIdAccountId = BankIdAccountId(fromAccount.bankId, fromAccount.accountId)
586586
view <- NewStyle.function.checkAccountAccessAndGetView(viewId, bankIdAccountId, Full(u), callContext)
587-
588-
_ <- if (view.canAddTransactionRequestToAnyAccount)
589-
Future.successful(Full(Unit))
590-
else
591-
NewStyle.function.hasEntitlement(fromAccount.bankId.value, u.userId, ApiRole.canCreateAnyTransactionRequest, callContext, InsufficientAuthorisationToCreateTransactionRequest)
592-
587+
_ <- Helper.booleanToFuture(InsufficientAuthorisationToCreateTransactionRequest, cc = callContext) {
588+
view.canAddTransactionRequestToAnyAccount
589+
}
593590
// Prevent default value for transaction request type (at least).
594591
_ <- Helper.booleanToFuture(s"From Account Currency is ${fromAccount.currency}, but Requested Transaction Currency is: ${sepaCreditTransfersBerlinGroupV13.instructedAmount.currency}", cc = callContext) {
595592
sepaCreditTransfersBerlinGroupV13.instructedAmount.currency == fromAccount.currency

obp-api/src/main/scala/code/api/constant/constant.scala

+5-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ object Constant extends MdcLoggable {
6060
final val SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID = "ReadAccountsBerlinGroup"
6161
final val SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID = "ReadBalancesBerlinGroup"
6262
final val SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID = "ReadTransactionsBerlinGroup"
63+
final val SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID = "InitiatePaymentsBerlinGroup"
6364

6465
//This is used for the canRevokeAccessToViews_ and canGrantAccessToViews_ fields of SYSTEM_OWNER_VIEW_ID or SYSTEM_STANDARD_VIEW_ID.
6566
final val DEFAULT_CAN_GRANT_AND_REVOKE_ACCESS_TO_VIEWS =
@@ -78,7 +79,8 @@ object Constant extends MdcLoggable {
7879
SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID::
7980
SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID::
8081
SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID::
81-
SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID :: Nil
82+
SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID ::
83+
SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID :: Nil
8284

8385
//We allow CBS side to generate views by getBankAccountsForUser.viewsToGenerate filed.
8486
// viewsToGenerate can be any views, and OBP will check the following list, to make sure only allowed views are generated
@@ -92,7 +94,8 @@ object Constant extends MdcLoggable {
9294
SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID::
9395
SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID::
9496
SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID::
95-
SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID :: Nil
97+
SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID ::
98+
SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID :: Nil
9699

97100
//These are the default incoming and outgoing account ids. we will create both during the boot.scala.
98101
final val INCOMING_SETTLEMENT_ACCOUNT_ID = "OBP-INCOMING-SETTLEMENT-ACCOUNT"

obp-api/src/main/scala/code/api/util/ConsentUtil.scala

+9-5
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ object Consent extends MdcLoggable {
669669
consentId: String,
670670
consumerId: Option[String],
671671
validUntil: Option[Date],
672-
callContext: Option[CallContext]): Future[String] = {
672+
callContext: Option[CallContext]): Future[Box[String]] = {
673673

674674
val currentTimeInSeconds = System.currentTimeMillis / 1000
675675
val validUntilTimeInSeconds = validUntil match {
@@ -731,10 +731,14 @@ object Consent extends MdcLoggable {
731731
views = views,
732732
access = Some(consent.access)
733733
)
734-
implicit val formats = CustomJsonFormats.formats
735-
val jwtPayloadAsJson = compactRender(Extraction.decompose(json))
736-
val jwtClaims: JWTClaimsSet = JWTClaimsSet.parse(jwtPayloadAsJson)
737-
CertificateUtil.jwtWithHmacProtection(jwtClaims, secret)
734+
if(views.isEmpty) {
735+
Empty
736+
} else {
737+
implicit val formats = CustomJsonFormats.formats
738+
val jwtPayloadAsJson = compactRender(Extraction.decompose(json))
739+
val jwtClaims: JWTClaimsSet = JWTClaimsSet.parse(jwtPayloadAsJson)
740+
Full(CertificateUtil.jwtWithHmacProtection(jwtClaims, secret))
741+
}
738742
}
739743
}
740744

obp-api/src/main/scala/code/api/v4_0_0/JSONFactory4.0.0.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ case class AccountsBalancesJsonV400(accounts:List[AccountBalanceJsonV400])
309309
case class BalanceJsonV400(`type`: String, currency: String, amount: String)
310310

311311
case class AccountBalanceJsonV400(
312-
account_id: String,
313312
bank_id: String,
313+
account_id: String,
314314
account_routings: List[AccountRouting],
315315
label: String,
316316
balances: List[BalanceJsonV400]

obp-api/src/main/scala/code/api/v5_0_0/APIMethods500.scala

+2
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,8 @@ trait APIMethods500 {
945945
//Here are all the VRP consent request
946946
(bankId, accountId, viewId, counterpartyId) <- if (isVRPConsentRequest) {
947947
val postConsentRequestJsonV510 = json.parse(createdConsentRequest.payload).extract[code.api.v5_1_0.PostVRPConsentRequestJsonV510]
948+
949+
// TODO Add routing scheme as well. In case IBAN is provided this will not work.
948950
val fromBankIdAccountId = BankIdAccountId(BankId(postConsentRequestJsonV510.from_account.bank_routing.address), AccountId(postConsentRequestJsonV510.from_account.account_routing.address))
949951

950952
val vrpViewId = s"_VRP-${UUID.randomUUID.toString}".dropRight(5)// to make sure the length of the viewId is 36.

obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala

+1
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ def restoreSomeSessions(): Unit = {
11111111
}
11121112

11131113
def isObpProvider(user: AuthUser) = {
1114+
// TODO Consider does http://host should match https://host in development mode
11141115
user.getProvider() == Constant.localIdentityProvider
11151116
}
11161117

obp-api/src/main/scala/code/sandbox/OBPDataImport.scala

+21-4
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,27 @@ trait OBPDataImport extends MdcLoggable {
411411
val readAccountsBerlinGroupView = Views.views.vend.getOrCreateSystemView(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID).asInstanceOf[Box[ViewType]]
412412
val readBalancesBerlinGroupView = Views.views.vend.getOrCreateSystemView(SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID).asInstanceOf[Box[ViewType]]
413413
val readTransactionsBerlinGroupView = Views.views.vend.getOrCreateSystemView(SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID).asInstanceOf[Box[ViewType]]
414-
415-
416-
417-
List(accountFirehose, ownerView, accountantsView, auditorsView, publicView, readAccountsBasicView, readAccountsDetailView, readBalancesView, readTransactionsBasicView, readTransactionsDebitsView, readTransactionsDetailView, readAccountsBerlinGroupView, readBalancesBerlinGroupView, readTransactionsBerlinGroupView).flatten
414+
val initiatePaymentsBerlinGroupView = Views.views.vend.getOrCreateSystemView(SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID).asInstanceOf[Box[ViewType]]
415+
416+
417+
418+
List(
419+
accountFirehose,
420+
ownerView,
421+
accountantsView,
422+
auditorsView,
423+
publicView,
424+
readAccountsBasicView,
425+
readAccountsDetailView,
426+
readBalancesView,
427+
readTransactionsBasicView,
428+
readTransactionsDebitsView,
429+
readTransactionsDetailView,
430+
readAccountsBerlinGroupView,
431+
readBalancesBerlinGroupView,
432+
readTransactionsBerlinGroupView,
433+
initiatePaymentsBerlinGroupView
434+
).flatten
418435

419436
}
420437

obp-api/src/main/scala/code/views/MapperViews.scala

+39-4
Original file line numberDiff line numberDiff line change
@@ -898,9 +898,12 @@ object MapperViews extends Views with MdcLoggable {
898898
.canSeeOtherBankRoutingAddress_(true)
899899
.canSeeOtherAccountRoutingScheme_(true)
900900
.canSeeOtherAccountRoutingAddress_(true)
901+
902+
// TODO Allow use only for certain cases
901903
.canAddTransactionRequestToOwnAccount_(true) //added following two for payments
902904
.canAddTransactionRequestToAnyAccount_(true)
903905
.canAddTransactionRequestToBeneficiary_(true)
906+
904907
.canSeeAvailableViewsForBankAccount_(false)
905908
.canSeeTransactionRequests_(false)
906909
.canSeeTransactionRequestTypes_(false)
@@ -916,7 +919,7 @@ object MapperViews extends Views with MdcLoggable {
916919

917920
viewId match {
918921
case SYSTEM_OWNER_VIEW_ID | SYSTEM_STANDARD_VIEW_ID =>
919-
entity
922+
entity // Make additional setup to the existing view
920923
.canSeeAvailableViewsForBankAccount_(true)
921924
.canSeeTransactionRequests_(true)
922925
.canSeeTransactionRequestTypes_(true)
@@ -926,21 +929,53 @@ object MapperViews extends Views with MdcLoggable {
926929
.canGrantAccessToViews_(DEFAULT_CAN_GRANT_AND_REVOKE_ACCESS_TO_VIEWS.mkString(","))
927930
.canRevokeAccessToViews_(DEFAULT_CAN_GRANT_AND_REVOKE_ACCESS_TO_VIEWS.mkString(","))
928931
case SYSTEM_STAGE_ONE_VIEW_ID =>
929-
entity
932+
entity // Make additional setup to the existing view
930933
.canSeeTransactionDescription_(false)
931934
.canAddTransactionRequestToAnyAccount_(false)
932935
.canAddTransactionRequestToBeneficiary_(false)
933936
case SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID =>
934-
entity
937+
entity // Make additional setup to the existing view
935938
.canRevokeAccessToCustomViews_(true)
936939
.canGrantAccessToCustomViews_(true)
937940
.canCreateCustomView_(true)
938941
.canDeleteCustomView_(true)
939942
.canUpdateCustomView_(true)
940943
.canGetCustomView_(true)
941944
case SYSTEM_FIREHOSE_VIEW_ID =>
942-
entity
945+
entity // Make additional setup to the existing view
943946
.isFirehose_(true)
947+
case SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID |
948+
SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID =>
949+
create // A new one
950+
.isSystem_(true)
951+
.isFirehose_(false)
952+
.name_(StringHelpers.capify(viewId))
953+
.view_id(viewId)
954+
.description_(viewId)
955+
case SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID =>
956+
create // A new one
957+
.isSystem_(true)
958+
.isFirehose_(false)
959+
.name_(StringHelpers.capify(viewId))
960+
.view_id(viewId)
961+
.description_(viewId)
962+
.canSeeTransactionThisBankAccount_(true)
963+
.canSeeTransactionOtherBankAccount_(true)
964+
.canSeeTransactionAmount_(true)
965+
.canSeeTransactionCurrency_(true)
966+
.canSeeTransactionBalance_(true)
967+
.canSeeTransactionStartDate_(true)
968+
.canSeeTransactionFinishDate_(true)
969+
.canSeeTransactionDescription_(true)
970+
case SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID =>
971+
create // A new one
972+
.isSystem_(true)
973+
.isFirehose_(false)
974+
.name_(StringHelpers.capify(viewId))
975+
.view_id(viewId)
976+
.description_(viewId)
977+
.canAddTransactionRequestToAnyAccount_(true)
978+
.canAddTransactionRequestToBeneficiary_(true)
944979
case _ =>
945980
entity
946981
}

obp-api/src/test/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApiTest.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package code.api.berlin.group.v1_3
22

33
import code.api.Constant
4-
import code.api.Constant.SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID
4+
import code.api.Constant.{SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID}
55
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3._
66
import code.api.builder.AccountInformationServiceAISApi.APIMethods_AccountInformationServiceAISApi
77
import code.api.util.APIUtil
@@ -212,7 +212,7 @@ class AccountInformationServiceAISApiTest extends BerlinGroupServerSetupV1_3 wit
212212
testAccountId.value,
213213
resourceUser1.userId,
214214
user1,
215-
PostViewJsonV400(view_id = SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, is_system = true)
215+
PostViewJsonV400(view_id = SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID, is_system = true)
216216
)
217217

218218
val requestGet = (V1_3_BG / "card-accounts" / testAccountId.value / "transactions").GET <@ (user1)

obp-api/src/test/scala/code/api/berlin/group/v1_3/BerlinGroupServerSetupV1_3.scala

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ trait BerlinGroupServerSetupV1_3 extends ServerSetupWithTestData {
2323
Views.views.vend.getOrCreateSystemView(SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID)
2424
Views.views.vend.getOrCreateSystemView(Constant.SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID)
2525
Views.views.vend.getOrCreateSystemView(Constant.SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID)
26+
Views.views.vend.getOrCreateSystemView(Constant.SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID)
2627
}
2728

2829
def grantUserAccessToViewViaEndpoint(bankId: String,

obp-api/src/test/scala/code/api/berlin/group/v1_3/PaymentInitiationServicePISApiTest.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package code.api.berlin.group.v1_3
22

33
import code.api.BerlinGroup.ScaStatus
44
import code.api.Constant
5-
import code.api.Constant.SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID
5+
import code.api.Constant.{SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID}
66
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.{CancellationJsonV13, InitiatePaymentResponseJson, StartPaymentAuthorisationJson}
77
import code.api.berlin.group.v1_3.model.{PsuData, ScaStatusResponse, UpdatePsuAuthenticationResponse}
88
import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.{CancellationJsonV13, ErrorMessagesBG, InitiatePaymentResponseJson, StartPaymentAuthorisationJson}
@@ -206,7 +206,8 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
206206
}
207207

208208
private def grantAccountAccess(acountRoutingIbanFrom: BankAccountRouting) = {
209-
Views.views.vend.systemView(ViewId(SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID)).flatMap(view =>
209+
org.scalameta.logger.elem(Views.views.vend.systemView(ViewId(SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID)))
210+
Views.views.vend.systemView(ViewId(SYSTEM_INITIATE_PAYMENTS_BERLIN_GROUP_VIEW_ID)).flatMap(view =>
210211
// Grant account access
211212
Views.views.vend.grantAccessToSystemView(acountRoutingIbanFrom.bankId,
212213
acountRoutingIbanFrom.accountId,

0 commit comments

Comments
 (0)