public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
                                        JsonSerializer serializer)
        {
            var jObject                = JObject.Load(reader);
            var installationToken      = jObject.GetValue(FIELD_TOKEN).ToString();
            var privateKeyClientString = jObject.GetValue(FIELD_PRIVATE_KEY_CLIENT).ToString();
            var keyPairClient          = SecurityUtils.CreateKeyPairFromPrivateKeyFormattedString(privateKeyClientString);
            var publicKeyServerString  = jObject.GetValue(FIELD_PUBLIC_KEY_SERVER).ToString();
            var publicKeyServer        = SecurityUtils.CreatePublicKeyFromPublicKeyFormattedString(publicKeyServerString);

            return(new InstallationContext(installationToken, keyPairClient, publicKeyServer));
        }
Esempio n. 2
0
        internal async Task InitializeInstallation()
        {
            var keyPairClient = SecurityUtils.GenerateKeyPair();

            var installationClient = Client.Installation();
            var result             = await installationClient.Create(SecurityUtils.GetPublicKeyFormattedString(keyPairClient));

            var id              = result.Get <BunqId>();
            var sessionToken    = result.Get <InstallationToken>();
            var serverPublicKey = result.Get <InstallationServerPublicKey>();

            UserStore.Installation.ClientKeyPair   = keyPairClient;
            UserStore.Installation.Id              = id.Id;
            UserStore.Installation.Token           = sessionToken.Token;
            UserStore.Installation.ServerPublicKey = SecurityUtils.CreatePublicKeyFromPublicKeyFormattedString(serverPublicKey.ServerPublicKey);
        }
 internal InstallationContext(Installation installation, RSA keyPairClient) :
     this(installation.SessionToken.Token, keyPairClient,
          SecurityUtils.CreatePublicKeyFromPublicKeyFormattedString(installation.GetPublicKeyServerString()))
 {
 }