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 e5d5cf764d..582a3aff9b 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 @@ -1,9 +1,7 @@ package code.api.ResourceDocs1_4_0 -import java.util.Date - -import code.api.Constant._ import code.api.Constant +import code.api.Constant._ import code.api.UKOpenBanking.v2_0_0.JSONFactory_UKOpenBanking_200 import code.api.UKOpenBanking.v2_0_0.JSONFactory_UKOpenBanking_200.{Account, AccountBalancesUKV200, AccountInner, AccountList, Accounts, BalanceJsonUKV200, BalanceUKOpenBankingJson, BankTransactionCodeJson, CreditLineJson, DataJsonUKV200, Links, MetaBisJson, MetaInnerJson, TransactionCodeJson, TransactionInnerJson, TransactionsInnerJson, TransactionsJsonUKV200} import code.api.berlin.group.v1.JSONFactory_BERLIN_GROUP_1.{AccountBalanceV1, AccountBalances, AmountOfMoneyV1, ClosingBookedBody, ExpectedBody, TransactionJsonV1, TransactionsJsonV1, ViewAccount} @@ -11,37 +9,32 @@ import code.api.dynamic.endpoint.helper.practise.PractiseEndpoint import code.api.util.APIUtil.{defaultJValue, _} import code.api.util.ApiRole._ import code.api.util.ExampleValue._ -import code.api.util.{APIUtil, ApiRole, ApiTrigger, ConsentJWT, CustomJsonFormats, ExampleValue} +import code.api.util.{ApiRole, ApiTrigger, ExampleValue} import code.api.v2_2_0.JSONFactory220.{AdapterImplementationJson, MessageDocJson, MessageDocsJson} import code.api.v3_0_0.JSONFactory300.createBranchJsonV300 import code.api.v3_0_0.custom.JSONFactoryCustom300 -import code.api.v3_0_0.{LobbyJsonV330, _} -import code.api.v3_1_0.{AccountBalanceV310, AccountsBalancesV310Json, BadLoginStatusJson, ContactDetailsJson, CustomerWithAttributesJsonV310, InviteeJson, ObpApiLoopbackJson, PhysicalCardWithAttributesJsonV310, PutUpdateCustomerEmailJsonV310, _} -import code.api.v4_0_0.{AccountMinimalJson400, BankAttributeBankResponseJsonV400, CardJsonV400, CustomerMinimalJsonV400, FastFirehoseAccountsJsonV400, PostHistoricalTransactionAtBankJson, _} -import code.api.v3_1_0.{AccountBalanceV310, AccountsBalancesV310Json, BadLoginStatusJson, ContactDetailsJson, InviteeJson, ObpApiLoopbackJson, PhysicalCardWithAttributesJsonV310, PutUpdateCustomerEmailJsonV310, _} -import code.api.v5_0_0.{AccountResponseJson500, CustomerOverviewFlatJsonV500, _} +import code.api.v3_0_0._ +import code.api.v3_1_0._ +import code.api.v4_0_0._ +import code.api.v5_0_0._ +import code.api.v5_1_0._ import code.branches.Branches.{Branch, DriveUpString, LobbyString} -import code.consent.ConsentStatus import code.connectormethod.{JsonConnectorMethod, JsonConnectorMethodMethodBody} +import code.consent.ConsentStatus import code.dynamicMessageDoc.JsonDynamicMessageDoc import code.dynamicResourceDoc.JsonDynamicResourceDoc import code.sandbox.SandboxData -import com.openbankproject.commons.model.enums.TransactionRequestTypes._ -import com.openbankproject.commons.model.enums.PaymentServiceTypes._ import com.github.dwickern.macros.NameOf.nameOf import com.openbankproject.commons.model import com.openbankproject.commons.model.PinResetReason.{FORGOT, GOOD_SECURITY_PRACTICE} +import com.openbankproject.commons.model.enums.TransactionRequestTypes._ import com.openbankproject.commons.model.enums.{AttributeCategory, CardAttributeType, ChallengeType} -import com.openbankproject.commons.model.{TransactionRequestSimple, UserAuthContextUpdateStatus, ViewBasic, _} -import com.openbankproject.commons.util.{ApiVersion, FieldNameApiVersions, ReflectUtils, RequiredArgs, RequiredInfo} +import com.openbankproject.commons.model._ +import com.openbankproject.commons.util.{ApiVersion, FieldNameApiVersions, ReflectUtils} import net.liftweb.json -import java.net.URLEncoder - -import code.api.v5_1_0.{AtmsJsonV510, CustomViewJsonV510, _} -import code.endpointMapping.EndpointMappingCommons -import net.liftweb.json.{Extraction, parse} -import scala.collection.immutable.List +import java.net.URLEncoder +import java.util.Date /** * This object prepare all the JSON case classes for Swagger . @@ -55,8 +48,6 @@ object SwaggerDefinitionsJSON { implicit def convertStringToBoolean(value:String) = value.toBoolean - implicit val formats = CustomJsonFormats.formats - lazy val regulatedEntitiesJsonV510: RegulatedEntitiesJsonV510 = RegulatedEntitiesJsonV510(List(regulatedEntityJsonV510)) lazy val regulatedEntityJsonV510: RegulatedEntityJsonV510 = RegulatedEntityJsonV510( entity_id = "0af807d7-3c39-43ef-9712-82bcfde1b9ca", @@ -4230,29 +4221,7 @@ object SwaggerDefinitionsJSON { api_standard = "Berlin Group", api_version = "v1.3", jwt = "eyJhbGciOiJIUzI1NiJ9.eyJlbnRpdGxlbWVudHMiOltdLCJjcmVhdGVkQnlVc2VySWQiOiIiLCJzdWIiOiJmY2YzNDZkMi0xNTNiLTQ0MzAtOWE4Zi1mMzU3Njg1MzM5ODciLCJhdWQiOiIyNjY0NjUwYy04MDkwLTQ4MWUtOGJkOC0wM2E5MmY5Yzg3ZWEiLCJuYmYiOjE3MzAzNzMyNzEsImFjY2VzcyI6eyJhY2NvdW50cyI6W3siaWJhbiI6IlJTMzUyNjAwMDU2MDEwMDE2MTEzNzkifV19LCJpc3MiOiJodHRwczovLzEyNy4wLjAuMTo4MDgwIiwiZXhwIjoxNzMwOTM3NjAwLCJpYXQiOjE3MzAzNzMyNzEsImp0aSI6ImQzM2Y3NDYzLWVlNDktNGU4YS04YTkyLTYxMzhkYzE4M2QxNiIsInZpZXdzIjpbeyJiYW5rX2lkIjoibmxia2IiLCJhY2NvdW50X2lkIjoiOTUzODkyOTctNDVjNC00MGViLTllZmQtMzMxYmExOTQzZGE0Iiwidmlld19pZCI6IlJlYWRBY2NvdW50c0Jlcmxpbkdyb3VwIn1dfQ.SXE4W34596lrSXqZrA8cvQs_fvhjWYilU8VDpXZ3C3Y", - jwt_payload = parse("""{ - "createdByUserId": "", - "sub": "fcf346d2-153b-4430-9a8f-f35768533987", - "iss": "https://127.0.0.1:8080", - "aud": "2664650c-8090-481e-8bd8-03a92f9c87ea", - "jti": "d33f7463-ee49-4e8a-8a92-6138dc183d16", - "iat": 1730373271, - "nbf": 1730373271, - "exp": 1730937600, - "entitlements": [], - "views": [ { - "bank_id": "nlbkb", - "account_id": "95389297-45c4-40eb-9efd-331ba1943da4", - "view_id": "ReadAccountsBerlinGroup" - } - ], - "access": { - "accounts": [ { - "iban": "RS35260005601001611379" - } - ] - } - }""").extractOpt[ConsentJWT], + jwt_payload = SwaggerDefinitionsJsonUtil.jwtPayload, ) val consentsJsonV510 = ConsentsJsonV510(List(allConsentJsonV510)) diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJsonUtil.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJsonUtil.scala new file mode 100644 index 0000000000..609e51ad2d --- /dev/null +++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJsonUtil.scala @@ -0,0 +1,38 @@ +package code.api.ResourceDocs1_4_0 + +import code.api.util.ConsentJWT +import net.liftweb.json._ + +object SwaggerDefinitionsJsonUtil { + implicit val formats: Formats = DefaultFormats + + // General method to parse JSON into any case class + def parseJsonToCaseClass[T](jsonString: String)(implicit mf: Manifest[T]): Option[T] = { + parse(jsonString).extractOpt[T] + } + + // Usage example with ConsentJWT, or replace ConsentJWT with any other case class + val jwtPayload: Option[ConsentJWT] = parseJsonToCaseClass[ConsentJWT]( + """{ + "createdByUserId": "", + "sub": "fcf346d2-153b-4430-9a8f-f35768533987", + "iss": "https://127.0.0.1:8080", + "aud": "2664650c-8090-481e-8bd8-03a92f9c87ea", + "jti": "d33f7463-ee49-4e8a-8a92-6138dc183d16", + "iat": 1730373271, + "nbf": 1730373271, + "exp": 1730937600, + "entitlements": [], + "views": [ { + "bank_id": "nlbkb", + "account_id": "95389297-45c4-40eb-9efd-331ba1943da4", + "view_id": "ReadAccountsBerlinGroup" + }], + "access": { + "accounts": [ { + "iban": "RS35260005601001611379" + }] + } + }""" + ) +} 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 a3555a2978..d3be8f537a 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 @@ -8745,7 +8745,7 @@ trait APIMethods400 extends MdcLoggable { nameOf(getConsentInfos), "GET", "/banks/BANK_ID/my/consent-infos", - "Get Consents Info", + "Get My Consents Info", s""" | |This endpoint gets the Consents that the current User created. diff --git a/obp-api/src/main/scala/code/snippet/UserInformation.scala b/obp-api/src/main/scala/code/snippet/UserInformation.scala index e8b58ad431..166f71145a 100644 --- a/obp-api/src/main/scala/code/snippet/UserInformation.scala +++ b/obp-api/src/main/scala/code/snippet/UserInformation.scala @@ -43,6 +43,7 @@ class UserInformation extends MdcLoggable { private object providerVar extends RequestVar("") private object devEmailVar extends RequestVar("") private object usernameVar extends RequestVar("") + private object userIdVar extends RequestVar("") def show: CssSel = { if(!AuthUser.loggedIn_?) { @@ -52,6 +53,7 @@ class UserInformation extends MdcLoggable { } else { val user: User = AuthUser.getCurrentUser.openOrThrowException(attemptedToOpenAnEmptyBox) usernameVar.set(user.name) + userIdVar.set(user.userId) devEmailVar.set(user.emailAddress) providerVar.set(user.provider) idTokenVar.set(AuthUser.getIDTokenOfCurrentUser) @@ -61,7 +63,8 @@ class UserInformation extends MdcLoggable { "#user-info-provider" #> SHtml.text(providerVar.is, providerVar(_)) & "#user-info-email" #> SHtml.text(devEmailVar, devEmailVar(_)) & "#user-info-id-token" #> SHtml.text(idTokenVar, idTokenVar(_)) & - "#user-info-access-token" #> SHtml.text(accessTokenVar, accessTokenVar(_)) + "#user-info-access-token" #> SHtml.text(accessTokenVar, accessTokenVar(_)) & + "#user-info-user-id" #> SHtml.text(userIdVar, accessTokenVar(_)) } & "#register-consumer-success" #> "" } } diff --git a/obp-api/src/main/webapp/user-information.html b/obp-api/src/main/webapp/user-information.html index 40a84c0863..122c9fd828 100644 --- a/obp-api/src/main/webapp/user-information.html +++ b/obp-api/src/main/webapp/user-information.html @@ -57,6 +57,10 @@