Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FIT-Connect-SDK - .NET
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
FIT-Connect-SDK - .NET
Commits
351d6b00
Commit
351d6b00
authored
2 years ago
by
Klaus Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Exporting public key via callback
parent
0b7e36ed
No related branches found
No related tags found
3 merge requests
!18
Feature/651 outsource crypto
,
!17
Feature/638 xml data
,
!15
Feature/580 encrypted data
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
DemoRunner/SenderDemo.cs
+3
-2
3 additions, 2 deletions
DemoRunner/SenderDemo.cs
FitConnect/Interfaces/Sender/ISender.cs
+6
-2
6 additions, 2 deletions
FitConnect/Interfaces/Sender/ISender.cs
FitConnect/Sender.cs
+8
-5
8 additions, 5 deletions
FitConnect/Sender.cs
with
17 additions
and
9 deletions
DemoRunner/SenderDemo.cs
+
3
−
2
View file @
351d6b00
using
System.Threading.Channels
;
using
FitConnect
;
using
FitConnect.Models
;
using
Microsoft.Extensions.Configuration
;
...
...
@@ -29,9 +30,9 @@ public static class SenderDemo {
var
destinationId
=
config
[
"FitConnect:Sender:DestinationId"
];
var
leikaKey
=
config
[
"FitConnect:Sender:LeikaKey"
];
Client
var
sender
=
Client
.
GetSender
(
FitConnectEnvironment
.
Testing
,
clientId
,
clientSecret
,
logger
)
.
WithDestination
(
destinationId
)
.
WithDestination
(
destinationId
,
(
key
)
=>
Console
.
WriteLine
(
key
)
)
.
WithServiceType
(
"FIT Connect Demo"
,
leikaKey
)
.
WithEncryptedAttachments
(
new
Dictionary
<
string
,
string
>())
.
WithEncryptedMetaData
(
""
)
...
...
This diff is collapsed.
Click to expand it.
FitConnect/Interfaces/Sender/ISender.cs
+
6
−
2
View file @
351d6b00
...
...
@@ -10,10 +10,12 @@ public interface ISender : IFitConnectClient {
/// <param name="ags"></param>
/// <param name="ars"></param>
/// <param name="areaId"></param>
/// <param name="receivedPublicKey">Callback for presenting the public key</param>
/// <returns></returns>
public
ISenderWithDestination
FindDestinationId
(
string
leiaKey
,
string
?
ags
=
null
,
string
?
ars
=
null
,
string
?
areaId
=
null
);
string
?
areaId
=
null
,
Action
<
string
>?
receivedPublicKey
=
null
);
/// <summary>
/// Configures the client for the given destination and loads the public key
...
...
@@ -22,6 +24,8 @@ public interface ISender : IFitConnectClient {
/// unique identifier of the clients destination
/// <para>eg: 00000000-0000-0000-0000-000000000000</para>
/// </param>
/// <param name="receivedPublicKey">Callback for presenting the public key</param>
/// <returns>the upload step for attachments</returns>
public
ISenderWithDestination
WithDestination
(
string
destinationId
);
public
ISenderWithDestination
WithDestination
(
string
destinationId
,
Action
<
string
>?
receivedPublicKey
=
null
);
}
This diff is collapsed.
Click to expand it.
FitConnect/Sender.cs
+
8
−
5
View file @
351d6b00
...
...
@@ -30,7 +30,7 @@ namespace FitConnect;
/// </example>
public
partial
class
Sender
:
FitConnectClient
,
ISender
,
ISenderWithDestination
,
ISenderWithAttachments
,
ISenderWithData
,
ISenderWithService
,
IWithEncryptedAttachments
,
ISenderWithEncryptedMetaData
,
ISenderWithEncryptedData
{
ISenderWithEncryptedMetaData
,
ISenderWithEncryptedData
{
public
string
?
PublicKey
{
get
;
set
;
}
public
Submission
?
Submission
{
get
;
set
;
}
...
...
@@ -46,22 +46,25 @@ public partial class Sender : FitConnectClient, ISender, ISenderWithDestination,
public
ISenderWithDestination
FindDestinationId
(
string
leiaKey
,
string
?
ags
=
null
,
string
?
ars
=
null
,
string
?
areaId
=
null
)
{
string
?
areaId
=
null
,
Action
<
string
>?
receivedPublicKey
=
null
)
{
if
(
ags
==
null
&&
ars
==
null
&&
areaId
==
null
)
throw
new
ArgumentException
(
"One of the following must be provided: ags, ars, areaId"
);
var
destinationId
=
RouteService
.
GetDestinationIdAsync
(
leiaKey
,
ags
,
ars
,
areaId
).
Result
;
Logger
?.
LogInformation
(
"Received destinations: {Destinations}"
,
destinationId
.
Select
(
d
=>
d
.
DestinationId
).
Aggregate
((
a
,
b
)
=>
a
+
","
+
b
));
return
WithDestination
(
destinationId
.
First
().
DestinationId
);
return
WithDestination
(
destinationId
.
First
().
DestinationId
,
receivedPublicKey
);
}
public
ISenderWithDestination
WithDestination
(
string
destinationId
)
{
public
ISenderWithDestination
WithDestination
(
string
destinationId
,
Action
<
string
>?
receivedPublicKey
=
null
)
{
if
(!
Regex
.
IsMatch
(
destinationId
,
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
))
throw
new
ArgumentException
(
"The destination must be a valid GUID"
);
Submission
=
CreateSubmission
(
destinationId
).
Result
;
if
(
PublicKey
!=
null
)
receivedPublicKey
?.
Invoke
(
PublicKey
!);
return
this
;
}
...
...
@@ -183,7 +186,7 @@ public partial class Sender : FitConnectClient, ISender, ISenderWithDestination,
return
submission
;
}
internal
async
Task
<
string
>
GetPublicKeyFromDestination
(
string
destinationId
)
{
public
async
Task
<
string
>
GetPublicKeyFromDestination
(
string
destinationId
)
{
var
publicKey
=
await
DestinationService
.
GetPublicKey
(
destinationId
);
var
keyIsValid
=
new
CertificateHelper
(
Logger
).
ValidateCertificate
(
publicKey
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment