@startuml
'-----START auto generated metadata please keep comment here to allow auto update-----
'-----DON'T EDIT THIS SECTION, INSTEAD RE-RUN prebuild.sh TO UPDATE-----
header [[https://www.nghinhut.dev?from=http%5C%3A%5C%2F%5C%2Fwww%5C.plantuml%5C.com%5C%2Fplantuml%5C%2Fproxy%3Ffmt%3Dsvg%5C%26src%3Dhttps%5C%3A%5C%2F%5C%2Fgitlab%5C.com%5C%2Fnghinhut%5C%2Fdocs%5C%2Fraw%5C%2F9afacf787796dfb7c1260b818c0c61e3649fc73f%5C%2Fplantuml%5C%2FIdM%5C%2Fuc02%5C.puml%0A @nghinhut]]
footer [[http://www.plantuml.com/plantuml/proxy?fmt=svg&src=https://gitlab.com/nghinhut/docs/raw/9afacf787796dfb7c1260b818c0c61e3649fc73f/plantuml/IdM/uc02.puml https://gitlab.com/nghinhut/docs/blob/9afacf787796dfb7c1260b818c0c61e3649fc73f/plantuml/IdM/uc02.puml]]
'-----END auto generated metadata please keep comment here to allow auto update-----
title List Users Stream
!$BASE_URL = "http://www.plantuml.com/plantuml/proxy?fmt=svg&src=" + %getenv("CI_PROJECT_URL") + "/raw/master"

participant "Client" as client
participant "IdM Service" as idm
participant "IdM Database" as db
participant "UMA2 Authorization Server" as as
participant "Encryption Service" as es

ref over client, idm, as
    [[$BASE_URL/IdM/create-permission-ticket.function.puml{} Create Permission Ticket]] with resources scopes = [ 'list-users' ]
end

client ->> idm : list users
activate idm
    ref over idm
        [[$BASE_URL/IdM/query-encrypted-users.function.puml Query Encrypted Users]] with empty query
    end

    loop for each user in users <//encrypted//>
        idm -> idm : userMsg = new idmGrpc.User()     // proto message
        loop for each attribute in user's attributes
            ref over idm, es
                Decrypt user's attribute by [[$BASE_URL/IdM/decryption.function.puml{} Decryption(attribute)]]
            end

            idm -> idm : userMsg.set(attribute //<decrypted>//, value)
        end

        client <<-- idm : write userMsg
    end

deactivate idm
@enduml
