@startuml
autonumber 1


skinparam titleBorderRoundCorner 15
skinparam titleBorderThickness 2
skinparam titleBorderColor red
skinparam titleBackgroundColor  Lightgreen
title TAAP with popToken Process

actor API_Partner

box "Apigee" #Lightgreen
    participant APIGEE_Proxy
    participant TMSValidateJWTPOPTokenV2
end box

group TAAP public key registeration for pop Token

note left API_Partner
Partner pre-assessment Requirement
----
1) Generate 256 bits RSA private / public keys
2) Register the public key to TFB Partner Apigee
3) Keep the private key in safe Place on Partner side
end note

API_Partner -> APIGEE_Proxy : Register the public key associated with Partner clientId \n /oauth2/v4/register/client-publickey
APIGEE_Proxy --> APIGEE_Proxy : register the public key by clientId
APIGEE_Proxy --> API_Partner : manual process (Success / failed)

end




group TAAP Access Token Process

note left API_Partner
4) Partner generates a JWT popToken
based on the RSA Private key
end note

note left API_Partner
required headers for TAAP Access Token API
----
Content-Type : application/json
Authorization : Basic <clientId:secrectId>
B2b-client : AOP
X-Authorization: <pop_token>
end note

API_Partner -> APIGEE_Proxy : POST /oauth2/v4/tokens
APIGEE_Proxy -> TMSValidateJWTPOPTokenV2 : popToken
TMSValidateJWTPOPTokenV2 -> TMSValidateJWTPOPTokenV2 : validated request signature \n by Partner public key
TMSValidateJWTPOPTokenV2 --> APIGEE_Proxy :
APIGEE_Proxy --> API_Partner :  access_token, id_token

end

== TFB API Process with TAAP ==

box "TFB Internal Service" #LightBlue
    participant TFB
    participant TAAP_Validation_library
end box


note left API_Partner
5) Partner generates a JWT popToken
based on the RSA Private key for each transaction
end note

note left API_Partner
(1) Retrieves Subscriber API
---
required headers
---
Accept : application/json
Content-Type: application/json
B2b-client : AOP
B2b-org : 7000000999999911111
Authorization : Bearer <acces_token>
X-Auth-Originator : <id_token>
X-Authorization : <pop_token>
end note

API_Partner->APIGEE_Proxy : POST /subscribers

APIGEE_Proxy -> TMSValidateJWTPOPTokenV2 : validate the pop_token
TMSValidateJWTPOPTokenV2 -> TMSValidateJWTPOPTokenV2 : validated it \n by Partner public key
TMSValidateJWTPOPTokenV2 --> APIGEE_Proxy : success


note left APIGEE_Proxy
Pass through all headers to TFB Microservices
Authorization and X-Auth-Originator headers
end note


APIGEE_Proxy->TFB: POST /subscribers

TFB -> TAAP_Validation_library : access_token and id_token
TAAP_Validation_library -> TAAP_Validation_library : validated \n the access_token and id_token
TAAP_Validation_library --> TFB : success
TFB --> TFB : process subscribers flows ( API flows)
TFB --> APIGEE_Proxy : response




APIGEE_Proxy --> API_Partner : response


note over API_Partner, APIGEE_Proxy
	Error Response On Any Call Will Terminate The Transaction
end note
@enduml