Step by step instructions for service providers on how to Signing using CIBA and SIM certificate.
Table of Contents
Requirements
For all steps to be successful the following must be at hand.
During setup
Client Id (received from Auðkenni)
Client secret (received from Auðkenni)
Related party (not necessary)
Base URI (received from Auðkenni)
Private Key (to sign a JSON Web Token)
Public Key (to give to Auðkenni for configuration)
Information needed at runtime
User’s mobile number
Message text for user (Including any verification messages: number, text etc.)
Setup requirements used in the examples
Client id: myCibaClientId
Client secret: MyApiClientP4$sW
Base URI: pfzww.audkenni.is
Private Key: Not shown here for security reasons
Public Key: Not shown
Step 1
Step 1: (Creating JSON Web Token)
The first step is to create a signed JWT to use for CIBA communication.
What the JWT need to include
login_hint (the users mobile number)
scope (openid, profile, signature. Also possible to add “related party” info here (see example))
acr_values (“sim-sign”. This value is different between authentication/signing methods)
iss (the Client id)
aud (Should have “https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni“)
exp (the lifetime of the token)
binding_message (the message to display at users mobile device)
binding_content (base64 string of a SHA256 hash)
Also needed to create the JWT
Private key (to sign the JWT)
Alg info (Should be “RS256”)
Example of JWT
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJsb2dpbl9oaW50IjoiOTg3NjU0MyIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgc2lnbmF0dXJlIFJFTEFURURQQVJUWTpNeU93bkNsaWVudCIsImFjcl92YWx1ZXMiOiJzaW0tc2lnbiIsImlzcyI6Im15Q2liYUNsaWVudElkIiwiYXVkIjoiaHR0cHM6Ly9wZnp3dy5hdWRrZW5uaS5pczo0NDMvc3NvL29hdXRoMi9yZWFsbXMvcm9vdC9yZWFsbXMvYXVka2VubmkiLCJleHAiOjE2MTExNDE4MDMuOTgxLCJiaW5kaW5nX21lc3NhZ2UiOiJBdcOwa2VubmkgU0lNIFNpZ25pbmciLCJiaW5kaW5nX2NvbnRlbnQiOiJQR1RMZitkeUtZU0EvR0tRMnJacUVRZXBmL3JZSExnZ0pyY3RZa0xHYlN3PSJ9.NzjNby1ENFpQgSy0GukuH29SyPThjv0TNJ-eQGihJh_xl9QkRnFztDIydEuUYqgaEe3S6g1u0-xr5_Qd4ua76m05TJZzdSzFChFsZyAfVqkWWlPfTZX-IEDqlugD6bFM3lNsgzjvR7hTYVnmoOMu8d3tt1He-VpOi_cgIi4aPV6HaTq8izNVYB-shXLKGQ8cQdRXYHVrKQJPmsu72FOdfWAulg5Mlegjaon-GkHPHNVEaBksGPm0LQ4DsVsr1QNJutIFIOO_TlJEgFk51pP_dEB6WdvGJAhhWAPeA7vhxLi6qJ9zLKUkJKxhzsnRvh388NwkzOUbhVyQDFq7bzKyOA
Example of JWT Payload
{ "login_hint": "9876543", "scope": "openid profile signature RELATEDPARTY:MyOwnClient", "acr_values": "sim-sign", "iss": "myCibaClientId", "aud": "https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni", "exp": 1611141803.981, "binding_message": "Auðkenni SIM Signing", "binding_content": "PGTLf+dyKYSA/GKQ2rZqEQepf/rYHLggJrctYkLGbSw=" }
Step 2
Step 2: (Authorize)
To authorize using mobile (SIM) we send a POST call to following URI:
https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/bc-authorize
Parameters needed in call
We need to add following header parameter
A Basic Auth header, using the Client id and Client secret
We need to add following parameter
request (the value should be the JWT from step 1)
CURL example of the call
curl --location --request POST 'https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/bc-authorize' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header 'Authorization: Basic bXlDaWJhQ2xpZW50SWQ6TXlBcGlDbGllbnRQNCRzVw==' \ --data-urlencode 'request=eyJ0eXAiOiJKV1QuLCJhbGciOiJSUzI1NiJ9.eyJeb2dpbl9oaW58IjoiNjE3ODg4OCIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgc2lnbmF0dXJlIFJFTEFURURQQVJUWTpNeU93bkNsaWVudCIsImFjcl92YWx1ZXMiOiJzaW0tYXV0aCIsImlzcyI6Im15Q2liYUNsaWVudElkIiwiYXVkIjoiaHR0cHM6Ly9wZnp3dy5hdWRrZW5uaS5pczo0NDMvc3NvL29hdXRoMi9yZWFsbXMvcm9vdC9yZWFsbXMvYXVka2VubmkiLCJleHAiOjE2MTEwNzIxODQuOTkyLCJiaW5kaW5nX21lc3NhZ2UiOiJBdXRoZW50aWNhdGlvbiB0byBBdcOwa2VubmkiLCJiaW5kaW5nX2NvbnRlbnQiOiIifQ.a0NM11W2PNyfzki-gHTrQZqVhuNgL6Uh4sjQQy96lHsfD1NkVe7h-41JT9to-c710GpSvF1ExAcb7b7Bjmy6Ep0M3BVuz066fzv0YfiIHbXd6pQIEXVqUxHQ6mteW1MmaI-xsYDgG_ahXS7ZD8VrN2y1hOGUt1P4kMnVkWVpSQBjolxsZdV1HYn7n9Iy1z0gNaZb_3EIiNGLAHzI2zaDG4x0SFl-vkslf0eqfBMyEquKNFeoBqLLW7WT-PXpIaCQuJ_7ohqbx-pO_JI9Hm2Fv-VH9HoXUhsXWxig3YcQVqYBzq5aEdrE_mulCJMGeCWM02HTxpHennN5GdttlGVksg'
C# - RestSharp example of the call
var client = new RestClient("https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/bc-authorize"); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", "Basic bXlDaWJhQ2xpZW50SWQ6TXlBcGlDbGllbnRQNCRzVw=="); request.AddParameter("request", "eyJ0eXAiOiJKV1QuLCJhbGciOiJSUzI1NiJ9.eyJeb2dpbl9oaW58IjoiNjE3ODg4OCIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgc2lnbmF0dXJlIFJFTEFURURQQVJUWTpNeU93bkNsaWVudCIsImFjcl92YWx1ZXMiOiJzaW0tYXV0aCIsImlzcyI6Im15Q2liYUNsaWVudElkIiwiYXVkIjoiaHR0cHM6Ly9wZnp3dy5hdWRrZW5uaS5pczo0NDMvc3NvL29hdXRoMi9yZWFsbXMvcm9vdC9yZWFsbXMvYXVka2VubmkiLCJleHAiOjE2MTEwNzIxODQuOTkyLCJiaW5kaW5nX21lc3NhZ2UiOiJBdXRoZW50aWNhdGlvbiB0byBBdcOwa2VubmkiLCJiaW5kaW5nX2NvbnRlbnQiOiIifQ.a0NM11W2PNyfzki-gHTrQZqVhuNgL6Uh4sjQQy96lHsfD1NkVe7h-41JT9to-c710GpSvF1ExAcb7b7Bjmy6Ep0M3BVuz066fzv0YfiIHbXd6pQIEXVqUxHQ6mteW1MmaI-xsYDgG_ahXS7ZD8VrN2y1hOGUt1P4kMnVkWVpSQBjolxsZdV1HYn7n9Iy1z0gNaZb_3EIiNGLAHzI2zaDG4x0SFl-vkslf0eqfBMyEquKNFeoBqLLW7WT-PXpIaCQuJ_7ohqbx-pO_JI9Hm2Fv-VH9HoXUhsXWxig3YcQVqYBzq5aEdrE_mulCJMGeCWM02HTxpHennN5GdttlGVksg"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);
Step 2: Expected response
The CIBA service answer is in JSON format.
When Step 2 is executed the authentication process at the users device starts.
The response should include following
auth_req_id (to use in next step)
expires_in (the lifetime of th id)
interval
Example of answer from Step 2
{ "auth_req_id": "8ag4NXa4ctFJuv1h9EtUnfNeFww", "expires_in": 600, "interval": 2 }
Step 3
Step 3: (Poll for token)
After executing Step 2 the authentication process at the users device starts. It depends on the user, the device and the network how long time this process takes.
In this step we poll for results from the authentication process. When authentication process is finished successfully you will receive answer with Access and Id token of the user authenticated.
To poll for tokens we send another POST call to following URI:
https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/access_token
Parameters needed in call
We need to add following header parameter
A Basic Auth header, using the Client id and Client secret
We need to add following parameter
grant_type (the value should be: “urn:openid:params:grant-type:ciba”)
auth_req_id (the value should be the auth_req_id from last step answer)
CURL example of the call
curl --location --request POST 'https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/access_token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header 'Authorization: Basic bXlDaWJhQ2xpZW50SWQ6TXlBcGlDbGllbnRQNCRzVw==' \ --data-urlencode 'grant_type=urn:openid:params:grant-type:ciba' \ --data-urlencode 'auth_req_id=byMGRumm7nantLLD7e4viiJ_ZTU'
C# - RestSharp example of the call
var client = new RestClient("https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/access_token"); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", "Basic bXlDaWJhQ2xpZW50SWQ6TXlBcGlDbGllbnRQNCRzVw=="); request.AddParameter("grant_type", "urn:openid:params:grant-type:ciba"); request.AddParameter("auth_req_id", "byMGRumm7nantLLD7e4viiJ_ZTU"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);
Step 3: Expected response (Authentication still in process)
If you run the poll call before the user authentication process is finished you will receive a answer notifying the process isn’t finished.
The REST API service answer is in JSON format.
If you get answer like this you need to wait for short time and run Step 3 call again.
The response should include following
error_description
error
Example of answer from Step 3
{ "error_description": "End user has not yet been authenticated", "error": "authorization_pending" }
Step 3: Expected response (Authentication is finished)
The answer from this call should give you the Access and Id tokens along type and lifetime info.
The Id token contains a PKCS7 signature. The signature contains a authentication certificate.
The REST API service answer is in JSON format.
Best practice
Best practice is to verify the signature and the certificate. Verify the user’s info in the Id token against the certificate in the signature.
The response should include following
access_token
id_token
token_type
expires_in (lifetime of the tokens)
Example of answer from step 5
{ "access_token": "eyJ0eXAiOiJKV1QiLCJ6aXAiOiJOT05FIiwiYWxnIjoiSFMyNTYifQ.eyJzdWIiOiIxMDkwNWYxZS0yNjA4LTRmOWMtODBkMi0zZmI0NTI0MTUyMmMiLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXV0aF9sZXZlbCI6MCwiYXVkaXRUcmFja2luZ0lkIjoiZWQ5NzcwMTgtOWMxYy00MDM3LWFkNTgtYzYxZGMyMjQ4MGE4LTkzNDA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CIXGdnrg0GdBIlznfuuyFKOK2Uo0dt-HjNtJJ8MbQcRNHAC2myUKf_PYDKOv_4OXFk3mS9z7_ECQIUXGKndg7250Uau46sjYj_Aigbqk08YbxoWaaKaQDZUp58WmuwIYATaYi2yJMllkKWeA1fJzrzX_cwXksXO1ulyYQiZ28nr92s-8piZpxs-6Tmo7hRg3AkNApvAYpwbGth1JrFxv_tN9SX4YaVhUFnS5D3Kn9BEcKGq6gGtmdKVexPcAudOCwVSvhIQBj2PbU5oJcKVbMClO03oTeiY_aWFeTEu8-qqc5P5wlgjCudg", "token_type": "Bearer", "expires_in": 3599 }
Example of the payload in Access token
{ "sub": "10935f1e-2638-4f9c-80d2-3fb45241522c", "cts": "OAUTH2_STATELESS_GRANT", "auth_level": 0, "auditTrackingId": "ed977018-9c1c-4037-ad58-c61dc22480a8-934001", "iss": "https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni", "tokenName": "access_token", "token_type": "Bearer", "authGrantId": "OOFQmzkBrVztphKqHRoFAPwpo_8", "aud": "myCibaClientId", "nbf": 1611073662, "grant_type": "urn:openid:params:grant-type:ciba", "scope": [ "RELATEDPARTY:MyOwnClient", "signature", "openid", "profile" ], "auth_time": 1611073662, "realm": "/audkenni", "exp": 1611077262, "iat": 1611073662, "expires_in": 3600, "jti": "O8ZnETheosfUpVwsjo5fv9sFwyg" }
Example of the payload in Id token
{ "at_hash": "-ebdK9snWHIG2gSnF3c1Xg", "sub": "10935f1e-2638-4f9c-80d2-3fb45241522c", "signature": "MIIIXAYJKmZIhvcNAQcCoIIITTCCCEkCAQExDTALBglghkgBZKMEAgEwQwYJKoZIhvcNAQcBoDYENABBAHUAdABoAGUAbgB0AGkAYwBhAHQAaQBvAG4AIAB0AG8AIABBAHUA8ABrAGUAbgBuAGmgggXWMIIF0jCCBLqgAwIBAgIDHwFgMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAklTMRMwEQYDVQQFEwo1MjEwMDAyNzkwMRUwEwY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wQCAaBlMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwGAYKKoZIhvcNAQkZAzEKBAiMTwzX0b04jzAvBgkqhkiG9w0BCQQxIgQgV5jKfht/dRJvgA6gUu1LRVEEV5F/lf8XCmtZFTYjFWYwCwYJKoZIhvcNAQEBBIIBAEEk0VLvO5fGYuHFOvc5g0e4uA9QzhMjJlN94n70rq9l91QkxeiHd4E6npj/Ye+eUlPW5PAnDlR9y4N+rAZuqL8f4Z9F/C1u7LZ64uVGFTnsl9rhsTWKdPfHSGBBByU1aKU4f+D69dS97VDIFNid//7Febs0UmQlv3c6xPG3JRwUhEuwdIfKNGS86wEAwmb2SbhoQG79j2Hu7aozS3h65kAWLxn8M9/BUSqmc3ysyAu5YY4avLuE+ffn3hldzZy/VDGe3o2+X7G525VSxFAuFsDvIU/a5YC928hMSlV1COtvDip0NH85arjHhQ/0WHveGMm5KnIpawBeUSqqJTapMUI=", "auditTrackingId": "ed977018-9c1c-4037-ad58-c61dc22480a8-934003", "certificate": "na", "iss": "https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni", "tokenName": "id_token", "aud": "myCibaClientId", "documentNr": "na", "nationalRegisterId": "1406714889", "azp": "myCibaClientId", "auth_time": 1611073662, "name": "Einar Helgi Hrafnsson", "realm": "/audkenni", "exp": 1611077262, "tokenType": "JWTToken", "iat": 1611073662 }
Step 4
Step 4: (Userinfo)
Here we ask for the users info using the Access token as Authorization header parameter.
To get the Userinfo we send a POST call to following URI:
https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/userinfo
Parameters needed in call
We need to add following header parameter
Token (Bearer, using the Access token from last call as value)
CURL example of the call
curl --location --request POST 'https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/userinfo' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJ6aXAiOiJOT25FIiwiYWxnIjoiSFMyNTYifQ.eyJzdWIIOiIxMDkwNWYxZS0yNjA4LTRmOWMtODBkMi0zZmI0NTI0MTUyMmMiLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXV0aF9sZXZlbCI6MCwiYXVkaXRUcmFja2luZ0lkIjoiZWQ5NzcwMTgtOWMxYy00MDM3LWFkNTgtYzYxZGMyMjQ4MGE4LTkzNzUyMCIsImlzcyI6Imh0dHBzOi8vcGZ6d3cuYXVka2VubmkuaXM6NDQzL3Nzby9vYXV0aDIvcmVhbG1zL3Jvb3QvcmVhbG1zL2F1ZGtlbm5pIiwidG9rZW5OYW1lIjoiYWNjZXNzX3Rva2VuIiwidG9rZW5fdHlwZSI6IkJlYXJlciIsImF1dGhHcmFudElkIjoiWHY1Yl9odXNGdklGeXJlOU1yZHRsTXVVM3djIiwiYXVkIjoibXlDaWJhQ2xpZW50SWQiLCJuYmYiOjE2MTEwNzQ3ODUsImdyYW50X3R5cGUiOiJ1cm46b3BlbmlkOnBhcmFtczpncmFudC10eXBlOmNpYmEiLCJzY29wZSI6WyJSRUxBVEVEUEFSVFk6TXlPd25DbGllbnQiLCJzaWduYXR1cmUiLCJvcGVuaWQiLCJwcm9maWxlIl0sImF1dGhfdGltZSI6MTYxMTA3NDc4NSwicmVhbG0iOiIvYXVka2VubmkiLCJleHAiOjE2MTEwNzgzODUsImlhdCI6MTYxMTA3NDc4NSwiZXhwaXJlc19pbiI6MzYwMCwianRpIjoiV2dBX3B0RzJoYmcyN3hoeXYyMktYTmNFeEVrIn0.k9AGl4MVncfmmq9USabdxlaIYlYC0_lrQhJFClZgRtM'
C# - RestSharp example of the call
var client = new RestClient("https://pfzww.audkenni.is:443/sso/oauth2/realms/root/realms/audkenni/userinfo"); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJ6aXAiOiJOT25FIiwiYWxnIjoiSFMyNTYifQ.eyJzdWIIOiIxMDkwNWYxZS0yNjA4LTRmOWMtODBkMi0zZmI0NTI0MTUyMmMiLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXV0aF9sZXZlbCI6MCwiYXVkaXRUcmFja2luZ0lkIjoiZWQ5NzcwMTgtOWMxYy00MDM3LWFkNTgtYzYxZGMyMjQ4MGE4LTkzNzUyMCIsImlzcyI6Imh0dHBzOi8vcGZ6d3cuYXVka2VubmkuaXM6NDQzL3Nzby9vYXV0aDIvcmVhbG1zL3Jvb3QvcmVhbG1zL2F1ZGtlbm5pIiwidG9rZW5OYW1lIjoiYWNjZXNzX3Rva2VuIiwidG9rZW5fdHlwZSI6IkJlYXJlciIsImF1dGhHcmFudElkIjoiWHY1Yl9odXNGdklGeXJlOU1yZHRsTXVVM3djIiwiYXVkIjoibXlDaWJhQ2xpZW50SWQiLCJuYmYiOjE2MTEwNzQ3ODUsImdyYW50X3R5cGUiOiJ1cm46b3BlbmlkOnBhcmFtczpncmFudC10eXBlOmNpYmEiLCJzY29wZSI6WyJSRUxBVEVEUEFSVFk6TXlPd25DbGllbnQiLCJzaWduYXR1cmUiLCJvcGVuaWQiLCJwcm9maWxlIl0sImF1dGhfdGltZSI6MTYxMTA3NDc4NSwicmVhbG0iOiIvYXVka2VubmkiLCJleHAiOjE2MTEwNzgzODUsImlhdCI6MTYxMTA3NDc4NSwiZXhwaXJlc19pbiI6MzYwMCwianRpIjoiV2dBX3B0RzJoYmcyN3hoeXYyMktYTmNFeEVrIn0.k9AGl4MVncfmmq9USabdxlaIYlYC0_lrQhJFClZgRtM"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);
Step 4: Expected response
The answer from this call should give you a PKCS7 Signature. The same signature as is in the Id token from last step.
The signature contains a authentication certificate.
The REST API service answer is in JSON format.
Best practice
Best practice is to verify the signature and the certificate. Verify the user’s info in the answer against the info in the certificate.
The response should include following
signature (PKCS7)
documentNr (should be “na”)
certificate (should be “na”)
nationalRegisterId (The social id number of the user)
name (The users name)
sub (A unique Id of the user in our system)
Example of answer from step 6
{ "signature": "MIIIdgYJKoZIhvcNAQcCoIIUZzCCCGMBAQExDTALBclghkgBZQMEAgEwXQYJMoZIhvcNAQcBoFAETgBBAHUAdABoAGUAbgB0AGkAYwBhAHQAaQBvAG4AIAB0AG8AIABBAHUA8ABrAGUAbgBuAGkAIAAtACAAQwBvAGQAZQA6ACAAMQAyADMANKCCBdYwggXSMIIEuqADAgECAgMfAWAwDQYJKoZIhvcNAQELBQAwfjELMAkGA1UEBhMCSVMxEzARBgNVBAUTCjUyMTAwMDI3OTAxFTATBgNVBAoTDEF1ZGtlbm5pIGhmLjEnMCUGA1UECxMeVXRnZWZhbmRpIGZ1bGxnaWxkcmEgc2tpbHJpa2phMRowGAYDVQQDExFGdWxsZ2lsdCBhdWRrZW5uaTAeFw0yMDA3MjcxMzQzMDNaFw0yNTA3MjcxMzQzMDFaMIGMMQswCQYDVQQGEwJJUzEWMBQGA1UECxMNZWlua2Fza2lscmlraTEUMBIGA1UECwwLQXXDsGtlbm5pbmcxFzAVBgNVBAsTDjIwMjAwNzI3MTM0MjA3MRMwEQYDVQQFEwoxNTA1NzE0NDg5MSEwHwYDVQQDDBhFaW5hciDDgXJzw6ZsbCBIcmFmbnNzb24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5Ed3IdytmZcwifRteBz7cCW/skhoKaxQOva9MK2shitQfjolZCytUiNaQsI7+YmANqJyvcqqocZCgLu6PcsobC0L+drpmFdHsxSR3a4hfizMJz/pPX4M1/7xRB6XNjh4NF/LR+WM5Hp1B2z8eyTsE2pXSOoW7P8AFyEuPajEOg9lz1zgtWZhsaY+frHdOe+KHzhMQdNF134jAfFZNLV+22/un68CMzQ2kM454ZxSUY0diz7vyMpYiUVM4BFvCVCqepuwXGhOKPHCtLfkIzRRE/j3+od2uXsMU8m1ACkXoNaJiblJTl3h1IrI3rXEI6gj2LlhxQ8tMvFzDQMZQGdt3AgMBAAGjggJIMIIC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MBQG4wk9mxVh76SwooduYFzZO8ziIa0tMhmnQKEUcafPploR2OUYtTqIvaN/3DEUXO2nr+V1sKdU7lUGVzC0RUxggIUMIICEAIBATCBhTB+MQswCQYDVQQGEwJJUzETMBEGA1UEBRMKNTIxMDAwMjc5MDEVMBMGA1UEChMMQXVka2VubmkgaGYuMScwJQYDVQQLEx5VdGdlZmFuZGkgZnVsbGdpbGRyYSBza2lscmlramExGjAYBgNVBAMTEUZ1bGxnaWx0IGF1ZGtlbm5pAgMfAWAwCwYJYIZIAWUDBAIBoGUwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAYBgoqhkiG9w0BCRkDMQoECIxPDNfRvTiPMC8GCSqGSIb3DQEJBDEiBCBconuOcWdR375x6x9Rc1rzRnb5YwbDUwSDiPWin8tY8jALBgkqhkiG9w0BAQEEggEAU76bsrH+g8KSayst7lEbV0aBvd0l2CNtUaOpitNs+7xVL9+1wlnQ6MgqU2VUSstZ2x+oyynDt097+QNvvBfVA+8T7MgMqkK726agdWnposwY/K5d1zfxDoFQoV4RmWuQ5ETaTYO0mmVTLwy9uskPBdQuUMNpwmRv7jXeMjkUimMECZVaeRZb34FTkcGYTAQhIO+XVqPCFqSaxi0aNNOX9rPYHuxLhTGfr8FBg2BZPICDH4uJdlBrimeZU0vdBxWytOtSN5bpeoKePCbtKJXYlvN2siWxxbwaitJ6YyTHcieLbuc2BhNtv9OpMCvKqZdV4T972nnls7pOcXY4QvTRWQ==", "documentNr": "na", "certificate": "na", "nationalRegisterId": "1406714889", "name": "Einar Helgi Hrafnsson", "sub": "10905f2e-2618-4f8c-80d2-3fb45241522c" }