Esempio n. 1
0
        public static void Init(ClientConfig config)
        {
            if (appSettings == null)
            {
                appSettings = new Dictionary <string, string>();
            }

            client = ClientFactory.GetConfigurationServiceClient(config.ConfigurationServer, config.ConfigurationServerPort);
            if (GetServerKey() == null)
            {
                throw new InvalidOperationException("Unable to retrieve server key");
            }

            //masterEncryptedAppHash = serverKey.EncryptWithPublicKey(config.ApplicationHash);

            if (clientKey == null)
            {
                string     masterEncryptedAppHash = serverKey.EncryptWithPublicKey(config.ApplicationHash);
                RSAKeyPair tempKey = new RSAKeyPair();
                clientKey = GetClientKey(masterEncryptedAppHash, tempKey);
            }

            // if the clientKey is still null
            // we were unable to get it from the service
            if (clientKey == null)
            {
                throw new InvalidOperationException("Unable to retrieve client key.  Make sure that you are using the correct application hash");
            }
        }
Esempio n. 2
0
 public static void AbandonSettings()
 {
     client       = null;
     config       = null;
     appSettings  = null;
     lastResponse = null;
     serverKey    = null;
     clientKey    = null;
 }
 public static void AbandonSettings()
 {
     client = null;
     config = null;
     appSettings = null;
     lastResponse = null;
     serverKey = null;
     clientKey = null;
 }
Esempio n. 4
0
 private static RijndaelKeyVectorPair GetClientKey(string masterEncryptedAppHash, RSAKeyPair tempKey)
 {
     if (clientKey == null)
     {
         ConfigurationResponse clientKeyResponse = client.GetClientKey(masterEncryptedAppHash, tempKey.PublicKeyXml);
         clientKey = clientKeyResponse.ClientKey;
         if (clientKey != null)
         {
             clientKey.Base64InitializationVector = tempKey.DecryptWithPrivateKey(clientKey.Base64InitializationVector);
             clientKey.Base64Key = tempKey.DecryptWithPrivateKey(clientKey.Base64Key);
         }
     }
     return(clientKey);
 }
 private static RijndaelKeyVectorPair GetClientKey(string masterEncryptedAppHash, RSAKeyPair tempKey)
 {
     if (clientKey == null)
     {
         ConfigurationResponse clientKeyResponse = client.GetClientKey(masterEncryptedAppHash, tempKey.PublicKeyXml);
         clientKey = clientKeyResponse.ClientKey;
         if (clientKey != null)
         {
             clientKey.Base64InitializationVector = tempKey.DecryptWithPrivateKey(clientKey.Base64InitializationVector);
             clientKey.Base64Key = tempKey.DecryptWithPrivateKey(clientKey.Base64Key);
         }
     }
     return clientKey;
 }
        public static void Init(ClientConfig config)
        {
            if (appSettings == null)
                appSettings = new Dictionary<string, string>();

            client = ClientFactory.GetConfigurationServiceClient(config.ConfigurationServer, config.ConfigurationServerPort);
            if (GetServerKey() == null)
                throw new InvalidOperationException("Unable to retrieve server key");

            //masterEncryptedAppHash = serverKey.EncryptWithPublicKey(config.ApplicationHash);

            if (clientKey == null)
            {
                string masterEncryptedAppHash = serverKey.EncryptWithPublicKey(config.ApplicationHash);
                RSAKeyPair tempKey = new RSAKeyPair();
                clientKey = GetClientKey(masterEncryptedAppHash, tempKey);
            }

            // if the clientKey is still null
            // we were unable to get it from the service
            if (clientKey == null)
                throw new InvalidOperationException("Unable to retrieve client key.  Make sure that you are using the correct application hash");
        }