diff --git a/obp-api/pom.xml b/obp-api/pom.xml index 3fdc02716d..5d991b3bde 100644 --- a/obp-api/pom.xml +++ b/obp-api/pom.xml @@ -418,7 +418,7 @@ com.microsoft.sqlserver mssql-jdbc - 8.1.0.jre${java.version}-preview + 11.2.0.jre${java.version} @@ -530,7 +530,7 @@ org.codehaus.mojo build-helper-maven-plugin - 1.10 + 3.6.0 generate-sources @@ -552,7 +552,7 @@ org.apache.maven.plugins maven-war-plugin - 2.6 + 3.4.0 ${webXmlPath} @@ -639,7 +639,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.13.0 ${java.version} diff --git a/obp-api/src/main/resources/i18n/lift-core_es_ES.properties b/obp-api/src/main/resources/i18n/lift-core_es_ES.properties index 3d3dd7a07c..c8b54ad520 100644 --- a/obp-api/src/main/resources/i18n/lift-core_es_ES.properties +++ b/obp-api/src/main/resources/i18n/lift-core_es_ES.properties @@ -718,7 +718,7 @@ OBP-30030 = se pudo insertar el Producto OBP-30031 = se ha podido actualizar el Producto OBP-30032 = se pudo insertar la tarjeta OBP-30033 = se ha podido actualizar la tarjeta -OBP-30034 = ViewId no es soportado. Sólo admite cuatro ahora': Owner, Accountant, Auditor, _Public. +OBP-30034 = ViewId no es soportado. Sólo admite cuatro ahora': owner, accountant, auditor, _public. OBP-30035 = se ha encontrado el enlace con el cliente OBP-30036 = se ha podido crear o actualizar CounterpartyMetadata OBP-30037 = se han encontrado los metadatos de la contraparte. Por favor, especifique valores válidos para BANK_ID, ACCOUNT_ID y COUNTERPARTY_ID. diff --git a/obp-api/src/main/scala/code/api/OAuth2.scala b/obp-api/src/main/scala/code/api/OAuth2.scala index b68644e5bb..e78befb655 100644 --- a/obp-api/src/main/scala/code/api/OAuth2.scala +++ b/obp-api/src/main/scala/code/api/OAuth2.scala @@ -181,8 +181,8 @@ object OAuth2Login extends RestHelper with MdcLoggable { // In case a user is created via OpenID Connect flow implies provider = hydraPublicUrl // In case a user is created via GUI of OBP-API implies provider = Constant.localIdentityProvider - val user = Users.users.vend.getUserByUserName(introspectOAuth2Token.getIss, introspectOAuth2Token.getSub).or( - Users.users.vend.getUserByUserName(Constant.localIdentityProvider, introspectOAuth2Token.getSub) + val user = Users.users.vend.getUserByProviderAndUsername(introspectOAuth2Token.getIss, introspectOAuth2Token.getSub).or( + Users.users.vend.getUserByProviderAndUsername(Constant.localIdentityProvider, introspectOAuth2Token.getSub) ) user match { case Full(u) => diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/MessageDocsSwaggerDefinitions.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/MessageDocsSwaggerDefinitions.scala index 65fb3f51c7..6fbd7001e4 100644 --- a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/MessageDocsSwaggerDefinitions.scala +++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/MessageDocsSwaggerDefinitions.scala @@ -1,5 +1,6 @@ package code.api.ResourceDocs1_4_0 +import code.api.Constant import java.util.Date import code.api.util.APIUtil._ @@ -23,7 +24,7 @@ object MessageDocsSwaggerDefinitions balanceAmount = balanceAmountExample.value, balanceCurrency = currencyExample.value, owners = List(owner1Example.value), - viewsToGenerate = List("Owner", "Accountant", "Auditor"), + viewsToGenerate = List(Constant.SYSTEM_OWNER_VIEW_ID, Constant.SYSTEM_ACCOUNTANT_VIEW_ID,Constant.SYSTEM_AUDITOR_VIEW_ID), bankRoutingScheme = bankRoutingSchemeExample.value, bankRoutingAddress = bankRoutingAddressExample.value, branchRoutingScheme = branchRoutingSchemeExample.value, diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala index ce8dbc06b2..6a1c916465 100644 --- a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala +++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala @@ -345,8 +345,8 @@ object SwaggerDefinitionsJSON { hide_metadata_if_alias_used = hideMetadataIfAliasUsedExample.value.toBoolean, allowed_actions = allowedActionsV500, // Version 5.0.0 - can_grant_access_to_views = Some(List(viewIdExample.value)), - can_revoke_access_to_views = Some(List(viewIdExample.value)) + can_grant_access_to_views = Some(List(Constant.SYSTEM_OWNER_VIEW_ID)), + can_revoke_access_to_views = Some(List(Constant.SYSTEM_OWNER_VIEW_ID)) ) val updateCustomViewJson = UpdateCustomViewJson( @@ -447,8 +447,8 @@ object SwaggerDefinitionsJSON { hide_metadata_if_alias_used = true, allowed_actions = allowedActionsV500, // Version 5.0.0 - can_grant_access_to_views = Some(List("owner")), - can_revoke_access_to_views = Some(List("owner")) + can_grant_access_to_views = Some(List(Constant.SYSTEM_OWNER_VIEW_ID)), + can_revoke_access_to_views = Some(List(Constant.SYSTEM_OWNER_VIEW_ID)) ) lazy val updateSystemViewJson500 = updateViewJsonV500.copy(is_public = false, is_firehose = Some(false)) @@ -3079,15 +3079,15 @@ object SwaggerDefinitionsJSON { can_see_bank_account_credit_limit = true, can_create_direct_debit = true, can_create_standing_order = true, - can_grant_access_to_views = List("Owner"), - can_revoke_access_to_views = List("Owner") + can_grant_access_to_views = List(Constant.SYSTEM_OWNER_VIEW_ID), + can_revoke_access_to_views = List(Constant.SYSTEM_OWNER_VIEW_ID) ) val viewsJsonV500 = ViewsJsonV500( views = List(viewJsonV500) ) - val viewIdJsonV500 = ViewIdJsonV500(id = "owner") + val viewIdJsonV500 = ViewIdJsonV500(id = Constant.SYSTEM_OWNER_VIEW_ID) val viewIdsJsonV500 = ViewsIdsJsonV500( views = List(viewIdJsonV500) ) diff --git a/obp-api/src/main/scala/code/api/berlin/group/v1_3/PaymentInitiationServicePISApi.scala b/obp-api/src/main/scala/code/api/berlin/group/v1_3/PaymentInitiationServicePISApi.scala index d2d26ad118..bce50fbdb1 100644 --- a/obp-api/src/main/scala/code/api/berlin/group/v1_3/PaymentInitiationServicePISApi.scala +++ b/obp-api/src/main/scala/code/api/berlin/group/v1_3/PaymentInitiationServicePISApi.scala @@ -1,5 +1,6 @@ package code.api.builder.PaymentInitiationServicePISApi +import code.api.Constant import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON.sepaCreditTransfersBerlinGroupV13 import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3.{CancelPaymentResponseJson, CancelPaymentResponseLinks, LinkHrefJson, UpdatePaymentPsuDataJson, checkUpdatePsuAuthentication,checkAuthorisationConfirmation, @@ -590,7 +591,7 @@ Check the transaction status of a payment initiation.""", for { (createdTransactionRequest, callContext) <- NewStyle.function.createTransactionRequestv400( u, - ViewId("Owner"), //This is the default + ViewId(Constant.SYSTEM_OWNER_VIEW_ID), //This is the default fromAccount, toAccount, TransactionRequestType(transactionRequestTypes.toString), diff --git a/obp-api/src/main/scala/code/api/constant/constant.scala b/obp-api/src/main/scala/code/api/constant/constant.scala index 86a601cfe8..69ac481743 100644 --- a/obp-api/src/main/scala/code/api/constant/constant.scala +++ b/obp-api/src/main/scala/code/api/constant/constant.scala @@ -13,7 +13,7 @@ object Constant extends MdcLoggable { object Pagination { final val offset = 0 - final val limit = 500 + final val limit = 50 } final val shortEndpointTimeoutInMillis = APIUtil.getPropsAsLongValue(nameOfProperty = "short_endpoint_timeout", 1L * 1000L) @@ -62,24 +62,35 @@ object Constant extends MdcLoggable { final val SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID = "ReadTransactionsBerlinGroup" //TODO, this need to be double check - final val ALL_SYSTEM_VIEWS_CREATED_FROM_BOOT = List( - SYSTEM_OWNER_VIEW_ID, - SYSTEM_AUDITOR_VIEW_ID, - SYSTEM_ACCOUNTANT_VIEW_ID, - SYSTEM_FIREHOSE_VIEW_ID, - SYSTEM_STANDARD_VIEW_ID, - SYSTEM_STAGE_ONE_VIEW_ID, - SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID, - SYSTEM_READ_ACCOUNTS_BASIC_VIEW_ID, - SYSTEM_READ_ACCOUNTS_DETAIL_VIEW_ID, - SYSTEM_READ_BALANCES_VIEW_ID, - SYSTEM_READ_TRANSACTIONS_BASIC_VIEW_ID, - SYSTEM_READ_TRANSACTIONS_DEBITS_VIEW_ID, - SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID, - SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, - SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID, - SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID - ) + final val ALL_SYSTEM_VIEWS_CREATED_FROM_BOOT = + SYSTEM_OWNER_VIEW_ID:: + SYSTEM_AUDITOR_VIEW_ID:: + SYSTEM_ACCOUNTANT_VIEW_ID:: + SYSTEM_FIREHOSE_VIEW_ID:: + SYSTEM_STANDARD_VIEW_ID:: + SYSTEM_STAGE_ONE_VIEW_ID:: + SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID:: + SYSTEM_READ_ACCOUNTS_BASIC_VIEW_ID:: + SYSTEM_READ_ACCOUNTS_DETAIL_VIEW_ID:: + SYSTEM_READ_BALANCES_VIEW_ID:: + SYSTEM_READ_TRANSACTIONS_BASIC_VIEW_ID:: + SYSTEM_READ_TRANSACTIONS_DEBITS_VIEW_ID:: + SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID:: + SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID:: + SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID:: + SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID :: Nil + + final val ALL_SYSTEM_VIEWS_CREATED_FROM_CBS = + SYSTEM_OWNER_VIEW_ID:: + SYSTEM_ACCOUNTANT_VIEW_ID:: + SYSTEM_AUDITOR_VIEW_ID:: + SYSTEM_STAGE_ONE_VIEW_ID:: + SYSTEM_STANDARD_VIEW_ID:: + SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID:: + SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID:: + SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID:: + SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID :: Nil + //These are the default incoming and outgoing account ids. we will create both during the boot.scala. final val INCOMING_SETTLEMENT_ACCOUNT_ID = "OBP-INCOMING-SETTLEMENT-ACCOUNT" final val OUTGOING_SETTLEMENT_ACCOUNT_ID = "OBP-OUTGOING-SETTLEMENT-ACCOUNT" diff --git a/obp-api/src/main/scala/code/api/directlogin.scala b/obp-api/src/main/scala/code/api/directlogin.scala index 576ce7511e..23ccea7a24 100644 --- a/obp-api/src/main/scala/code/api/directlogin.scala +++ b/obp-api/src/main/scala/code/api/directlogin.scala @@ -491,14 +491,9 @@ object DirectLogin extends RestHelper with MdcLoggable { val username = directLoginParameters.getOrElse("username", "") val password = directLoginParameters.getOrElse("password", "") - var userId = for {id <- AuthUser.getResourceUserId(username, password)} yield id - - if (userId.isEmpty) { - if ( ! AuthUser.externalUserHelper(username, password).isEmpty) - userId = for {id <- AuthUser.getResourceUserId(username, password)} yield id - } - - userId + //we first try to get the userId from local, if not find, we try to get it from external + AuthUser.getResourceUserId(username, password) + .or(AuthUser.externalUserHelper(username, password).map(_.user.get)) } diff --git a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala index 2d07d11df9..21733fe8ad 100644 --- a/obp-api/src/main/scala/code/api/util/ErrorMessages.scala +++ b/obp-api/src/main/scala/code/api/util/ErrorMessages.scala @@ -338,14 +338,7 @@ object ErrorMessages { val CreateCardError = "OBP-30032: Could not insert the Card" val UpdateCardError = "OBP-30033: Could not update the Card" - val ViewIdNotSupported = s"OBP-30034: This ViewId is not supported. Only the following can be used: " + - s"$SYSTEM_OWNER_VIEW_ID, " + - s"$SYSTEM_ACCOUNTANT_VIEW_ID, " + - s"$SYSTEM_AUDITOR_VIEW_ID, " + - s"$SYSTEM_STAGE_ONE_VIEW_ID, " + - s"$SYSTEM_STANDARD_VIEW_ID, " + - s"$SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID, " + - s"$CUSTOM_PUBLIC_VIEW_ID." + val ViewIdNotSupported = s"OBP-30034: This ViewId is not supported. Only the following can be used: " val UserCustomerLinkNotFound = "OBP-30035: User Customer Link not found" diff --git a/obp-api/src/main/scala/code/api/util/ExampleValue.scala b/obp-api/src/main/scala/code/api/util/ExampleValue.scala index 9a1eb27012..e931599cf1 100644 --- a/obp-api/src/main/scala/code/api/util/ExampleValue.scala +++ b/obp-api/src/main/scala/code/api/util/ExampleValue.scala @@ -1,6 +1,7 @@ package code.api.util +import code.api.Constant import code.api.util.APIUtil.{DateWithMs, DateWithMsExampleString, formatDate, oneYearAgo, oneYearAgoDate, parseDate} import code.api.util.ErrorMessages.{InvalidJsonFormat, UnknownError, UserHasMissingRoles, UserNotLoggedIn} import net.liftweb.json.JsonDSL._ @@ -331,10 +332,10 @@ object ExampleValue { lazy val owner1Example = ConnectorField("SusanSmith", "A username that is the owner of the account.") glossaryItems += makeGlossaryItem("Account.owner", owner1Example) - lazy val viewIdExample = ConnectorField("owner", "A viewId can be owner, accountant, public ....") + lazy val viewIdExample = ConnectorField(Constant.SYSTEM_OWNER_VIEW_ID, "A viewId can be owner, accountant ....") glossaryItems += makeGlossaryItem("view.id", viewIdExample) - lazy val viewNameExample = ConnectorField("Owner","A viewName can be Owner, Accountant, Public ....") + lazy val viewNameExample = ConnectorField(Constant.SYSTEM_OWNER_VIEW_ID,"A viewName can be owner, accountant ....") glossaryItems += makeGlossaryItem("view.name",viewNameExample) lazy val viewDescriptionExample = ConnectorField("This view is for the owner for the account.", "A description for this view.") @@ -1497,7 +1498,7 @@ object ExampleValue { glossaryItems += makeGlossaryItem("basket_id", basketIdExample) lazy val consentRequestPayloadExample = ConnectorField( - """{ + s"""{ | "everything": false, | "account_access": [ | { @@ -1505,7 +1506,7 @@ object ExampleValue { | "scheme": "AccountNumber", | "address": "4930396" | }, - | "view_id": "owner" + | "view_id": "${Constant.SYSTEM_OWNER_VIEW_ID}" | } | ], | "phone_number": "+44 07972 444 876", diff --git a/obp-api/src/main/scala/code/api/util/Glossary.scala b/obp-api/src/main/scala/code/api/util/Glossary.scala index 2849e74a5c..cb499e2bff 100644 --- a/obp-api/src/main/scala/code/api/util/Glossary.scala +++ b/obp-api/src/main/scala/code/api/util/Glossary.scala @@ -1,7 +1,7 @@ package code.api.util import java.io.File - +import code.api.Constant import code.api.Constant.{PARAM_LOCALE, directLoginHeaderName} import code.api.util.APIUtil.{getObpApiRoot, getServerUrl} import code.api.util.ExampleValue.{accountIdExample, bankIdExample, customerIdExample, userIdExample} @@ -739,7 +739,16 @@ object Glossary extends MdcLoggable { s""" |The "consumer" of the API, i.e. the web, mobile or serverside "App" that calls on the OBP API on behalf of the end user (or system). | - |Each Consumer has a consumer key and secrect which allows it to enter into secure communication with the API server. + |Each Consumer has a consumer key and secret which allows it to enter into secure communication with the API server. + | + |A Consumer is given a Consumer ID (a UUID) which appears in logs and messages to the backend. + | + |A Consumer may be pinned to an mTLS certificate i.e. the consumer record in the database is given a field which matches the PEM representation of the certificate. + | + |After pinning, the consumer must present the certificate in all communication with the server. + | + |There is a one to one relationship between a Consumer and its certificate. i.e. OBP does not (currently) store the history of certificates bound to a Consumer. If a certificate expires, the third party provider (TPP) must generate a new consumer using a new certificate. In this case, related resources such as rate limits and scopes must be copied from the old consumer to the new consumer. In the future, OBP may store multiple certificates for a consumer, but a certificate will always identify only one consumer record. + | """) glossaryItems += GlossaryItem( @@ -1752,7 +1761,7 @@ object Glossary extends MdcLoggable { | |Body: | -| { "everything":false, "views":[{ "bank_id":"gh.29.uk", "account_id":"8ca8a7e4-6d02-40e3-a129-0b2bf89de9f0", "view_id":"owner" }], "entitlements":[{ "bank_id":"gh.29.uk", "role_name":"CanGetCustomer" }], "consumer_id":"7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh", "phone_number":"+44 07972 444 876", "valid_from":"2022-04-29T10:40:03Z", "time_to_live":3600} +| { "everything":false, "views":[{ "bank_id":"gh.29.uk", "account_id":"8ca8a7e4-6d02-40e3-a129-0b2bf89de9f0", "view_id":${Constant.SYSTEM_OWNER_VIEW_ID}], "entitlements":[{ "bank_id":"gh.29.uk", "role_name":"CanGetCustomer" }], "consumer_id":"7uy8a7e4-6d02-40e3-a129-0b2bf89de8uh", "phone_number":"+44 07972 444 876", "valid_from":"2022-04-29T10:40:03Z", "time_to_live":3600} | |Headers: | diff --git a/obp-api/src/main/scala/code/api/util/NewStyle.scala b/obp-api/src/main/scala/code/api/util/NewStyle.scala index c7c488e497..8932ccb83d 100644 --- a/obp-api/src/main/scala/code/api/util/NewStyle.scala +++ b/obp-api/src/main/scala/code/api/util/NewStyle.scala @@ -80,6 +80,7 @@ import code.endpointMapping.{EndpointMappingProvider, EndpointMappingT} import code.endpointTag.EndpointTagT import code.util.Helper.MdcLoggable import code.views.system.AccountAccess +import com.openbankproject.commons.model.enums.SuppliedAnswerType import net.liftweb.mapper.By object NewStyle extends MdcLoggable{ @@ -408,7 +409,7 @@ object NewStyle extends MdcLoggable{ } def getBankAccountByAccountId(accountId : AccountId, callContext: Option[CallContext]) : OBPReturnType[BankAccount] = { - Connector.connector.vend.getBankAccountByAccountId(accountId : AccountId, callContext: Option[CallContext]) map { i => + Connector.connector.vend.checkBankAccountExists(BankId(defaultBankId), accountId : AccountId, callContext: Option[CallContext]) map { i => (unboxFullOrFail(i._1, callContext,s"$BankAccountNotFoundByAccountId Current account_id is $accountId", 404 ), i._2) } } @@ -1300,9 +1301,8 @@ object NewStyle extends MdcLoggable{ } } - - def validateChallengeAnswer(challengeId: String, hashOfSuppliedAnswer: String, callContext: Option[CallContext]): OBPReturnType[Boolean] = - Connector.connector.vend.validateChallengeAnswer(challengeId: String, hashOfSuppliedAnswer: String, callContext: Option[CallContext]) map { i => + def validateChallengeAnswer(challengeId: String, suppliedAnswer: String, suppliedAnswerType:SuppliedAnswerType.Value, callContext: Option[CallContext]): OBPReturnType[Boolean] = + Connector.connector.vend.validateChallengeAnswerV2(challengeId, suppliedAnswer, suppliedAnswerType, callContext) map { i => (unboxFullOrFail(i._1, callContext, s"${ InvalidChallengeAnswer .replace("answer may be expired.", s"answer may be expired (${transactionRequestChallengeTtl} seconds).") @@ -1330,6 +1330,7 @@ object NewStyle extends MdcLoggable{ (unboxFullOrFail(i._1, callContext, s"$InvalidConnectorResponse() "), i._2) } + //At moment this method is used for Berlin Group Payments def validateChallengeAnswerC2( challengeType: ChallengeType.Value, transactionRequestId: Option[String], @@ -1358,6 +1359,8 @@ object NewStyle extends MdcLoggable{ } } } + + //At moment this method is used for Berlin Group SigningBasketsApi.scala def validateChallengeAnswerC3( challengeType: ChallengeType.Value, transactionRequestId: Option[String], diff --git a/obp-api/src/main/scala/code/api/util/migration/Migration.scala b/obp-api/src/main/scala/code/api/util/migration/Migration.scala index ed5458dfb2..03c6f24c11 100644 --- a/obp-api/src/main/scala/code/api/util/migration/Migration.scala +++ b/obp-api/src/main/scala/code/api/util/migration/Migration.scala @@ -584,8 +584,15 @@ object Migration extends MdcLoggable { val tableName = table.dbTableName val sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss_SSS") val resultDate = new Date(System.currentTimeMillis()) - DB.prepareStatement(s"CREATE TABLE ${tableName}_backup_${sdf.format(resultDate)} AS (SELECT * FROM $tableName); ", conn){ - stmt => stmt.executeQuery() + val dbDriver = APIUtil.getPropsValue("db.driver","org.h2.Driver") + val sqlQuery = if (dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver")) { + s"SELECT * INTO ${tableName}_backup_${sdf.format(resultDate)} FROM $tableName;" + }else{ + s"CREATE TABLE ${tableName}_backup_${sdf.format(resultDate)} AS (SELECT * FROM $tableName);" + } + DB.prepareStatement(sqlQuery, conn){ + stmt => stmt.execute() //statement.executeQuery() expects a resultset and you don't get one. + // Use statement.execute() for an ALTER-statement to avoid this issue. } true } catch { diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationInfoOfAccoutHolders.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationInfoOfAccoutHolders.scala index 321f33bf87..35f18d283f 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationInfoOfAccoutHolders.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationInfoOfAccoutHolders.scala @@ -1,5 +1,6 @@ package code.api.util.migration +import code.api.Constant import java.time.format.DateTimeFormatter import java.time.{ZoneId, ZonedDateTime} @@ -42,7 +43,7 @@ object BankAccountHoldersAndOwnerViewAccess { ownerViewAccess = AccountAccess.findAll( By(AccountAccess.bank_id, bankId), By(AccountAccess.account_id, accountId), - ByList(AccountAccess.view_id, List("owner", "_owner")) + ByList(AccountAccess.view_id, List(Constant.SYSTEM_OWNER_VIEW_ID, "_owner")) ) } yield { (bankId, accountId, ownerViewAccess.size > 0) diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfAuthUser.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfAuthUser.scala index 668764de7b..037b3ed9bc 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfAuthUser.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfAuthUser.scala @@ -27,10 +27,10 @@ object MigrationOfAuthUser { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => s""" - |${Helper.dropIndexIfExists(value,"authUser", "authuser_username_provider")} + |${Helper.dropIndexIfExists(dbDriver,"authUser", "authuser_username_provider")} | |ALTER TABLE authuser ALTER COLUMN username varchar(100); |ALTER TABLE authuser ALTER COLUMN provider varchar(100); @@ -38,7 +38,7 @@ object MigrationOfAuthUser { |ALTER TABLE authuser ALTER COLUMN lastname varchar(100); |ALTER TABLE authuser ALTER COLUMN email varchar(100); | - |${Helper.createIndexIfNotExists(value,"authUser", "authuser_username_provider")} + |${Helper.createIndexIfNotExists(dbDriver,"authUser", "authuser_username_provider")} |""".stripMargin case _ => () => diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfCustomerAttributes.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfCustomerAttributes.scala index 908ffde0f1..624aebd205 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfCustomerAttributes.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfCustomerAttributes.scala @@ -27,9 +27,9 @@ object MigrationOfCustomerAttributes { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => "ALTER TABLE mappedcustomerattribute ALTER COLUMN mvalue varchar(2000);" - case Full(value) if value.contains("com.mysql.cj.jdbc.Driver") => // MySQL + case Full(dbDriver) if dbDriver.contains("com.mysql.cj.jdbc.Driver") => // MySQL () => "ALTER TABLE mappedcustomerattribute MODIFY COLUMN mvalue varchar(2000);" case _ => () => "ALTER TABLE mappedcustomerattribute ALTER COLUMN mvalue type varchar(2000);" diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedConsent.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedConsent.scala index 97407ddfb1..412b279320 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedConsent.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedConsent.scala @@ -26,9 +26,9 @@ object MigrationOfMappedConsent { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => "ALTER TABLE mappedconsent ALTER COLUMN mjsonwebtoken text;" - case Full(value) if value.contains("com.mysql.cj.jdbc.Driver") => // MySQL + case Full(dbDriver) if dbDriver.contains("com.mysql.cj.jdbc.Driver") => // MySQL () => "ALTER TABLE mappedconsent MODIFY COLUMN mjsonwebtoken TEXT;" case _ => () => "ALTER TABLE mappedconsent ALTER COLUMN mjsonwebtoken type text;" @@ -66,11 +66,11 @@ object MigrationOfMappedConsent { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => """ALTER TABLE mappedconsent ALTER COLUMN mchallenge varchar(50); |""".stripMargin - case Full(value) if value.contains("com.mysql.cj.jdbc.Driver") => // MySQL + case Full(dbDriver) if dbDriver.contains("com.mysql.cj.jdbc.Driver") => // MySQL () => """ALTER TABLE mappedconsent MODIFY COLUMN mchallenge varchar(50); |""".stripMargin @@ -112,7 +112,7 @@ object MigrationOfMappedConsent { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => """ALTER TABLE mappedconsent ALTER COLUMN mstatus varchar(40); |""".stripMargin diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedExpectedChallengeAnswerFieldLength.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedExpectedChallengeAnswerFieldLength.scala index ef5de1ecd7..cace88f422 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedExpectedChallengeAnswerFieldLength.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedExpectedChallengeAnswerFieldLength.scala @@ -27,7 +27,7 @@ object MigrationOfMappedExpectedChallengeAnswerFieldLength { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => """ |ALTER TABLE ExpectedChallengeAnswer ALTER COLUMN ChallengeType varchar(100); diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedUserAuthContext.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedUserAuthContext.scala index 4ba5df22ad..026539964b 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedUserAuthContext.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedUserAuthContext.scala @@ -26,7 +26,7 @@ object MigrationOfMappedUserAuthContext { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => "DROP INDEX IF EXISTS mappeduserauthcontext_muserid_mkey ON mappeduserauthcontext;" case _ => () => "DROP INDEX IF EXISTS mappeduserauthcontext_muserid_mkey;" diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedUserAuthContextUpdate.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedUserAuthContextUpdate.scala index c8756cdec1..43c4c515e9 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedUserAuthContextUpdate.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMappedUserAuthContextUpdate.scala @@ -26,9 +26,9 @@ object MigrationOfMappedUserAuthContextUpdate { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => "DROP INDEX IF EXISTS mappeduserauthcontextupdate_muserid_mkey ON mappeduserauthcontextupdate;" - case Full(value) if value.contains("com.mysql.cj.jdbc.Driver") => // MySQL + case Full(dbDriver) if dbDriver.contains("com.mysql.cj.jdbc.Driver") => // MySQL () => "DROP INDEX mappeduserauthcontextupdate_muserid_mkey ON mappeduserauthcontextupdate;" case _ => () => "DROP INDEX IF EXISTS mappeduserauthcontextupdate_muserid_mkey;" diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMetricTable.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMetricTable.scala index 8046960966..431de1766a 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfMetricTable.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfMetricTable.scala @@ -27,7 +27,7 @@ object MigrationOfMetricTable { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => """ |ALTER TABLE metric ALTER COLUMN correlationid varchar(256); diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfOpnIDConnectToken.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfOpnIDConnectToken.scala index a6bba3ff24..787f3de480 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfOpnIDConnectToken.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfOpnIDConnectToken.scala @@ -26,9 +26,9 @@ object MigrationOfOpnIDConnectToken { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => "ALTER TABLE openidconnecttoken ALTER COLUMN accesstoken text;" - case Full(value) if value.contains("com.mysql.cj.jdbc.Driver") => + case Full(dbDriver) if dbDriver.contains("com.mysql.cj.jdbc.Driver") => () => "ALTER TABLE openidconnecttoken MODIFY COLUMN accesstoken text;" case _ => () => "ALTER TABLE openidconnecttoken ALTER COLUMN accesstoken type text;" @@ -65,9 +65,9 @@ object MigrationOfOpnIDConnectToken { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => "ALTER TABLE openidconnecttoken ALTER COLUMN refreshtoken text;" - case Full(value) if value.contains("com.mysql.cj.jdbc.Driver") => // MySQL + case Full(dbDriver) if dbDriver.contains("com.mysql.cj.jdbc.Driver") => // MySQL () => "ALTER TABLE openidconnecttoken MODIFY COLUMN refreshtoken text;" case _ => () => "ALTER TABLE openidconnecttoken ALTER COLUMN refreshtoken type text;" diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfProductFee.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfProductFee.scala index f7484682e0..7d9b150525 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfProductFee.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfProductFee.scala @@ -25,7 +25,7 @@ object MigrationOfProductFee { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => """ |ALTER TABLE ProductFee ALTER COLUMN name varchar(100); diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfResourceUser.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfResourceUser.scala index 363d078b86..ee4f04cf6a 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfResourceUser.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfResourceUser.scala @@ -65,7 +65,7 @@ object MigrationOfResourceUser { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => """ALTER TABLE resourceuser ALTER COLUMN email varchar(100); |""".stripMargin diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfResourceUserIsDeleted.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfResourceUserIsDeleted.scala index 7d5fe428e6..3617cf7840 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfResourceUserIsDeleted.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfResourceUserIsDeleted.scala @@ -65,7 +65,7 @@ object MigrationOfResourceUserIsDeleted { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => """ALTER TABLE resourceuser ALTER COLUMN email varchar(100); |""".stripMargin diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfTransactionRequerst.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfTransactionRequerst.scala index 1235728859..0ce0cc0bed 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfTransactionRequerst.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfTransactionRequerst.scala @@ -26,7 +26,7 @@ object MigrationOfTransactionRequerst { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => "ALTER TABLE mappedtransactionrequest ALTER COLUMN mdetails text;" case _ => () => "ALTER TABLE mappedtransactionrequest ALTER COLUMN mdetails type text;" diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfTransactionRequestChallengeChallengeTypeLength.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfTransactionRequestChallengeChallengeTypeLength.scala index 4fbe1a1e5b..3fd11c9f64 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfTransactionRequestChallengeChallengeTypeLength.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfTransactionRequestChallengeChallengeTypeLength.scala @@ -26,7 +26,7 @@ object MigrationOfTransactionRequestChallengeChallengeTypeLength { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => "ALTER TABLE mappedtransactionrequest ALTER COLUMN mChallenge_ChallengeType varchar(100);" case _ => () => "ALTER TABLE mappedtransactionrequest ALTER COLUMN mChallenge_ChallengeType type varchar(100);" diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfUserAttributeNameFieldLength.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfUserAttributeNameFieldLength.scala index d646d61134..3df6666ad1 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfUserAttributeNameFieldLength.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfUserAttributeNameFieldLength.scala @@ -26,7 +26,7 @@ object MigrationOfUserAttributeNameFieldLength { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => """ |ALTER TABLE UserAttribute ALTER COLUMN name varchar(255); diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfUserAuthContextFieldLength.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfUserAuthContextFieldLength.scala index 8025e2c17f..8c7145bae7 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfUserAuthContextFieldLength.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfUserAuthContextFieldLength.scala @@ -26,15 +26,15 @@ object MigrationOfUserAuthContextFieldLength { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => s""" - |${Helper.dropIndexIfExists(value,"mappeduserauthcontext", "mappeduserauthcontext_muserid_mkey_createdat")} + |${Helper.dropIndexIfExists(dbDriver,"mappeduserauthcontext", "mappeduserauthcontext_muserid_mkey_createdat")} | |ALTER TABLE MappedUserAuthContext ALTER COLUMN mKey varchar(4000); |ALTER TABLE MappedUserAuthContext ALTER COLUMN mValue varchar(4000); | - |${Helper.createIndexIfNotExists(value, "mappeduserauthcontext", "mappeduserauthcontext_muserid_mkey_createdat")} + |${Helper.createIndexIfNotExists(dbDriver, "mappeduserauthcontext", "mappeduserauthcontext_muserid_mkey_createdat")} | |""".stripMargin case _ => diff --git a/obp-api/src/main/scala/code/api/util/migration/MigrationOfWebhookUrlFieldLength.scala b/obp-api/src/main/scala/code/api/util/migration/MigrationOfWebhookUrlFieldLength.scala index 3ffa94a9b6..612483f190 100644 --- a/obp-api/src/main/scala/code/api/util/migration/MigrationOfWebhookUrlFieldLength.scala +++ b/obp-api/src/main/scala/code/api/util/migration/MigrationOfWebhookUrlFieldLength.scala @@ -30,7 +30,7 @@ object MigrationOfWebhookUrlFieldLength { val executedSql = DbFunction.maybeWrite(true, Schemifier.infoF _) { APIUtil.getPropsValue("db.driver") match { - case Full(value) if value.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => + case Full(dbDriver) if dbDriver.contains("com.microsoft.sqlserver.jdbc.SQLServerDriver") => () => """ |ALTER TABLE SystemAccountNotificationWebhook ALTER COLUMN Url varchar(1024); diff --git a/obp-api/src/main/scala/code/api/v2_1_0/APIMethods210.scala b/obp-api/src/main/scala/code/api/v2_1_0/APIMethods210.scala index 6b6de47b0e..81386e4f47 100644 --- a/obp-api/src/main/scala/code/api/v2_1_0/APIMethods210.scala +++ b/obp-api/src/main/scala/code/api/v2_1_0/APIMethods210.scala @@ -1,7 +1,6 @@ package code.api.v2_1_0 import java.util.Date - import code.TransactionTypes.TransactionType import code.api.util import code.api.util.ApiTag._ @@ -32,7 +31,7 @@ import code.util.Helper.booleanToBox import code.views.Views import code.views.system.ViewDefinition import com.openbankproject.commons.model._ -import com.openbankproject.commons.model.enums.ChallengeType +import com.openbankproject.commons.model.enums.{ChallengeType, SuppliedAnswerType} import com.openbankproject.commons.util.ApiVersion import net.liftweb.json.Extraction import net.liftweb.util.Helpers.tryo @@ -681,7 +680,7 @@ trait APIMethods210 { existingTransactionRequest.challenge.challenge_type == ChallengeType.OBP_TRANSACTION_REQUEST_CHALLENGE.toString } - (isChallengeAnswerValidated, callContext) <- NewStyle.function.validateChallengeAnswer(challengeAnswerJson.id, challengeAnswerJson.answer, callContext) + (isChallengeAnswerValidated, callContext) <- NewStyle.function.validateChallengeAnswer(challengeAnswerJson.id, challengeAnswerJson.answer, SuppliedAnswerType.PLAIN_TEXT_VALUE, callContext) _ <- Helper.booleanToFuture(s"${InvalidChallengeAnswer .replace("answer may be expired.", s"answer may be expired (${transactionRequestChallengeTtl} seconds).") diff --git a/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala b/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala index 066746bb05..251bff491a 100644 --- a/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala +++ b/obp-api/src/main/scala/code/api/v3_1_0/APIMethods310.scala @@ -1925,7 +1925,7 @@ trait APIMethods310 { cc => implicit val ec = EndpointContext(Some(cc)) for { (Full(u), callContext) <- authenticatedAccess(cc) - _ <- NewStyle.function.hasEntitlement("", userId, canRefreshUser, callContext) + _ <- NewStyle.function.hasEntitlement("", u.userId, canRefreshUser, callContext) startTime <- Future{Helpers.now} (user, callContext) <- NewStyle.function.findByUserId(userId, callContext) _ <- AuthUser.refreshUser(user, callContext) @@ -3246,7 +3246,7 @@ trait APIMethods310 { | { | "bank_id": "GENODEM1GLS", | "account_id": "8ca8a7e4-6d02-40e3-a129-0b2bf89de9f0", - | "view_id": "owner" + | "view_id": "${Constant.SYSTEM_OWNER_VIEW_ID}" | } | ], | "entitlements": [ @@ -3317,7 +3317,7 @@ trait APIMethods310 { | { | "bank_id": "GENODEM1GLS", | "account_id": "8ca8a7e4-6d02-40e3-a129-0b2bf89de9f0", - | "view_id": "owner" + | "view_id": "${Constant.SYSTEM_OWNER_VIEW_ID}" | } | ], | "entitlements": [ @@ -3396,7 +3396,7 @@ trait APIMethods310 { | { | "bank_id": "GENODEM1GLS", | "account_id": "8ca8a7e4-6d02-40e3-a129-0b2bf89de9f0", - | "view_id": "owner" + | "view_id": "${Constant.SYSTEM_OWNER_VIEW_ID}" | } | ], | "entitlements": [ @@ -3475,7 +3475,7 @@ trait APIMethods310 { | { | "bank_id": "GENODEM1GLS", | "account_id": "8ca8a7e4-6d02-40e3-a129-0b2bf89de9f0", - | "view_id": "owner" + | "view_id": "${Constant.SYSTEM_OWNER_VIEW_ID}" | } | ], | "entitlements": [ diff --git a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala index 5201455aa1..aa29368675 100644 --- a/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala +++ b/obp-api/src/main/scala/code/api/v4_0_0/APIMethods400.scala @@ -86,7 +86,7 @@ import com.openbankproject.commons.dto.GetProductsParam import com.openbankproject.commons.model.enums.ChallengeType.OBP_TRANSACTION_REQUEST_CHALLENGE import com.openbankproject.commons.model.enums.DynamicEntityOperation._ import com.openbankproject.commons.model.enums.{TransactionRequestStatus, _} -import com.openbankproject.commons.model.{ListResult, _} +import com.openbankproject.commons.model._ import com.openbankproject.commons.util.{ApiVersion, JsonUtils, ScannedApiVersion} import deletion._ import net.liftweb.common._ @@ -95,7 +95,7 @@ import net.liftweb.http.{JsonResponse, Req, S} import net.liftweb.json.JsonAST.JValue import net.liftweb.json.JsonDSL._ import net.liftweb.json.Serialization.write -import net.liftweb.json.{compactRender, prettyRender, _} +import net.liftweb.json._ import net.liftweb.mapper.By import net.liftweb.util.Helpers.{now, tryo} import net.liftweb.util.Mailer.{From, PlainMailBodyType, Subject, To, XHTMLMailBodyType} @@ -1470,7 +1470,7 @@ trait APIMethods400 extends MdcLoggable { case "transaction-request-types" :: "CARD" :: "transaction-requests" :: Nil JsonPost json -> _ => cc => implicit val ec = EndpointContext(Some(cc)) val transactionRequestType = TransactionRequestType("CARD") - createTransactionRequest(BankId(""), AccountId(""), ViewId("owner"), transactionRequestType, json) + createTransactionRequest(BankId(""), AccountId(""), ViewId(Constant.SYSTEM_OWNER_VIEW_ID), transactionRequestType, json) } @@ -1637,7 +1637,7 @@ trait APIMethods400 extends MdcLoggable { case _ => for { - (challengeAnswerIsValidated, callContext) <- NewStyle.function.validateChallengeAnswer(challengeAnswerJson.id, challengeAnswerJson.answer, callContext) + (challengeAnswerIsValidated, callContext) <- NewStyle.function.validateChallengeAnswer(challengeAnswerJson.id, challengeAnswerJson.answer, SuppliedAnswerType.PLAIN_TEXT_VALUE,callContext) _ <- Helper.booleanToFuture(s"${InvalidChallengeAnswer .replace("answer may be expired.",s"answer may be expired (${transactionRequestChallengeTtl} seconds).") @@ -8341,7 +8341,7 @@ trait APIMethods400 extends MdcLoggable { createdByUserId=u.userId, thisBankId=bankId.value, thisAccountId=accountId.value, - thisViewId = "owner", + thisViewId = Constant.SYSTEM_OWNER_VIEW_ID, otherAccountRoutingScheme=postJson.other_account_routing_scheme, otherAccountRoutingAddress=postJson.other_account_routing_address, otherAccountSecondaryRoutingScheme=postJson.other_account_secondary_routing_scheme, diff --git a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala index 37126451e6..4bbf563a27 100644 --- a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala +++ b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala @@ -2703,9 +2703,9 @@ trait APIMethods510 { _ <- Helper.booleanToFuture(failMsg = InvalidCustomViewFormat + s"Current TARGET_VIEW_ID (${targetViewId.value})", cc = callContext) { isValidCustomViewId(targetViewId.value) } - failmsg = s"${ErrorMessages.ViewDoesNotPermitAccess} You need the `${StringHelpers.snakify(nameOf(view.canSeeAvailableViewsForBankAccount))}`permission on any your views. Current VIEW_ID (${viewId.value})" + failmsg = s"${ErrorMessages.ViewDoesNotPermitAccess} You need the `${StringHelpers.snakify(nameOf(view.canGetCustomView))}`permission on any your views. Current VIEW_ID (${viewId.value})" _ <- Helper.booleanToFuture(failmsg, cc = callContext) { - view.canSeeAvailableViewsForBankAccount + view.canGetCustomView } targetView <- NewStyle.function.customView(targetViewId, BankIdAccountId(bankId, accountId), callContext) } yield { diff --git a/obp-api/src/main/scala/code/bankconnectors/Connector.scala b/obp-api/src/main/scala/code/bankconnectors/Connector.scala index 02096bb748..a63916fe2c 100644 --- a/obp-api/src/main/scala/code/bankconnectors/Connector.scala +++ b/obp-api/src/main/scala/code/bankconnectors/Connector.scala @@ -42,6 +42,7 @@ import com.openbankproject.commons.ExecutionContext.Implicits.global import com.openbankproject.commons.dto.{CustomerAndAttribute, GetProductsParam, InBoundTrait, ProductCollectionItemsTree} import com.openbankproject.commons.model.enums.StrongCustomerAuthentication.SCA import com.openbankproject.commons.model.enums.StrongCustomerAuthenticationStatus.SCAStatus +import com.openbankproject.commons.model.enums.SuppliedAnswerType import com.openbankproject.commons.model.enums._ import com.openbankproject.commons.model.{AccountApplication, Bank, CounterpartyTrait, CustomerAddress, DirectDebitTrait, FXRate, Product, ProductCollection, ProductCollectionItem, TaxResidence, TransactionRequestStatus, TransactionRequestTypeCharge, UserAuthContext, UserAuthContextUpdate, _} import com.openbankproject.commons.util.Functions.lazyValue @@ -437,8 +438,11 @@ trait Connector extends MdcLoggable { callContext: Option[CallContext]) : OBPReturnType[Box[List[ChallengeTrait]]]= Future{(Failure(setUnimplementedError), callContext)} // Validates an answer for a challenge and returns if the answer is correct or not + @deprecated("Please use @validateChallengeAnswerV2 instead ","01.07.2024") def validateChallengeAnswer(challengeId: String, hashOfSuppliedAnswer: String, callContext: Option[CallContext]): OBPReturnType[Box[Boolean]] = Future{(Full(true), callContext)} + def validateChallengeAnswerV2(challengeId: String, suppliedAnswer: String, suppliedAnswerType:SuppliedAnswerType.Value, callContext: Option[CallContext]): OBPReturnType[Box[Boolean]] = Future{(Full(true), callContext)} + def allChallengesSuccessfullyAnswered( bankId: BankId, accountId: AccountId, @@ -544,7 +548,6 @@ trait Connector extends MdcLoggable { //This one just added the callContext in parameters. def getBankAccountLegacy(bankId : BankId, accountId : AccountId, callContext: Option[CallContext]) : Box[(BankAccount, Option[CallContext])]= Failure(setUnimplementedError) - def getBankAccountByAccountId(accountId : AccountId, callContext: Option[CallContext]) : OBPReturnType[Box[BankAccount]]= Future{(Failure(setUnimplementedError),callContext)} def getBankAccountByIban(iban : String, callContext: Option[CallContext]) : OBPReturnType[Box[BankAccount]]= Future{(Failure(setUnimplementedError),callContext)} def getBankAccountByRoutingLegacy(bankId: Option[BankId], scheme : String, address : String, callContext: Option[CallContext]) : Box[(BankAccount, Option[CallContext])]= Failure(setUnimplementedError) def getBankAccountByRouting(bankId: Option[BankId], scheme : String, address : String, callContext: Option[CallContext]) : OBPReturnType[Box[BankAccount]]= Future{(Failure(setUnimplementedError), callContext)} @@ -1582,7 +1585,7 @@ trait Connector extends MdcLoggable { @deprecated("we create new code.model.dataAccess.AuthUser.updateUserAccountViews for June2017 connector, try to use new instead of this","11 September 2018") def setAccountHolder(owner : String, bankId: BankId, accountId: AccountId, account_owners: List[String]) : Unit = { // if (account_owners.contains(owner)) { // No need for now, fix it later - val resourceUserOwner = Users.users.vend.getUserByUserName(localIdentityProvider, owner) + val resourceUserOwner = Users.users.vend.getUserByProviderAndUsername(localIdentityProvider, owner) resourceUserOwner match { case Full(owner) => { if ( ! accountOwnerExists(owner, bankId, accountId).openOrThrowException(attemptedToOpenAnEmptyBox)) { diff --git a/obp-api/src/main/scala/code/bankconnectors/ConnectorBuilderUtil.scala b/obp-api/src/main/scala/code/bankconnectors/ConnectorBuilderUtil.scala index 70610ebaec..95d7d4ed9f 100644 --- a/obp-api/src/main/scala/code/bankconnectors/ConnectorBuilderUtil.scala +++ b/obp-api/src/main/scala/code/bankconnectors/ConnectorBuilderUtil.scala @@ -234,6 +234,7 @@ object ConnectorBuilderUtil { "getBankAccountsForUser", "getUser", "getBankAccountsBalances", + "getBankAccountBalances", "getCoreBankAccounts", "getBankAccountsHeld", "getCounterpartyTrait", @@ -372,6 +373,7 @@ object ConnectorBuilderUtil { "validateAndCheckIbanNumber", "validateChallengeAnswerC2", "validateChallengeAnswerC3", + "validateChallengeAnswerV2", "getCounterpartyByIbanAndBankAccountId", ).distinct diff --git a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala index ac64a799ec..128c26d595 100644 --- a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala +++ b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala @@ -10,7 +10,7 @@ import code.accountattribute.AccountAttributeX import code.accountholders.{AccountHolders, MapperAccountHolders} import code.api.BerlinGroup.{AuthenticationType, ScaStatus} import code.api.Constant -import code.api.Constant.{INCOMING_SETTLEMENT_ACCOUNT_ID, OUTGOING_SETTLEMENT_ACCOUNT_ID, SYSTEM_ACCOUNTANT_VIEW_ID, SYSTEM_AUDITOR_VIEW_ID, SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID, SYSTEM_OWNER_VIEW_ID, localIdentityProvider} +import code.api.Constant._ import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON import code.api.attributedefinition.{AttributeDefinition, AttributeDefinitionDI} import code.api.cache.Caching @@ -53,7 +53,7 @@ import code.metadata.transactionimages.TransactionImages import code.metadata.wheretags.WhereTags import code.metrics.MappedMetric import code.model._ -import code.model.dataAccess.AuthUser.findAuthUserByUsernameLocally +import code.model.dataAccess.AuthUser.findAuthUserByUsernameLocallyLegacy import code.model.dataAccess._ import code.productAttributeattribute.MappedProductAttribute import code.productattribute.ProductAttributeX @@ -81,6 +81,7 @@ import com.openbankproject.commons.model.enums.ChallengeType.OBP_TRANSACTION_REQ import com.openbankproject.commons.model.enums.DynamicEntityOperation._ import com.openbankproject.commons.model.enums.StrongCustomerAuthentication.SCA import com.openbankproject.commons.model.enums.StrongCustomerAuthenticationStatus.SCAStatus +import com.openbankproject.commons.model.enums.SuppliedAnswerType import com.openbankproject.commons.model.enums.{TransactionRequestStatus, _} import com.openbankproject.commons.model.{AccountApplication, AccountAttribute, ConsentImplicitSCAT, DirectDebitTrait, FXRate, Product, ProductAttribute, ProductCollectionItem, TaxResidence, TransactionRequestCommonBodyJSON, _} import com.tesobe.CacheKeyFromArguments @@ -486,6 +487,13 @@ object LocalMappedConnector extends Connector with MdcLoggable { override def getChallenge(challengeId: String, callContext: Option[CallContext]): OBPReturnType[Box[ChallengeTrait]] = Future {(Challenges.ChallengeProvider.vend.getChallenge(challengeId), callContext)} + override def validateChallengeAnswerV2(challengeId: String, suppliedAnswer: String, suppliedAnswerType:SuppliedAnswerType, callContext: Option[CallContext]): OBPReturnType[Box[Boolean]] = + Future { + val userId = callContext.map(_.user.map(_.userId).openOrThrowException(s"$UserNotLoggedIn Can not find the userId here.")) + //In OBP, we only validateChallenge with SuppliedAnswerType.PLAN_TEXT, + (Full(Challenges.ChallengeProvider.vend.validateChallenge(challengeId, suppliedAnswer, userId).isDefined), callContext) + } + override def validateChallengeAnswer(challengeId: String, hashOfSuppliedAnswer: String, callContext: Option[CallContext]): OBPReturnType[Box[Boolean]] = Future { val userId = callContext.map(_.user.map(_.userId).openOrThrowException(s"$UserNotLoggedIn Can not find the userId here.")) @@ -610,7 +618,7 @@ object LocalMappedConnector extends Connector with MdcLoggable { */ override def getBankAccountsForUserLegacy(provider: String, username:String, callContext: Option[CallContext]): Box[(List[InboundAccount], Option[CallContext])] = { //1st: get the accounts from userAuthContext - val viewsToGenerate = List(SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID,SYSTEM_OWNER_VIEW_ID) //TODO, so far only set the `owner` view, later need to simulate other views. + val viewsToGenerate = List(SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID,SYSTEM_OWNER_VIEW_ID, SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID) //TODO, so far only set the `owner` view, later need to simulate other views. val user = Users.users.vend.getUserByProviderId(provider, username).getOrElse(throw new RuntimeException(s"$RefreshUserError at getBankAccountsForUserLegacy($username, ${callContext})")) val userId = user.userId tryo{net.liftweb.common.Logger(this.getClass).debug(s"getBankAccountsForUser.user says: provider($provider), username($username)")} @@ -803,16 +811,6 @@ object LocalMappedConnector extends Connector with MdcLoggable { getBankAccountCommon(bankId, accountId, callContext) } - override def getBankAccountByAccountId(accountId : AccountId, callContext: Option[CallContext]): OBPReturnType[Box[BankAccount]] = Future { - getBankAccountByAccountIdLegacy(accountId : AccountId, callContext: Option[CallContext]) - } - - def getBankAccountByAccountIdLegacy(accountId : AccountId, callContext: Option[CallContext]): Box[(BankAccount, Option[CallContext])] = { - MappedBankAccount.find( - By(MappedBankAccount.theAccountId, accountId.value) - ).map(bankAccount => (bankAccount, callContext)) - } - override def getBankAccountByIban(iban: String, callContext: Option[CallContext]): OBPReturnType[Box[BankAccount]] = Future { getBankAccountByRoutingLegacy(None, "IBAN", iban, callContext) } @@ -5696,7 +5694,7 @@ object LocalMappedConnector extends Connector with MdcLoggable { @deprecated("we create new code.model.dataAccess.AuthUser.updateUserAccountViews for June2017 connector, try to use new instead of this", "11 September 2018") override def setAccountHolder(owner: String, bankId: BankId, accountId: AccountId, account_owners: List[String]): Unit = { // if (account_owners.contains(owner)) { // No need for now, fix it later - val resourceUserOwner = Users.users.vend.getUserByUserName(localIdentityProvider, owner) + val resourceUserOwner = Users.users.vend.getUserByProviderAndUsername(localIdentityProvider, owner) resourceUserOwner match { case Full(owner) => { if (!accountOwnerExists(owner, bankId, accountId).openOrThrowException(attemptedToOpenAnEmptyBox)) { @@ -5794,7 +5792,7 @@ object LocalMappedConnector extends Connector with MdcLoggable { //NOTE: this method is not for mapped connector, we put it here for the star default implementation. // : we call that method only when we set external authentication and provider is not OBP-API override def checkExternalUserExists(username: String, callContext: Option[CallContext]): Box[InboundExternalUser] = { - findAuthUserByUsernameLocally(username).map(user => + findAuthUserByUsernameLocallyLegacy(username).map(user => InboundExternalUser(aud = "", exp = "", iat = "", diff --git a/obp-api/src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala b/obp-api/src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala index 9ab651e8e6..b5468c3e7b 100644 --- a/obp-api/src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala +++ b/obp-api/src/main/scala/code/bankconnectors/storedprocedure/StoredProcedureConnector_vDec2019.scala @@ -75,7 +75,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { val connectorName = "stored_procedure_vDec2019" //---------------- dynamic start -------------------please don't modify this line -// ---------- created on 2024-01-29T13:58:37Z +// ---------- created on 2024-07-01T13:40:08Z messageDocs += getAdapterInfoDoc def getAdapterInfoDoc = MessageDoc( @@ -434,6 +434,34 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { response.map(convertToTuple[Boolean](callContext)) } + messageDocs += validateChallengeAnswerV2Doc + def validateChallengeAnswerV2Doc = MessageDoc( + process = "obp.validateChallengeAnswerV2", + messageFormat = messageFormat, + description = "Validate Challenge Answer V2", + outboundTopic = None, + inboundTopic = None, + exampleOutboundMessage = ( + OutBoundValidateChallengeAnswerV2(outboundAdapterCallContext=MessageDocsSwaggerDefinitions.outboundAdapterCallContext, + challengeId=challengeIdExample.value, + suppliedAnswer="string", + suppliedAnswerType=com.openbankproject.commons.model.enums.SuppliedAnswerType.example) + ), + exampleInboundMessage = ( + InBoundValidateChallengeAnswerV2(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext, + status=MessageDocsSwaggerDefinitions.inboundStatus, + data=true) + ), + adapterImplementation = Some(AdapterImplementation("- Core", 1)) + ) + + override def validateChallengeAnswerV2(challengeId: String, suppliedAnswer: String, suppliedAnswerType: SuppliedAnswerType.Value, callContext: Option[CallContext]): OBPReturnType[Box[Boolean]] = { + import com.openbankproject.commons.dto.{InBoundValidateChallengeAnswerV2 => InBound, OutBoundValidateChallengeAnswerV2 => OutBound} + val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, challengeId, suppliedAnswer, suppliedAnswerType) + val response: Future[Box[InBound]] = sendRequest[InBound]("obp_validate_challenge_answer_v2", req, callContext) + response.map(convertToTuple[Boolean](callContext)) + } + messageDocs += validateChallengeAnswerC2Doc def validateChallengeAnswerC2Doc = MessageDoc( process = "obp.validateChallengeAnswerC2", @@ -1051,6 +1079,43 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { response.map(convertToTuple[AccountsBalances](callContext)) } + messageDocs += getBankAccountBalancesDoc + def getBankAccountBalancesDoc = MessageDoc( + process = "obp.getBankAccountBalances", + messageFormat = messageFormat, + description = "Get Bank Account Balances", + outboundTopic = None, + inboundTopic = None, + exampleOutboundMessage = ( + OutBoundGetBankAccountBalances(outboundAdapterCallContext=MessageDocsSwaggerDefinitions.outboundAdapterCallContext, + bankIdAccountId= BankIdAccountId(bankId=BankId(bankIdExample.value), + accountId=AccountId(accountIdExample.value))) + ), + exampleInboundMessage = ( + InBoundGetBankAccountBalances(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext, + status=MessageDocsSwaggerDefinitions.inboundStatus, + data= AccountBalances(id=idExample.value, + label=labelExample.value, + bankId=bankIdExample.value, + accountRoutings=List( AccountRouting(scheme=accountRoutingSchemeExample.value, + address=accountRoutingAddressExample.value)), + balances=List( BankAccountBalance(balance= AmountOfMoney(currency=balanceCurrencyExample.value, + amount=balanceAmountExample.value), + balanceType="string")), + overallBalance= AmountOfMoney(currency=currencyExample.value, + amount=amountExample.value), + overallBalanceDate=toDate(overallBalanceDateExample))) + ), + adapterImplementation = Some(AdapterImplementation("- Core", 1)) + ) + + override def getBankAccountBalances(bankIdAccountId: BankIdAccountId, callContext: Option[CallContext]): OBPReturnType[Box[AccountBalances]] = { + import com.openbankproject.commons.dto.{InBoundGetBankAccountBalances => InBound, OutBoundGetBankAccountBalances => OutBound} + val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, bankIdAccountId) + val response: Future[Box[InBound]] = sendRequest[InBound]("obp_get_bank_account_balances", req, callContext) + response.map(convertToTuple[AccountBalances](callContext)) + } + messageDocs += getCoreBankAccountsDoc def getCoreBankAccountsDoc = MessageDoc( process = "obp.getCoreBankAccounts", @@ -6587,8 +6652,8 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable { response.map(convertToTuple[Boolean](callContext)) } -// ---------- created on 2024-01-29T13:58:37Z -//---------------- dynamic end ---------------------please don't modify this line +// ---------- created on 2024-07-01T13:40:08Z +//---------------- dynamic end ---------------------please don't modify this line private val availableOperation = DynamicEntityOperation.values.map(it => s""""$it"""").mkString("[", ", ", "]") diff --git a/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala b/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala index 2ca46c5709..412797bc83 100644 --- a/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala +++ b/obp-api/src/main/scala/code/bankconnectors/vSept2018/KafkaMappedConnector_vSept2018.scala @@ -23,6 +23,7 @@ Osloerstrasse 16/17 Berlin 13359, Germany */ +import code.api.Constant import java.text.SimpleDateFormat import java.util.Date import java.util.UUID.randomUUID @@ -102,7 +103,7 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc basicUserAuthContexts <- cc.gatewayLoginRequestPayload match { case None => for{ - user <- Users.users.vend.getUserByUserName(provider,username) ?~! "getAuthInfoFirstCbsCall: can not get user object here." + user <- Users.users.vend.getUserByProviderAndUsername(provider,username) ?~! "getAuthInfoFirstCbsCall: can not get user object here." userAuthContexts<- UserAuthContextProvider.userAuthContextProvider.vend.getUserAuthContextsBox(user.userId)?~! "getAuthInfoFirstCbsCall: can not get userAuthContexts object here." basicUserAuthContexts = JsonFactory_vSept2018.createBasicUserAuthContextJson(userAuthContexts) } yield @@ -193,7 +194,7 @@ trait KafkaMappedConnector_vSept2018 extends Connector with KafkaHelper with Mdc generalContext = Option(List(BasicGeneralContext(key = "string", value = "string")))) - val viewBasicExample = ViewBasic("owner","Owner", "This is the owner view") + val viewBasicExample = ViewBasic(Constant.SYSTEM_OWNER_VIEW_ID,Constant.SYSTEM_OWNER_VIEW_ID, "This is the owner view") val internalBasicCustomerExample = InternalBasicCustomer( bankId = ExampleValue.bankIdExample.value, diff --git a/obp-api/src/main/scala/code/model/User.scala b/obp-api/src/main/scala/code/model/User.scala index 10c70b84f4..891cc1f839 100644 --- a/obp-api/src/main/scala/code/model/User.scala +++ b/obp-api/src/main/scala/code/model/User.scala @@ -141,7 +141,7 @@ object UserX { } def findByUserName(provider: String, userName: String) = { - Users.users.vend.getUserByUserName(provider, userName) + Users.users.vend.getUserByProviderAndUsername(provider, userName) } def findByEmail(email: String) = { diff --git a/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala b/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala index 6ba53c07e5..6e2492089f 100644 --- a/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala +++ b/obp-api/src/main/scala/code/model/dataAccess/AuthUser.scala @@ -350,8 +350,8 @@ class AuthUser extends MegaProtoUser[AuthUser] with CreatedUpdated with MdcLogga } } - def getResourceUserByUsername(provider: String, username: String) : Box[User] = { - Users.users.vend.getUserByUserName(provider, username) + def getResourceUserByProviderAndUsername(provider: String, username: String) : Box[User] = { + Users.users.vend.getUserByProviderAndUsername(provider, username) } override def save(): Boolean = { @@ -509,7 +509,7 @@ import net.liftweb.util.Helpers._ Constant.localIdentityProvider else user.provider.get - Users.users.vend.getUserByUserName(provider, user.username.get) + Users.users.vend.getUserByProviderAndUsername(provider, user.username.get) } else if (directLogin.isDefined) // Direct Login DirectLogin.getUser else if (hasDirectLoginHeader(authorization)) // Direct Login Deprecated @@ -591,7 +591,7 @@ import net.liftweb.util.Helpers._ * Overridden to use the hostname set in the props file */ override def sendPasswordReset(name: String) { - findAuthUserByUsernameLocally(name).toList ::: findUsersByEmailLocally(name) map { + findAuthUserByUsernameLocallyLegacy(name).toList ::: findUsersByEmailLocally(name) map { // reason of case parameter name is "u" instead of "user": trait AuthUser have constant mumber name is "user" // So if the follow case paramter name is "user" will cause compile warnings case u if u.validated_? => @@ -655,7 +655,7 @@ import net.liftweb.util.Helpers._ } def grantDefaultEntitlementsToAuthUser(user: TheUserType) = { - tryo{getResourceUserByUsername(user.getProvider(), user.username.get).head.userId} match { + tryo{getResourceUserByProviderAndUsername(user.getProvider(), user.username.get).head.userId} match { case Full(userId)=>APIUtil.grantDefaultEntitlementsToNewUser(userId) case _ => logger.error("Can not getResourceUserByUsername here, so it breaks the grantDefaultEntitlementsToNewUser process.") } @@ -840,7 +840,7 @@ import net.liftweb.util.Helpers._ def getResourceUserId(username: String, password: String): Box[Long] = { - findAuthUserByUsernameLocally(username) match { + findAuthUserByUsernameLocallyLegacy(username) match { // We have a user from the local provider. case Full(user) if (user.getProvider() == Constant.localIdentityProvider) => if ( @@ -918,7 +918,7 @@ import net.liftweb.util.Helpers._ Connector.connector.vend.getUser(name, password) match { case Full(InboundUser(extEmail, extPassword, extUsername)) => { val extProvider = connector - val user = findAuthUserByUsernameLocally(name) match { + val user = findAuthUserByUsernameLocallyLegacy(name) match { // Check if the external user is already created locally case Full(user) if user.validated_? // && user.provider == extProvider @@ -961,7 +961,7 @@ import net.liftweb.util.Helpers._ def checkExternalUserViaConnector(username: String, password: String):Box[AuthUser] = { Connector.connector.vend.checkExternalUserCredentials(username, password, None) match { case Full(InboundExternalUser(aud, exp, iat, iss, sub, azp, email, emailVerified, name, userAuthContexts)) => - val user = findAuthUserByUsernameLocally(sub) match { // Check if the external user is already created locally + val user = findAuthUserByUsernameAndProvider(sub, iss) match { // Check if the external user is already created locally case Full(user) if user.validated_? => // Return existing user if found logger.debug("external user already exists locally, using that one") userAuthContexts match { @@ -1138,7 +1138,7 @@ def restoreSomeSessions(): Unit = { if(passwordEmptyField) S.error("login-form-password-error", Helper.i18n("please.enter.your.password")) case false => - findAuthUserByUsernameLocally(usernameFromGui) match { + findAuthUserByUsernameLocallyLegacy(usernameFromGui) match { case Full(user) if !user.validated_? => S.error(S.?("account.validation.error")) @@ -1275,14 +1275,14 @@ def restoreSomeSessions(): Unit = { if (connector.startsWith("kafka") ) { for { user <- getUserFromConnector(name, password) - u <- Users.users.vend.getUserByUserName(user.getProvider(), name) + u <- Users.users.vend.getUserByProviderAndUsername(user.getProvider(), name) } yield { user } } else { for { user <- checkExternalUserViaConnector(name, password) - u <- Users.users.vend.getUserByUserName(user.getProvider(), name) + u <- Users.users.vend.getUserByProviderAndUsername(user.getProvider(), name) } yield { user } @@ -1296,7 +1296,7 @@ def restoreSomeSessions(): Unit = { def registeredUserHelper(provider: String, username: String) = { if (connector.startsWith("kafka")) { for { - u <- Users.users.vend.getUserByUserName(provider, username) + u <- Users.users.vend.getUserByProviderAndUsername(provider, username) } yield { refreshUserLegacy(u, None) } @@ -1595,7 +1595,8 @@ def restoreSomeSessions(): Unit = { * Only search at the local database. * Please note that provider is implicitly defined i.e. not provided via a parameter */ - def findAuthUserByUsernameLocally(name: String): Box[TheUserType] = { + @deprecated("AuthUser unique key is username and provider, please use @findAuthUserByUsernameAndProvider instead.","06.06.2024") + def findAuthUserByUsernameLocallyLegacy(name: String): Box[TheUserType] = { // 1st try is provider with local_identity_provider or hostname value find(By(this.username, name), By(this.provider, Constant.localIdentityProvider)) // 2nd try is provider with null value @@ -1603,6 +1604,10 @@ def restoreSomeSessions(): Unit = { // 3rd try is provider with empty string value .or(find(By(this.username, name), By(this.provider, ""))) } + + def findAuthUserByUsernameAndProvider(name: String, provider: String): Box[TheUserType] = { + find(By(this.username, name), By(this.provider, provider)) + } def findAuthUserByPrimaryKey(key: Long): Box[TheUserType] = { find(By(this.user, key)) } diff --git a/obp-api/src/main/scala/code/model/dataAccess/MappedView.scala b/obp-api/src/main/scala/code/model/dataAccess/MappedView.scala index b949ab4cb6..c5c3c156b8 100644 --- a/obp-api/src/main/scala/code/model/dataAccess/MappedView.scala +++ b/obp-api/src/main/scala/code/model/dataAccess/MappedView.scala @@ -454,6 +454,9 @@ class ViewImpl extends View with LongKeyedMapper[ViewImpl] with ManyToMany with object canUpdateCustomView_ extends MappedBoolean(this){ override def defaultValue = false } + object canGetCustomView_ extends MappedBoolean(this){ + override def defaultValue = false + } object canRevokeAccessToCustomViews_ extends MappedBoolean(this) { override def defaultValue = false } @@ -582,6 +585,7 @@ class ViewImpl extends View with LongKeyedMapper[ViewImpl] with ManyToMany with def canCreateCustomView: Boolean = canCreateCustomView_.get def canDeleteCustomView: Boolean = canDeleteCustomView_.get def canUpdateCustomView: Boolean = canUpdateCustomView_.get + def canGetCustomView: Boolean = canGetCustomView_.get override def canGrantAccessToCustomViews: Boolean = canGrantAccessToCustomViews_.get override def canRevokeAccessToCustomViews: Boolean = canRevokeAccessToCustomViews_.get diff --git a/obp-api/src/main/scala/code/remotedata/RemotedataUsers.scala b/obp-api/src/main/scala/code/remotedata/RemotedataUsers.scala index 0979fa52b3..58b51e30c8 100644 --- a/obp-api/src/main/scala/code/remotedata/RemotedataUsers.scala +++ b/obp-api/src/main/scala/code/remotedata/RemotedataUsers.scala @@ -50,7 +50,7 @@ object RemotedataUsers extends ObpActorInit with Users { def getUsersByUserIdsFuture(userIds : List[String]) : Future[List[User]] = (actor ? cc.getUsersByUserIdsFuture(userIds)).mapTo[List[User]] - def getUserByUserName(provider : String, userName : String) : Box[ResourceUser] = getValueFromFuture( + def getUserByProviderAndUsername(provider : String, userName : String) : Box[ResourceUser] = getValueFromFuture( (actor ? cc.getUserByUserName(provider, userName)).mapTo[Box[ResourceUser]] ) diff --git a/obp-api/src/main/scala/code/remotedata/RemotedataUsersActor.scala b/obp-api/src/main/scala/code/remotedata/RemotedataUsersActor.scala index 537df1dda6..5a54c7a5db 100644 --- a/obp-api/src/main/scala/code/remotedata/RemotedataUsersActor.scala +++ b/obp-api/src/main/scala/code/remotedata/RemotedataUsersActor.scala @@ -59,11 +59,11 @@ class RemotedataUsersActor extends Actor with ObpActorHelper with MdcLoggable { case cc.getUserByUserName(provider: String, userName: String) => logger.debug("getUserByUserName("+provider + userName +")") - sender ! (mapper.getUserByUserName(provider, userName)) + sender ! (mapper.getUserByProviderAndUsername(provider, userName)) case cc.getUserByUserNameFuture(provider: String, userName: String) => logger.debug("getUserByUserNameFuture("+provider + userName +")") - sender ! (mapper.getUserByUserName(provider, userName)) + sender ! (mapper.getUserByProviderAndUsername(provider, userName)) case cc.getUserByEmail(email: String) => logger.debug("getUserByEmail(" + email +")") diff --git a/obp-api/src/main/scala/code/sandbox/OBPDataImport.scala b/obp-api/src/main/scala/code/sandbox/OBPDataImport.scala index ade31aca4a..d5760d2c94 100644 --- a/obp-api/src/main/scala/code/sandbox/OBPDataImport.scala +++ b/obp-api/src/main/scala/code/sandbox/OBPDataImport.scala @@ -5,7 +5,7 @@ import java.util.UUID import code.accountholders.AccountHolders import code.api.Constant -import code.api.Constant.{SYSTEM_ACCOUNTANT_VIEW_ID, SYSTEM_AUDITOR_VIEW_ID, SYSTEM_FIREHOSE_VIEW_ID, SYSTEM_OWNER_VIEW_ID, SYSTEM_READ_ACCOUNTS_BASIC_VIEW_ID, SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_ACCOUNTS_DETAIL_VIEW_ID, SYSTEM_READ_BALANCES_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_BALANCES_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BASIC_VIEW_ID, SYSTEM_READ_TRANSACTIONS_BERLIN_GROUP_VIEW_ID, SYSTEM_READ_TRANSACTIONS_DEBITS_VIEW_ID, SYSTEM_READ_TRANSACTIONS_DETAIL_VIEW_ID, localIdentityProvider} +import code.api.Constant._ import code.api.util.APIUtil._ import code.api.util.{APIUtil, ApiPropsWithAlias, ErrorMessages} import code.bankconnectors.Connector @@ -125,7 +125,7 @@ trait OBPDataImport extends MdcLoggable { protected def createSaveableUser(u : SandboxUserImport) : Box[Saveable[ResourceUser]] protected def createUsers(toImport : List[SandboxUserImport]) : Box[List[Saveable[ResourceUser]]] = { - val existingResourceUsers = toImport.flatMap(u => Users.users.vend.getUserByUserName(localIdentityProvider, u.user_name)) + val existingResourceUsers = toImport.flatMap(u => Users.users.vend.getUserByProviderAndUsername(localIdentityProvider, u.user_name)) val allUsernames = toImport.map(_.user_name) val duplicateUsernames = allUsernames diff allUsernames.distinct @@ -295,7 +295,7 @@ trait OBPDataImport extends MdcLoggable { accId = AccountId(acc.id) bankId = BankId(acc.bank) //TODO Check the following logic which breaks sandbox tests after ViewsImpl refactoring - //ownerViewDoesNotExist <- Helper.booleanToBox(Views.views.vend.view(ViewUID(ViewId("owner"), bankId, accId)).isEmpty) ?~ { + //ownerViewDoesNotExist <- Helper.booleanToBox(Views.views.vend.view(ViewUID(ViewId(Constant.SYSTEM_OWNER_VIEW_ID), bankId, accId)).isEmpty) ?~ { // s"owner view for account ${acc.id} at bank ${acc.bank} already exists" //} //publicViewDoesNotExist <- Helper.booleanToBox(Views.views.vend.view(ViewUID(ViewId("public"), bankId, accId)).isEmpty) ?~ { diff --git a/obp-api/src/main/scala/code/snippet/UserInvitation.scala b/obp-api/src/main/scala/code/snippet/UserInvitation.scala index eab34b28a2..700b754fa8 100644 --- a/obp-api/src/main/scala/code/snippet/UserInvitation.scala +++ b/obp-api/src/main/scala/code/snippet/UserInvitation.scala @@ -99,7 +99,7 @@ class UserInvitation extends MdcLoggable { else if(userInvitation.map(_.status != "CREATED").getOrElse(false)) showErrorsForStatus() else if(timeDifference.abs.getSeconds > ttl) showErrorsForTtl() else if(AuthUser.currentUser.isDefined) showErrorYouMustBeLoggedOff() - else if(Users.users.vend.getUserByUserName(localIdentityProvider, usernameVar.is).isDefined) showErrorsForUsername() + else if(Users.users.vend.getUserByProviderAndUsername(localIdentityProvider, usernameVar.is).isDefined) showErrorsForUsername() else if(privacyCheckboxVar.is == false) showErrorsForPrivacyConditions() else if(termsCheckboxVar.is == false) showErrorsForTermsAndConditions() else if(personalDataCollectionConsentCountryWaiverList.exists(_.toLowerCase == countryVar.is.toLowerCase) == false && consentForCollectingCheckboxVar.is == false) showErrorsForConsentForCollectingPersonalData() diff --git a/obp-api/src/main/scala/code/userlocks/UserLocksProvider.scala b/obp-api/src/main/scala/code/userlocks/UserLocksProvider.scala index 79148196f4..d020128739 100644 --- a/obp-api/src/main/scala/code/userlocks/UserLocksProvider.scala +++ b/obp-api/src/main/scala/code/userlocks/UserLocksProvider.scala @@ -8,7 +8,7 @@ import net.liftweb.util.Helpers._ object UserLocksProvider extends MdcLoggable { def isLocked(provider: String, username: String): Boolean = { - Users.users.vend.getUserByUserName(provider, username) match { + Users.users.vend.getUserByProviderAndUsername(provider, username) match { case Full(user) => UserLocks.find(By(UserLocks.UserId, user.userId)) match { case Full(_) => true @@ -18,7 +18,7 @@ object UserLocksProvider extends MdcLoggable { } } def lockUser(provider: String, username: String): Box[UserLocks] = { - Users.users.vend.getUserByUserName(provider, username) match { + Users.users.vend.getUserByProviderAndUsername(provider, username) match { case Full(user) => UserLocks.find(By(UserLocks.UserId, user.userId)) match { case Full(userLocks) => @@ -41,7 +41,7 @@ object UserLocksProvider extends MdcLoggable { } } def unlockUser(provider: String, username: String): Box[Boolean] = { - Users.users.vend.getUserByUserName(provider, username) match { + Users.users.vend.getUserByProviderAndUsername(provider, username) match { case Full(user) => UserLocks.find(By(UserLocks.UserId, user.userId)) match { case Full(userLocks) => Some(userLocks.delete_!) diff --git a/obp-api/src/main/scala/code/users/LiftUsers.scala b/obp-api/src/main/scala/code/users/LiftUsers.scala index 2a88ff44b8..585ee1d336 100644 --- a/obp-api/src/main/scala/code/users/LiftUsers.scala +++ b/obp-api/src/main/scala/code/users/LiftUsers.scala @@ -92,7 +92,7 @@ object LiftUsers extends Users with MdcLoggable{ Future(getUsersByUserIds(userIds)) } - override def getUserByUserName(provider : String, userName: String): Box[User] = { + override def getUserByProviderAndUsername(provider : String, userName: String): Box[User] = { ResourceUser.find( By(ResourceUser.provider_, provider), By(ResourceUser.name_, userName) @@ -101,7 +101,7 @@ object LiftUsers extends Users with MdcLoggable{ override def getUserByProviderAndUsernameFuture(provider: String, username: String): Future[Box[User]] = { Future { - getUserByUserName(provider, username) + getUserByProviderAndUsername(provider, username) } } diff --git a/obp-api/src/main/scala/code/users/Users.scala b/obp-api/src/main/scala/code/users/Users.scala index c9ce68ee68..bc586762f9 100644 --- a/obp-api/src/main/scala/code/users/Users.scala +++ b/obp-api/src/main/scala/code/users/Users.scala @@ -42,8 +42,8 @@ trait Users { def getUserByUserIdFuture(userId : String) : Future[Box[User]] def getUsersByUserIdsFuture(userIds : List[String]) : Future[List[User]] - // find ResourceUser by Resourceuser user name - def getUserByUserName(provider: String, userName: String) : Box[User] + // find ResourceUser by Resourceuser username + def getUserByProviderAndUsername(provider: String, userName: String) : Box[User] def getUserByProviderAndUsernameFuture(provider: String, username: String): Future[Box[User]] def getUserByEmail(email: String) : Box[List[ResourceUser]] diff --git a/obp-api/src/main/scala/code/views/MapperViews.scala b/obp-api/src/main/scala/code/views/MapperViews.scala index 9837512ce0..41144c9c57 100644 --- a/obp-api/src/main/scala/code/views/MapperViews.scala +++ b/obp-api/src/main/scala/code/views/MapperViews.scala @@ -618,34 +618,19 @@ object MapperViews extends Views with MdcLoggable { def getOrCreateSystemViewFromCbs(viewId: String): Box[View] = { logger.debug(s"-->getOrCreateSystemViewFromCbs--- start--${viewId} ") - + val ownerView = SYSTEM_OWNER_VIEW_ID.equals(viewId.toLowerCase) - val accountantsView = SYSTEM_ACCOUNTANT_VIEW_ID.equals(viewId.toLowerCase) - val auditorsView = SYSTEM_AUDITOR_VIEW_ID.equals(viewId.toLowerCase) - val standardView = SYSTEM_STANDARD_VIEW_ID.equals(viewId.toLowerCase) - val stageOneView = SYSTEM_STAGE_ONE_VIEW_ID.toLowerCase.equals(viewId.toLowerCase) - val manageCustomViews = SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID.toLowerCase.equals(viewId.toLowerCase) - - val theView = - if (ownerView) - getOrCreateSystemView(SYSTEM_OWNER_VIEW_ID) - else if (accountantsView) - getOrCreateSystemView(SYSTEM_ACCOUNTANT_VIEW_ID) - else if (auditorsView) - getOrCreateSystemView(SYSTEM_AUDITOR_VIEW_ID) - else if (standardView) - getOrCreateSystemView(SYSTEM_STANDARD_VIEW_ID) - else if (stageOneView) - getOrCreateSystemView(SYSTEM_STAGE_ONE_VIEW_ID) - else if (manageCustomViews) - getOrCreateSystemView(SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID) - else { - logger.error(ViewIdNotSupported+ s"Your input viewId is :$viewId") - Failure(ViewIdNotSupported+ s"Your input viewId is :$viewId") - } - + + val theView = if (ownerView) { + getOrCreateSystemView(SYSTEM_OWNER_VIEW_ID) + } else if (ALL_SYSTEM_VIEWS_CREATED_FROM_CBS.contains(viewId)) { + getOrCreateSystemView(viewId) + } else { + val errorMessage = ViewIdNotSupported + code.api.Constant.ALL_SYSTEM_VIEWS_CREATED_FROM_CBS.mkString(", ") + s"Your input viewId is :$viewId" + logger.error(errorMessage) + Failure(errorMessage) + } logger.debug(s"-->getOrCreateSystemViewFromCbs --- finish.${viewId } : ${theView} ") - theView } @@ -735,6 +720,7 @@ object MapperViews extends Views with MdcLoggable { "canCreateCustomView", "canDeleteCustomView", "canUpdateCustomView", + "canGetCustomView", "canSeeViewsWithPermissionsForAllUsers", "canSeeViewsWithPermissionsForOneUser" ) @@ -927,9 +913,6 @@ object MapperViews extends Views with MdcLoggable { .canSeeTransactionRequests_(false) .canSeeTransactionRequestTypes_(false) .canUpdateBankAccountLabel_(false) - .canCreateCustomView_(false) - .canDeleteCustomView_(false) - .canUpdateCustomView_(false) .canSeeViewsWithPermissionsForOneUser_(false) .canSeeViewsWithPermissionsForAllUsers_(false) .canRevokeAccessToCustomViews_(false) @@ -937,6 +920,7 @@ object MapperViews extends Views with MdcLoggable { .canCreateCustomView_(false) .canDeleteCustomView_(false) .canUpdateCustomView_(false) + .canGetCustomView_(false) viewId match { case SYSTEM_OWNER_VIEW_ID | SYSTEM_STANDARD_VIEW_ID => @@ -960,6 +944,7 @@ object MapperViews extends Views with MdcLoggable { .canCreateCustomView_(true) .canDeleteCustomView_(true) .canUpdateCustomView_(true) + .canGetCustomView_(true) case SYSTEM_FIREHOSE_VIEW_ID => entity .isFirehose_(true) @@ -1061,7 +1046,11 @@ object MapperViews extends Views with MdcLoggable { canAddTransactionRequestToAnyAccount_(false). canSeeTransactionRequests_(false). canSeeTransactionRequestTypes_(false). - canUpdateBankAccountLabel_(false) + canUpdateBankAccountLabel_(false). + canCreateCustomView_(false). + canDeleteCustomView_(false). + canUpdateCustomView_(false). + canGetCustomView_(false) } def createAndSaveDefaultPublicCustomView(bankId : BankId, accountId: AccountId, description: String) : Box[View] = { diff --git a/obp-api/src/main/scala/code/views/system/ViewDefinition.scala b/obp-api/src/main/scala/code/views/system/ViewDefinition.scala index 336f03a69d..287f716ff9 100644 --- a/obp-api/src/main/scala/code/views/system/ViewDefinition.scala +++ b/obp-api/src/main/scala/code/views/system/ViewDefinition.scala @@ -325,6 +325,9 @@ class ViewDefinition extends View with LongKeyedMapper[ViewDefinition] with Many object canUpdateCustomView_ extends MappedBoolean(this){ override def defaultValue = false } + object canGetCustomView_ extends MappedBoolean(this){ + override def defaultValue = false + } object canSeeViewsWithPermissionsForAllUsers_ extends MappedBoolean(this){ override def defaultValue = false } @@ -591,6 +594,7 @@ class ViewDefinition extends View with LongKeyedMapper[ViewDefinition] with Many def canCreateCustomView: Boolean = canCreateCustomView_.get def canDeleteCustomView: Boolean = canDeleteCustomView_.get def canUpdateCustomView: Boolean = canUpdateCustomView_.get + def canGetCustomView: Boolean = canGetCustomView_.get //TODO: if you add new permissions here, remember to set them wherever views are created // (e.g. BankAccountCreationDispatcher) } diff --git a/obp-api/src/test/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApiTest.scala b/obp-api/src/test/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApiTest.scala index 053be11881..845f6c6e2a 100644 --- a/obp-api/src/test/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApiTest.scala +++ b/obp-api/src/test/scala/code/api/berlin/group/v1_3/AccountInformationServiceAISApiTest.scala @@ -4,6 +4,7 @@ import code.api.Constant import code.api.Constant.SYSTEM_READ_ACCOUNTS_BERLIN_GROUP_VIEW_ID import code.api.berlin.group.v1_3.JSONFactory_BERLIN_GROUP_1_3._ import code.api.builder.AccountInformationServiceAISApi.APIMethods_AccountInformationServiceAISApi +import code.api.util.APIUtil import code.api.util.APIUtil.OAuth._ import code.api.util.ErrorMessages._ import code.api.v4_0_0.PostViewJsonV400 @@ -83,7 +84,10 @@ class AccountInformationServiceAISApiTest extends BerlinGroupServerSetupV1_3 wit } scenario("Authentication User, test succeed", BerlinGroupV1_3, readAccountDetails) { - val (bankId, accountId) = MappedBankAccount.findAll().headOption.map(i => (i.bankId.value,i.accountId.value)).getOrElse(("", "")) + val bankId = APIUtil.defaultBankId + val accountId = testAccountId0.value + + grantUserAccessToViewViaEndpoint( bankId, accountId, @@ -103,7 +107,7 @@ class AccountInformationServiceAISApiTest extends BerlinGroupServerSetupV1_3 wit feature(s"BG v1.3 - $getBalances") { scenario("Authentication User, test succeed", BerlinGroupV1_3, getBalances) { - val bankId = MappedBankAccount.find(By(MappedBankAccount.theAccountId, testAccountId1.value)).map(_.bankId.value).getOrElse("") + val bankId = APIUtil.defaultBankId Then("We should get a 403 ") val requestGetFailed = (V1_3_BG / "accounts" / testAccountId1.value / "balances").GET <@ (user1) @@ -139,7 +143,7 @@ class AccountInformationServiceAISApiTest extends BerlinGroupServerSetupV1_3 wit responseGetFailed.code should equal(403) responseGetFailed.body.extract[ErrorMessagesBG].tppMessages.head.text should startWith(UserNoPermissionAccessView) - val bankId = MappedBankAccount.find(By(MappedBankAccount.theAccountId, testAccountId.value)).map(_.bankId.value).getOrElse("") + val bankId = APIUtil.defaultBankId grantUserAccessToViewViaEndpoint( bankId, testAccountId.value, @@ -168,7 +172,7 @@ class AccountInformationServiceAISApiTest extends BerlinGroupServerSetupV1_3 wit responseGetFailed.code should equal(403) responseGetFailed.body.extract[ErrorMessagesBG].tppMessages.head.text should startWith(UserNoPermissionAccessView) - val bankId = MappedBankAccount.find(By(MappedBankAccount.theAccountId, testAccountId.value)).map(_.bankId.value).getOrElse("") + val bankId = APIUtil.defaultBankId grantUserAccessToViewViaEndpoint( bankId, testAccountId.value, @@ -202,7 +206,7 @@ class AccountInformationServiceAISApiTest extends BerlinGroupServerSetupV1_3 wit responseGetFailed.code should equal(403) responseGetFailed.body.extract[ErrorMessagesBG].tppMessages.head.text should startWith(UserNoPermissionAccessView) - val bankId = MappedBankAccount.find(By(MappedBankAccount.theAccountId, testAccountId.value)).map(_.bankId.value).getOrElse("") + val bankId = APIUtil.defaultBankId grantUserAccessToViewViaEndpoint( bankId, testAccountId.value, diff --git a/obp-api/src/test/scala/code/api/v1_2_0/API12Test.scala b/obp-api/src/test/scala/code/api/v1_2_0/API12Test.scala index 056d6dbf89..c85d5d896b 100644 --- a/obp-api/src/test/scala/code/api/v1_2_0/API12Test.scala +++ b/obp-api/src/test/scala/code/api/v1_2_0/API12Test.scala @@ -167,7 +167,7 @@ // def randomViewPermalinkButNotOwner(bankId: String, account: AccountJSON) : String = { // val request = v1_2Request / "banks" / bankId / "accounts" / account.id / "views" <@(consumer, token1) // val reply = makeGetRequest(request) -// val possibleViewsPermalinksWithoutOwner = reply.body.extract[ViewsJSON].views.filterNot(_.is_public==true).filterNot(_.id == "owner") +// val possibleViewsPermalinksWithoutOwner = reply.body.extract[ViewsJSON].views.filterNot(_.is_public==true).filterNot(_.id == Constant.SYSTEM_OWNER_VIEW_ID) // val randomPosition = nextInt(possibleViewsPermalinksWithoutOwner.size) // possibleViewsPermalinksWithoutOwner(randomPosition).id // } @@ -1377,7 +1377,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val viewId = "owner" +// val viewId = Constant.SYSTEM_OWNER_VIEW_ID // val userId1 = resourceUser2.idGivenByProvider // val userId2 = resourceUser2.idGivenByProvider // grantUserAccessToView(bankId, bankAccount.id, userId1, viewId, user1) @@ -1395,7 +1395,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val viewId = ViewId("owner") +// val viewId = ViewId(Constant.SYSTEM_OWNER_VIEW_ID) // val view = Views.views.vend.view(BankIdAccountIdViewId(BankId(bankId), AccountId(bankAccount.id), viewId)).get // if(Views.views.vend.getOwners(view).toList.length == 0){ // val userId = resourceUser2.idGivenByProvider @@ -4122,7 +4122,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // When("the request is sent") // val randomNarrative = randomString(20) @@ -4140,7 +4140,7 @@ // Given("We will not use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // val randomNarrative = randomString(20) // When("the request is sent") @@ -4159,7 +4159,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // val randomNarrative = randomString(20) // When("the request is sent") @@ -4178,7 +4178,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // val randomNarrative = randomString(20) // When("the request is sent") @@ -4197,7 +4197,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val randomNarrative = randomString(20) // When("the request is sent") // val postReply = postNarrativeForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomNarrative, user1) @@ -4213,7 +4213,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // When("the request is sent") // val randomNarrative = randomString(20) @@ -4231,7 +4231,7 @@ // Given("We will not use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // val randomNarrative = randomString(20) // When("the request is sent") @@ -4250,7 +4250,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // val randomNarrative = randomString(20) // When("the request is sent") @@ -4269,7 +4269,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transactionId = randomString(5) // val randomNarrative = randomString(20) // When("the request is sent") @@ -4286,7 +4286,7 @@ // Given("We will use an access token and will set a narrative first") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // val randomNarrative = randomString(20) // postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user1) @@ -4304,7 +4304,7 @@ // Given("We will not use an access token and will set a narrative first") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // val randomNarrative = randomString(20) // postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user1) @@ -4322,7 +4322,7 @@ // Given("We will use an access token and will set a narrative first") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val transaction = randomTransaction(bankId, bankAccount.id, view) // val randomNarrative = randomString(20) // postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user1) @@ -4340,7 +4340,7 @@ // Given("We will use an access token") // val bankId = randomBank // val bankAccount : AccountJSON = randomPrivateAccount(bankId) -// val view = "owner" +// val view = Constant.SYSTEM_OWNER_VIEW_ID // val randomNarrative = randomString(20) // When("the delete request is sent") // val deleteReply = deleteNarrativeForOneTransaction(bankId, bankAccount.id, view, randomString(5), user1) diff --git a/obp-api/src/test/scala/code/api/v2_2_0/AccountTest.scala b/obp-api/src/test/scala/code/api/v2_2_0/AccountTest.scala index a1a62b8791..4521df27f3 100644 --- a/obp-api/src/test/scala/code/api/v2_2_0/AccountTest.scala +++ b/obp-api/src/test/scala/code/api/v2_2_0/AccountTest.scala @@ -1,5 +1,6 @@ package code.api.v2_2_0 +import code.api.Constant import code.api.util.APIUtil.OAuth._ import code.api.util.APIUtil.extractErrorMessageCode import code.api.util.{ApiRole, ErrorMessages} @@ -156,7 +157,7 @@ class AccountTest extends V220ServerSetup with DefaultUsers { val accountViews = accountViewsResponse.body.extract[ViewsJSONV220] //Note: now when we create new account, will have the systemOwnerView access to this view. accountViews.views.length > 0 should be (true) - accountViews.views.map(_.id).toString() contains("owner") should be (true) + accountViews.views.map(_.id).toString() contains(Constant.SYSTEM_OWNER_VIEW_ID) should be (true) } scenario("We create an account, but with wrong format of account_id ") { diff --git a/obp-api/src/test/scala/code/api/v3_0_0/FirehoseTest.scala b/obp-api/src/test/scala/code/api/v3_0_0/FirehoseTest.scala index 870a6bc445..45e6b1b361 100644 --- a/obp-api/src/test/scala/code/api/v3_0_0/FirehoseTest.scala +++ b/obp-api/src/test/scala/code/api/v3_0_0/FirehoseTest.scala @@ -1,5 +1,6 @@ package code.api.v3_0_0 +import code.api.Constant import code.api.util.APIUtil.OAuth._ import code.api.util.ApiRole import code.api.util.ApiRole.{CanUseAccountFirehose, CanUseAccountFirehoseAtAnyBank} @@ -77,7 +78,7 @@ class FirehoseTest extends V300ServerSetup with PropsReset{ setPropsValues("enable.force_error"->"true") Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, ApiRole.CanUseAccountFirehoseAtAnyBank.toString) When("We send the request") - val request = (v3_0Request / "banks" / testBankId1.value /"firehose" / "accounts" / testAccountId1.value / "views"/"owner"/"transactions").GET <@ (user1) + val request = (v3_0Request / "banks" / testBankId1.value /"firehose" / "accounts" / testAccountId1.value / "views"/Constant.SYSTEM_OWNER_VIEW_ID/"transactions").GET <@ (user1) val response = makeGetRequest(request) Then("We should get a 200 and check the response body") response.code should equal(200) @@ -89,7 +90,7 @@ class FirehoseTest extends V300ServerSetup with PropsReset{ setPropsValues("enable.force_error" -> "true") Entitlement.entitlement.vend.addEntitlement(testBankId1.value, resourceUser1.userId, ApiRole.CanUseAccountFirehose.toString) When("We send the request") - val request = (v3_0Request / "banks" / testBankId1.value / "firehose" / "accounts" / testAccountId1.value / "views" / "owner" / "transactions").GET <@ (user1) + val request = (v3_0Request / "banks" / testBankId1.value / "firehose" / "accounts" / testAccountId1.value / "views" / Constant.SYSTEM_OWNER_VIEW_ID / "transactions").GET <@ (user1) val response = makeGetRequest(request) Then("We should get a 200 and check the response body") response.code should equal(200) @@ -100,7 +101,7 @@ class FirehoseTest extends V300ServerSetup with PropsReset{ setPropsValues("allow_firehose_views" -> "true") Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, ApiRole.CanUseAccountFirehoseAtAnyBank.toString) When("We send the request") - val request = (v3_0Request / "banks" / testBankId1.value /"firehose" / "accounts" / testAccountId1.value / "views"/"owner"/"transactions").GET <@ (user1) + val request = (v3_0Request / "banks" / testBankId1.value /"firehose" / "accounts" / testAccountId1.value / "views"/Constant.SYSTEM_OWNER_VIEW_ID/"transactions").GET <@ (user1) val response = makeGetRequest(request) Then("We should get a 200 and check the response body") response.code should equal(200) @@ -111,7 +112,7 @@ class FirehoseTest extends V300ServerSetup with PropsReset{ scenario("We will call the endpoint missing role", VersionOfApi, ApiEndpoint4) { setPropsValues("allow_account_firehose" -> "true") When("We send the request") - val request = (v3_0Request / "banks" / testBankId1.value / "firehose" / "accounts" / testAccountId1.value /"views" / "owner"/"transactions").GET <@ (user1) + val request = (v3_0Request / "banks" / testBankId1.value / "firehose" / "accounts" / testAccountId1.value /"views" / Constant.SYSTEM_OWNER_VIEW_ID/"transactions").GET <@ (user1) val response = makeGetRequest(request) Then("We should get a 403 and check the response body") response.code should equal(403) @@ -122,7 +123,7 @@ class FirehoseTest extends V300ServerSetup with PropsReset{ scenario("We will call the endpoint missing props ", VersionOfApi, ApiEndpoint4) { Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, ApiRole.CanUseAccountFirehoseAtAnyBank.toString) When("We send the request") - val request = (v3_0Request / "banks" / testBankId1.value /"firehose" / "accounts" / testAccountId1.value / "views"/"owner"/"transactions").GET <@ (user1) + val request = (v3_0Request / "banks" / testBankId1.value /"firehose" / "accounts" / testAccountId1.value / "views"/Constant.SYSTEM_OWNER_VIEW_ID/"transactions").GET <@ (user1) val response = makeGetRequest(request) Then("We should get a 400 and check the response body") response.code should equal(400) diff --git a/obp-api/src/test/scala/code/api/v3_1_0/ConsentTest.scala b/obp-api/src/test/scala/code/api/v3_1_0/ConsentTest.scala index 6449695a59..cc23dc8d95 100644 --- a/obp-api/src/test/scala/code/api/v3_1_0/ConsentTest.scala +++ b/obp-api/src/test/scala/code/api/v3_1_0/ConsentTest.scala @@ -25,6 +25,7 @@ TESOBE (http://www.tesobe.com/) */ package code.api.v3_1_0 +import code.api.Constant import code.api.RequestHeader import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON import code.api.util.{APIUtil, Consent} @@ -59,7 +60,7 @@ class ConsentTest extends V310ServerSetup { lazy val bankId = randomBankId lazy val bankAccount = randomPrivateAccount(bankId) lazy val entitlements = List(PostConsentEntitlementJsonV310("", CanGetAnyUser.toString())) - lazy val views = List(PostConsentViewJsonV310(bankId, bankAccount.id, "owner")) + lazy val views = List(PostConsentViewJsonV310(bankId, bankAccount.id, Constant.SYSTEM_OWNER_VIEW_ID)) lazy val postConsentEmailJsonV310 = SwaggerDefinitionsJSON.postConsentEmailJsonV310 .copy(entitlements=entitlements) .copy(consumer_id=Some(testConsumer.consumerId.get)) diff --git a/obp-api/src/test/scala/code/api/v3_1_0/TransactionRequestTest.scala b/obp-api/src/test/scala/code/api/v3_1_0/TransactionRequestTest.scala index cc8a23212a..0df2bfda97 100644 --- a/obp-api/src/test/scala/code/api/v3_1_0/TransactionRequestTest.scala +++ b/obp-api/src/test/scala/code/api/v3_1_0/TransactionRequestTest.scala @@ -55,7 +55,7 @@ class TransactionRequestTest extends V310ServerSetup { When("We make a request v3.1.0") val bankId = randomBankId val bankAccount = randomPrivateAccount(bankId) - val view = bankAccount.views_available.map(_.id).headOption.getOrElse("owner") + val view = bankAccount.views_available.map(_.id).headOption.getOrElse(Constant.SYSTEM_OWNER_VIEW_ID) val request310 = (v3_1_0_Request / "banks" / bankId / "accounts" / bankAccount.id / view / "transaction-requests").GET val response310 = makeGetRequest(request310) Then("We should get a 401") @@ -67,7 +67,7 @@ class TransactionRequestTest extends V310ServerSetup { When("We make a request v3.1.0") val bankId = randomBankId val bankAccount = randomPrivateAccount(bankId) - val view = bankAccount.views_available.map(_.id).headOption.getOrElse("owner") + val view = bankAccount.views_available.map(_.id).headOption.getOrElse(Constant.SYSTEM_OWNER_VIEW_ID) val request310 = (v3_1_0_Request / "banks" / bankId / "accounts" / bankAccount.id / view / "transaction-requests").GET <@(user1) val response310 = makeGetRequest(request310) Then("We should get a 200") diff --git a/obp-api/src/test/scala/code/api/v3_1_0/TransactionTest.scala b/obp-api/src/test/scala/code/api/v3_1_0/TransactionTest.scala index 11ce2163f1..f67ddc6246 100644 --- a/obp-api/src/test/scala/code/api/v3_1_0/TransactionTest.scala +++ b/obp-api/src/test/scala/code/api/v3_1_0/TransactionTest.scala @@ -80,7 +80,7 @@ class TransactionTest extends V310ServerSetup { When("We make a request v3.1.0") val bankId = randomBankId val bankAccount = randomPrivateAccount(bankId) - val view = bankAccount.views_available.map(_.id).headOption.getOrElse("owner") + val view = bankAccount.views_available.map(_.id).headOption.getOrElse(SYSTEM_OWNER_VIEW_ID) val transaction = randomTransaction(bankId, bankAccount.id, view) val request310 = (v3_1_0_Request / "banks" / bankId / "accounts" / bankAccount.id / view / "transactions" / transaction.id / "transaction").GET val response310 = makeGetRequest(request310) @@ -93,7 +93,7 @@ class TransactionTest extends V310ServerSetup { When("We make a request v3.1.0") val bankId = randomBankId val bankAccount = randomPrivateAccount(bankId) - val view = bankAccount.views_available.map(_.id).headOption.getOrElse("owner") + val view = bankAccount.views_available.map(_.id).headOption.getOrElse(SYSTEM_OWNER_VIEW_ID) val transaction = randomTransaction(bankId, bankAccount.id, view) val request310 = (v3_1_0_Request / "banks" / bankId / "accounts" / bankAccount.id / view / "transactions" / transaction.id / "transaction").GET <@(user1) val response310 = makeGetRequest(request310) @@ -214,7 +214,7 @@ class TransactionTest extends V310ServerSetup { val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId2,other_account_routing_address=bankAccountId2) When(s"We make the request Create counterparty for an account $ApiEndpoint5") - val requestPost = (v3_1_0_Request / "banks" / bankId1 / "accounts" / bankAccountId1 / "owner" / "counterparties" ).POST <@ (user1) + val requestPost = (v3_1_0_Request / "banks" / bankId1 / "accounts" / bankAccountId1 / SYSTEM_OWNER_VIEW_ID / "counterparties" ).POST <@ (user1) val responsePost = makePostRequest(requestPost, write(counterpartyPostJSON)) Then("We should get a 201 and check all the fields") @@ -286,7 +286,7 @@ class TransactionTest extends V310ServerSetup { val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId1,other_account_routing_address=bankAccountId1) When(s"We make the request Create counterparty for an account $ApiEndpoint5") - val requestPost = (v3_1_0_Request / "banks" / bankId2 / "accounts" / bankAccountId2 / "owner" / "counterparties" ).POST <@ (user1) + val requestPost = (v3_1_0_Request / "banks" / bankId2 / "accounts" / bankAccountId2 / SYSTEM_OWNER_VIEW_ID / "counterparties" ).POST <@ (user1) val responsePost = makePostRequest(requestPost, write(counterpartyPostJSON)) Then("We should get a 201 and check all the fields") @@ -358,7 +358,7 @@ class TransactionTest extends V310ServerSetup { val counterpartyPostJsonFrom = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId1,other_account_routing_address=bankAccountId1) When(s"We make the request Create counterparty for an account $ApiEndpoint5") - val requestPostFrom = (v3_1_0_Request / "banks" / bankId1 / "accounts" / bankAccountId1 / "owner" / "counterparties" ).POST <@ (user1) + val requestPostFrom = (v3_1_0_Request / "banks" / bankId1 / "accounts" / bankAccountId1 / SYSTEM_OWNER_VIEW_ID / "counterparties" ).POST <@ (user1) val responsePostFrom = makePostRequest(requestPostFrom, write(counterpartyPostJsonFrom)) Then("We should get a 201 and check all the fields") @@ -371,7 +371,7 @@ class TransactionTest extends V310ServerSetup { val counterpartyPostJsonTo = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId2,other_account_routing_address=bankAccountId2) When(s"We make the request Create counterparty for an account $ApiEndpoint5") - val requestPostTo = (v3_1_0_Request / "banks" / bankId2 / "accounts" / bankAccountId2 / "owner" / "counterparties" ).POST <@ (user1) + val requestPostTo = (v3_1_0_Request / "banks" / bankId2 / "accounts" / bankAccountId2 / SYSTEM_OWNER_VIEW_ID / "counterparties" ).POST <@ (user1) val responsePostTo = makePostRequest(requestPostTo, write(counterpartyPostJsonTo)) Then("We should get a 201 and check all the fields") @@ -429,7 +429,7 @@ class TransactionTest extends V310ServerSetup { val counterpartyPostJSON = SwaggerDefinitionsJSON.postCounterpartyJSON.copy(other_bank_routing_address=bankId2,other_account_routing_address=bankAccountId2) When(s"We make the request Create counterparty for an account $ApiEndpoint5") - val requestPost = (v3_1_0_Request / "banks" / bankId1 / "accounts" / bankAccountId1 / "owner" / "counterparties" ).POST <@ (user1) + val requestPost = (v3_1_0_Request / "banks" / bankId1 / "accounts" / bankAccountId1 / SYSTEM_OWNER_VIEW_ID / "counterparties" ).POST <@ (user1) val responsePost = makePostRequest(requestPost, write(counterpartyPostJSON)) Then("We should get a 201 and check all the fields") diff --git a/obp-api/src/test/scala/code/api/v4_0_0/DeleteAccountCascadeTest.scala b/obp-api/src/test/scala/code/api/v4_0_0/DeleteAccountCascadeTest.scala index 78eb5eba9f..54998c885d 100644 --- a/obp-api/src/test/scala/code/api/v4_0_0/DeleteAccountCascadeTest.scala +++ b/obp-api/src/test/scala/code/api/v4_0_0/DeleteAccountCascadeTest.scala @@ -1,5 +1,6 @@ package code.api.v4_0_0 +import code.api.Constant import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON.createViewJsonV300 import code.api.util.APIUtil.OAuth._ @@ -87,7 +88,7 @@ class DeleteAccountCascadeTest extends V400ServerSetup { account.account_id, resourceUser2.userId, user1, - PostViewJsonV400(view_id = "owner", is_system = true) + PostViewJsonV400(view_id = Constant.SYSTEM_OWNER_VIEW_ID, is_system = true) ) createWebhookViaEndpoint( diff --git a/obp-api/src/test/scala/code/api/v4_0_0/DeleteBankCascadeTest.scala b/obp-api/src/test/scala/code/api/v4_0_0/DeleteBankCascadeTest.scala index 6d65c160fa..5f03e7ee9e 100644 --- a/obp-api/src/test/scala/code/api/v4_0_0/DeleteBankCascadeTest.scala +++ b/obp-api/src/test/scala/code/api/v4_0_0/DeleteBankCascadeTest.scala @@ -1,5 +1,6 @@ package code.api.v4_0_0 +import code.api.Constant import java.util.concurrent.TimeUnit import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON @@ -98,7 +99,7 @@ class DeleteBankCascadeTest extends V400ServerSetup { account.account_id, resourceUser2.userId, user1, - PostViewJsonV400(view_id = "owner", is_system = true) + PostViewJsonV400(view_id = Constant.SYSTEM_OWNER_VIEW_ID, is_system = true) ) createWebhookViaEndpoint( diff --git a/obp-api/src/test/scala/code/api/v4_0_0/DoubleEntryTransactionTest.scala b/obp-api/src/test/scala/code/api/v4_0_0/DoubleEntryTransactionTest.scala index dc467f2268..cdfc3e8dc2 100644 --- a/obp-api/src/test/scala/code/api/v4_0_0/DoubleEntryTransactionTest.scala +++ b/obp-api/src/test/scala/code/api/v4_0_0/DoubleEntryTransactionTest.scala @@ -1,5 +1,6 @@ package code.api.v4_0_0 +import code.api.Constant import code.api.util.APIUtil.OAuth._ import code.api.util.ApiRole import code.api.util.ErrorMessages.{UserHasMissingRoles, UserNoPermissionAccessView, UserNotLoggedIn} @@ -15,7 +16,7 @@ class DoubleEntryTransactionTest extends V400ServerSetup { lazy val testBankId: BankId = testBankId1 lazy val testAccountId: AccountId = testAccountId1 - lazy val view = "owner" + lazy val view = Constant.SYSTEM_OWNER_VIEW_ID /** * Test tags diff --git a/obp-api/src/test/scala/code/api/v4_0_0/TransactionAttributesTest.scala b/obp-api/src/test/scala/code/api/v4_0_0/TransactionAttributesTest.scala index 0389d5f891..1780b64362 100644 --- a/obp-api/src/test/scala/code/api/v4_0_0/TransactionAttributesTest.scala +++ b/obp-api/src/test/scala/code/api/v4_0_0/TransactionAttributesTest.scala @@ -1,6 +1,6 @@ package code.api.v4_0_0 - +import code.api.Constant import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON import code.api.util.APIUtil.OAuth._ import code.api.util.ApiRole._ @@ -33,7 +33,7 @@ class TransactionAttributesTest extends V400ServerSetup { lazy val accountId = testAccountId1.value lazy val postTransactionAttributeJsonV400 = SwaggerDefinitionsJSON.transactionAttributeJsonV400 lazy val putTransactionAttributeJsonV400 = SwaggerDefinitionsJSON.transactionAttributeJsonV400.copy(name="test") - lazy val view = "owner" + lazy val view = Constant.SYSTEM_OWNER_VIEW_ID @@ -72,7 +72,7 @@ class TransactionAttributesTest extends V400ServerSetup { lazy val accountId = bankAccount.id lazy val postTransactionAttributeJsonV400 = SwaggerDefinitionsJSON.transactionAttributeJsonV400 lazy val putTransactionAttributeJsonV400 = SwaggerDefinitionsJSON.transactionAttributeJsonV400.copy(name="test") - lazy val view = bankAccount.views_available.map(_.id).headOption.getOrElse("owner") + lazy val view = bankAccount.views_available.map(_.id).headOption.getOrElse(Constant.SYSTEM_OWNER_VIEW_ID) lazy val transaction = randomTransactionViaEndpoint(bankId, bankAccount.id, view) lazy val transactionId = transaction.id diff --git a/obp-api/src/test/scala/code/api/v4_0_0/TransactionRequestAttributesTest.scala b/obp-api/src/test/scala/code/api/v4_0_0/TransactionRequestAttributesTest.scala index 2dcbd4b121..b4b56e5c7f 100644 --- a/obp-api/src/test/scala/code/api/v4_0_0/TransactionRequestAttributesTest.scala +++ b/obp-api/src/test/scala/code/api/v4_0_0/TransactionRequestAttributesTest.scala @@ -1,5 +1,6 @@ package code.api.v4_0_0 +import code.api.Constant import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON import code.api.util.APIUtil import code.api.util.APIUtil.OAuth._ @@ -20,7 +21,7 @@ class TransactionRequestAttributesTest extends V400ServerSetup { lazy val accountId = testAccountId1.value lazy val postTransactionRequestAttributeJsonV400 = SwaggerDefinitionsJSON.transactionRequestAttributeJsonV400 lazy val putTransactionRequestAttributeJsonV400 = SwaggerDefinitionsJSON.transactionRequestAttributeJsonV400.copy(name = "test") - lazy val view = "owner" + lazy val view = Constant.SYSTEM_OWNER_VIEW_ID /** * Test tags @@ -86,7 +87,7 @@ class TransactionRequestAttributesTest extends V400ServerSetup { lazy val accountId = bankAccount.id lazy val postTransactionRequestAttributeJsonV400 = SwaggerDefinitionsJSON.transactionRequestAttributeJsonV400 lazy val putTransactionRequestAttributeJsonV400 = SwaggerDefinitionsJSON.transactionRequestAttributeJsonV400.copy(name = "test") - lazy val view = bankAccount.views_available.map(_.id).headOption.getOrElse("owner") + lazy val view = bankAccount.views_available.map(_.id).headOption.getOrElse(Constant.SYSTEM_OWNER_VIEW_ID) lazy val transactionRequest = randomTransactionRequestViaEndpoint(bankId, bankAccount.id, view, user1) lazy val transactionRequestId = transactionRequest.id diff --git a/obp-api/src/test/scala/code/api/v4_0_0/TransactionRequestsTest.scala b/obp-api/src/test/scala/code/api/v4_0_0/TransactionRequestsTest.scala index b0789e2aba..7a09a0a2d2 100644 --- a/obp-api/src/test/scala/code/api/v4_0_0/TransactionRequestsTest.scala +++ b/obp-api/src/test/scala/code/api/v4_0_0/TransactionRequestsTest.scala @@ -1,5 +1,6 @@ package code.api.v4_0_0 +import code.api.Constant import java.util.{Date, UUID} import code.api.ChargePolicy import code.api.Constant._ @@ -1184,7 +1185,7 @@ class TransactionRequestsTest extends V400ServerSetup with DefaultUsers { helper.accountId1.value, resourceUser2.userId, user1, - PostViewJsonV400(view_id = "owner", is_system = true) + PostViewJsonV400(view_id = Constant.SYSTEM_OWNER_VIEW_ID, is_system = true) ) Then("we call the 'V400 Create Transaction Request' endpoint") @@ -1432,7 +1433,7 @@ class TransactionRequestsTest extends V400ServerSetup with DefaultUsers { helper.accountId1.value, resourceUser2.userId, user1, - PostViewJsonV400(view_id = "owner", is_system = true) + PostViewJsonV400(view_id = Constant.SYSTEM_OWNER_VIEW_ID, is_system = true) ) Then("we call the 'V400 Create Transaction Request' endpoint") @@ -1697,7 +1698,7 @@ class TransactionRequestsTest extends V400ServerSetup with DefaultUsers { helper.accountId1.value, resourceUser2.userId, user1, - PostViewJsonV400(view_id = "owner", is_system = true) + PostViewJsonV400(view_id = Constant.SYSTEM_OWNER_VIEW_ID, is_system = true) ) Then("we call the 'V400 Create Transaction Request' endpoint") @@ -1750,7 +1751,7 @@ class TransactionRequestsTest extends V400ServerSetup with DefaultUsers { lazy val bankId = testBankId1.value lazy val accountId = testAccountId1.value - lazy val view = "owner" + lazy val view = Constant.SYSTEM_OWNER_VIEW_ID scenario("We will call the endpoint WITHOUT user credentials", ApiEndpoint1, VersionOfApi) { diff --git a/obp-api/src/test/scala/code/api/v5_0_0/ConsentRequestTest.scala b/obp-api/src/test/scala/code/api/v5_0_0/ConsentRequestTest.scala index 22a87d247e..61ed28f991 100644 --- a/obp-api/src/test/scala/code/api/v5_0_0/ConsentRequestTest.scala +++ b/obp-api/src/test/scala/code/api/v5_0_0/ConsentRequestTest.scala @@ -25,6 +25,7 @@ TESOBE (http://www.tesobe.com/) */ package code.api.v5_0_0 +import code.api.Constant import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON import code.api.util.APIUtil.OAuth._ import code.api.util.ApiRole._ @@ -68,7 +69,7 @@ class ConsentRequestTest extends V500ServerSetupAsync with PropsReset{ lazy val accountAccess = List(AccountAccessV500( account_routing = AccountRoutingJsonV121( scheme = "AccountId", - address = testAccountId1.value), "owner")) + address = testAccountId1.value), Constant.SYSTEM_OWNER_VIEW_ID)) lazy val postConsentRequestJsonV310 = SwaggerDefinitionsJSON.postConsentRequestJsonV500 .copy(entitlements=Some(entitlements)) .copy(consumer_id=None) diff --git a/obp-api/src/test/scala/code/api/v5_1_0/ConsentsTest.scala b/obp-api/src/test/scala/code/api/v5_1_0/ConsentsTest.scala index afaff87370..4dc53a08ab 100644 --- a/obp-api/src/test/scala/code/api/v5_1_0/ConsentsTest.scala +++ b/obp-api/src/test/scala/code/api/v5_1_0/ConsentsTest.scala @@ -25,6 +25,7 @@ TESOBE (http://www.tesobe.com/) */ package code.api.v5_1_0 +import code.api.Constant import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON import code.api.util.APIUtil.OAuth._ import code.api.util.ApiRole._ @@ -70,7 +71,7 @@ class ConsentsTest extends V510ServerSetup with PropsReset{ lazy val accountAccess = List(AccountAccessV500( account_routing = AccountRoutingJsonV121( scheme = "AccountId", - address = testAccountId1.value), "owner")) + address = testAccountId1.value), Constant.SYSTEM_OWNER_VIEW_ID)) lazy val postConsentRequestJsonV310 = SwaggerDefinitionsJSON.postConsentRequestJsonV500 .copy(entitlements=Some(entitlements)) .copy(consumer_id=None) diff --git a/obp-api/src/test/scala/code/api/v5_1_0/CustomViewTest.scala b/obp-api/src/test/scala/code/api/v5_1_0/CustomViewTest.scala index 2c03414fb1..1b081ba302 100644 --- a/obp-api/src/test/scala/code/api/v5_1_0/CustomViewTest.scala +++ b/obp-api/src/test/scala/code/api/v5_1_0/CustomViewTest.scala @@ -134,12 +134,12 @@ class CustomViewTest extends V510ServerSetup { } { - val request510 = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId /"views" / SYSTEM_AUDITOR_VIEW_ID /"target-views" / targetViewId ).GET <@ (user1) + val request510 = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId /"views" / ownerView /"target-views" / targetViewId ).GET <@ (user1) val response510 = makeGetRequest(request510) Then("We should get a 400") response510.code should equal(400) response510.body.extract[ErrorMessage].message contains (ViewDoesNotPermitAccess) shouldBe (true) - response510.body.extract[ErrorMessage].message contains ("can_see_available_views_for_bank_account") shouldBe (true) + response510.body.extract[ErrorMessage].message contains ("can_get_custom_view") shouldBe (true) } { @@ -169,7 +169,7 @@ class CustomViewTest extends V510ServerSetup { response510.body.extract[CustomViewJsonV510].allowed_permissions.sorted should equal(postCustomViewJson.allowed_permissions.sorted) { - val request510 = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId / "views" / ownerView / "target-views" / targetViewId).GET <@ (user1) + val request510 = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId / "views" / manageCustomView / "target-views" / targetViewId).GET <@ (user1) val response510 = makeGetRequest(request510) Then("We should get a 200") response510.code should equal(200) @@ -198,7 +198,7 @@ class CustomViewTest extends V510ServerSetup { } { - val request510 = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId /"views" / ownerView /"target-views" / targetViewId ).GET <@ (user1) + val request510 = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId /"views" / manageCustomView /"target-views" / targetViewId ).GET <@ (user1) val response510 = makeGetRequest(request510) Then("We should get a 200") response510.code should equal(200) @@ -217,7 +217,7 @@ class CustomViewTest extends V510ServerSetup { response510.code should equal(204) } { - val request510 = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId / "views" / ownerView / "target-views" / targetViewId).GET <@ (user1) + val request510 = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId / "views" / manageCustomView / "target-views" / targetViewId).GET <@ (user1) val response510 = makeGetRequest(request510) Then("We should get a 400") response510.code should equal(400) diff --git a/obp-api/src/test/scala/code/connector/MockedCbsConnector.scala b/obp-api/src/test/scala/code/connector/MockedCbsConnector.scala index 49f3220ead..24ca50053b 100644 --- a/obp-api/src/test/scala/code/connector/MockedCbsConnector.scala +++ b/obp-api/src/test/scala/code/connector/MockedCbsConnector.scala @@ -1,6 +1,6 @@ package code.connector -import code.api.Constant.SYSTEM_STANDARD_VIEW_ID +import code.api.Constant._ import code.api.util.{CallContext, CustomJsonFormats} import code.bankconnectors._ import code.setup.{DefaultConnectorTestSetup, DefaultUsers, ServerSetup} @@ -38,7 +38,7 @@ object MockedCbsConnector extends ServerSetup balanceAmount = "", balanceCurrency = "", owners = List(""), - viewsToGenerate = SYSTEM_STANDARD_VIEW_ID :: "Owner" :: "_Public" :: "Accountant" :: "Auditor" :: Nil, + viewsToGenerate = SYSTEM_STANDARD_VIEW_ID :: SYSTEM_OWNER_VIEW_ID :: CUSTOM_PUBLIC_VIEW_ID :: SYSTEM_ACCOUNTANT_VIEW_ID :: SYSTEM_AUDITOR_VIEW_ID :: Nil, bankRoutingScheme = "", bankRoutingAddress = "", branchRoutingScheme = "", @@ -54,7 +54,7 @@ object MockedCbsConnector extends ServerSetup balanceAmount = "", balanceCurrency = "", owners = List(""), - viewsToGenerate = SYSTEM_STANDARD_VIEW_ID :: "Owner" :: "_Public" :: "Accountant" :: "Auditor" :: Nil, + viewsToGenerate = SYSTEM_STANDARD_VIEW_ID :: SYSTEM_OWNER_VIEW_ID :: CUSTOM_PUBLIC_VIEW_ID :: SYSTEM_ACCOUNTANT_VIEW_ID :: SYSTEM_AUDITOR_VIEW_ID :: Nil, bankRoutingScheme = "", bankRoutingAddress = "", branchRoutingScheme = "", diff --git a/obp-api/src/test/scala/code/setup/ServerSetup.scala b/obp-api/src/test/scala/code/setup/ServerSetup.scala index ab0675994a..b3a4e25fc2 100644 --- a/obp-api/src/test/scala/code/setup/ServerSetup.scala +++ b/obp-api/src/test/scala/code/setup/ServerSetup.scala @@ -72,7 +72,7 @@ trait ServerSetup extends FeatureSpec with SendServerRequests val exampleDate = DateWithSecondsExampleObject // @code.setup.TestConnectorSetup.createBanks we can know, the bankIds in test database. - val testBankId1 = BankId("testBank1") + val testBankId1 = BankId(APIUtil.defaultBankId) val testBankId2 = BankId("testBank2") // @code.setup.TestConnectorSetup.createAccounts we can know, the accountIds in test database. diff --git a/obp-api/src/test/scala/code/setup/TestConnectorSetup.scala b/obp-api/src/test/scala/code/setup/TestConnectorSetup.scala index 86b6c930e7..ae5fadd478 100644 --- a/obp-api/src/test/scala/code/setup/TestConnectorSetup.scala +++ b/obp-api/src/test/scala/code/setup/TestConnectorSetup.scala @@ -2,7 +2,7 @@ package code.setup import java.util.{Calendar, Date} import code.accountholders.AccountHolders -import code.api.Constant.{SYSTEM_ACCOUNTANT_VIEW_ID, SYSTEM_AUDITOR_VIEW_ID, SYSTEM_MANAGE_CUSTOM_VIEWS_VIEW_ID, SYSTEM_FIREHOSE_VIEW_ID, SYSTEM_OWNER_VIEW_ID} +import code.api.Constant._ import code.api.util.ErrorMessages.attemptedToOpenAnEmptyBox import code.api.util.{APIUtil, OBPLimit, OBPOffset} import code.bankconnectors.{Connector, LocalMappedConnector} diff --git a/obp-api/src/test/scala/code/views/MappedViewsTest.scala b/obp-api/src/test/scala/code/views/MappedViewsTest.scala index c530e1f857..55f2736772 100644 --- a/obp-api/src/test/scala/code/views/MappedViewsTest.scala +++ b/obp-api/src/test/scala/code/views/MappedViewsTest.scala @@ -1,5 +1,6 @@ package code.views +import code.api.Constant import code.api.util.ErrorMessages.ViewIdNotSupported import code.setup.{DefaultUsers, ServerSetup} import code.views.system.ViewDefinition @@ -20,7 +21,7 @@ class MappedViewsTest extends ServerSetup with DefaultUsers{ val bankIdAccountId = BankIdAccountId(BankId("1"),AccountId("2")) - val viewIdOwner = "owner" + val viewIdOwner = Constant.SYSTEM_OWNER_VIEW_ID val viewIdAccountant = "accountant" val viewIdAuditor = "auditor" val viewIdNotSupport = "NotSupport" @@ -37,7 +38,7 @@ class MappedViewsTest extends ServerSetup with DefaultUsers{ var allExistingViewsForOneAccount = MapperViews.availableViewsForAccount(bankIdAccountId) Then("Check the result from database. it should have 4 views and with the right viewId") - viewOwner.head.viewId.value should equal("owner".toLowerCase()) + viewOwner.head.viewId.value should equal(Constant.SYSTEM_OWNER_VIEW_ID.toLowerCase()) viewAccountant.head.viewId.value should equal("accountant".toLowerCase()) viewAuditor.head.viewId.value should equal("auditor".toLowerCase()) allExistingViewsForOneAccount.length should equal(3) @@ -49,7 +50,7 @@ class MappedViewsTest extends ServerSetup with DefaultUsers{ allExistingViewsForOneAccount = MapperViews.availableViewsForAccount(bankIdAccountId) Then("Check the result from database again. it should have four views and with the right viewId, there should be not changed.") - viewOwner.head.viewId.value should equal("owner".toLowerCase()) + viewOwner.head.viewId.value should equal(Constant.SYSTEM_OWNER_VIEW_ID.toLowerCase()) viewAccountant.head.viewId.value should equal("accountant".toLowerCase()) viewAuditor.head.viewId.value should equal("auditor".toLowerCase()) allExistingViewsForOneAccount.length should equal(3) @@ -59,7 +60,9 @@ class MappedViewsTest extends ServerSetup with DefaultUsers{ val wrongViewId = "WrongViewId" val wrongView = MapperViews.getOrCreateSystemViewFromCbs(wrongViewId) - wrongView should equal(Failure(ViewIdNotSupported+ s"Your input viewId is :$wrongViewId")) + wrongView.toString contains ViewIdNotSupported shouldBe (true) + + wrongView.toString contains wrongViewId shouldBe(true) } diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala b/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala index 16e932fc73..bb1b3f63fa 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala @@ -27,9 +27,10 @@ TESOBE (http://www.tesobe.com/) package com.openbankproject.commons.dto import java.util.Date -import com.openbankproject.commons.model.enums.{CardAttributeType, ChallengeType, CustomerAttributeType, DynamicEntityOperation, StrongCustomerAuthentication, TransactionAttributeType, TransactionRequestStatus} +import com.openbankproject.commons.model.enums.{CardAttributeType, ChallengeType, CustomerAttributeType, DynamicEntityOperation, StrongCustomerAuthentication, SuppliedAnswerType, TransactionAttributeType, TransactionRequestStatus} import com.openbankproject.commons.model.enums.StrongCustomerAuthentication.SCA import com.openbankproject.commons.model.enums.StrongCustomerAuthenticationStatus.SCAStatus +import com.openbankproject.commons.model.enums.SuppliedAnswerType import com.openbankproject.commons.model.{enums, _} import net.liftweb.json.{JObject, JValue} @@ -112,6 +113,11 @@ case class OutBoundGetBankAccountsBalances(outboundAdapterCallContext: OutboundA case class InBoundGetBankAccountsBalances(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: AccountsBalances) extends InBoundTrait[AccountsBalances] +case class OutBoundGetBankAccountBalances(outboundAdapterCallContext: OutboundAdapterCallContext, + bankIdAccountId: BankIdAccountId) extends TopicTrait + +case class InBoundGetBankAccountBalances(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: AccountBalances) extends InBoundTrait[AccountBalances] + case class OutBoundGetCoreBankAccountsHeld(outboundAdapterCallContext: OutboundAdapterCallContext, bankIdAccountIds: List[BankIdAccountId]) extends TopicTrait case class InBoundGetCoreBankAccountsHeld(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[AccountHeld]) extends InBoundTrait[List[AccountHeld]] @@ -854,6 +860,16 @@ case class InBoundValidateChallengeAnswer(inboundAdapterCallContext: InboundAdap status: Status, data: Boolean) extends InBoundTrait[Boolean] + +case class OutBoundValidateChallengeAnswerV2(outboundAdapterCallContext: OutboundAdapterCallContext, + challengeId: String, + suppliedAnswer: String, + suppliedAnswerType: SuppliedAnswerType) extends TopicTrait + +case class InBoundValidateChallengeAnswerV2(inboundAdapterCallContext: InboundAdapterCallContext, + status: Status, + data: Boolean) extends InBoundTrait[Boolean] + //--------------------- diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/ViewModel.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/ViewModel.scala index 256ba39ec3..4cf6b06fbb 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/ViewModel.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/ViewModel.scala @@ -432,4 +432,5 @@ trait View { def canCreateCustomView: Boolean def canDeleteCustomView: Boolean def canUpdateCustomView: Boolean + def canGetCustomView: Boolean } \ No newline at end of file diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/enums/Enumerations.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/enums/Enumerations.scala index 35bd148f68..b23ae9b95c 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/enums/Enumerations.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/enums/Enumerations.scala @@ -229,6 +229,13 @@ object AttributeCategory extends OBPEnumeration[AttributeCategory]{ object TransactionRequest extends Value } +sealed trait SuppliedAnswerType extends EnumValue +object SuppliedAnswerType extends OBPEnumeration[SuppliedAnswerType]{ + object PLAIN_TEXT_VALUE extends Value + object HASH_VALUE extends Value +} + + object TransactionRequestStatus extends Enumeration { type TransactionRequestStatus = Value val INITIATED, PENDING, NEXT_CHALLENGE_PENDING, FAILED, COMPLETED, FORWARDED, REJECTED, CANCELLED, CANCELLATION_PENDING = Value diff --git a/pom.xml b/pom.xml index b8f7e7923f..a0fb316aae 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ http://scala-tools.org/mvnsites/liftweb - 8 + 11 ${java.version} ${java.version}