public void CanSign()
        {
            var domain = new Domain
            {
                Name = "example.com",
                DnsEntries = new[]
                {
                    new DnsEntry { Name = "@", Expire = 86400, Type = DnsEntryType.A, Content = "80.69.67.46" },
                    new DnsEntry { Name = "@", Expire = 86400, Type = DnsEntryType.MX, Content = "10 @" },
                    new DnsEntry { Name = "@", Expire = 86400, Type = DnsEntryType.MX, Content = "20 relay.transip.nl." },
                    new DnsEntry { Name = "ftp", Expire = 86400, Type = DnsEntryType.CNAME, Content = "@" },
                    new DnsEntry { Name = "mail", Expire = 86400, Type = DnsEntryType.CNAME, Content = "@" },
                    new DnsEntry { Name = "www", Expire = 86400, Type = DnsEntryType.CNAME, Content = "@" }
                }
            };

            var timestamp = "1352842387";
            var nonce = "50a2bc93d5e3e6.28404859";

            var signature = EncryptionHelper.Encode(EncryptionHelper.Sign(PrivateKey, new object[]
            {
                domain,
                new KeyValuePair<string, string>("__method", "register"),
                new KeyValuePair<string, string>("__service", "DomainService"),
                new KeyValuePair<string, string>("__hostname", "api.transip.nl"),
                new KeyValuePair<string, string>("__timestamp", timestamp),
                new KeyValuePair<string, string>("__nonce", nonce)
            }));

            // Expected signature taken from PHP example and replicated here in .NET
            const string expected = "wghhEAhMJNt4a4Rxun3oTODB4sJSvfJNYDkNqxO3PkWCkdpRrSh9MgiVCkUeAbl0zBrWf5SIXAsQSwBSrT0hoj3MyVs7XFNnod%2Finen3cLh65JCdVTS%2BRqNDqOlPzeI0AQ8tnuUXjgR%2Fr%2BxFaUJxrdirVsDt%2B4KaIurmztsY4U8%2BBLMBCS9HDoYKMJUFIGlWWHcYpNVIyg%2F8FzfXQRqDPfqOkzg%2FuXQA0%2BVF49zQewxdEYI6qLKPl8T%2BoWv%2FjgvlJZydmp378woawbngE5tQ%2FEQbOfgAHBM9i%2BwhbRFH%2FWpEy%2BJZPyhvV2sQxiDjjVFMX1A%2F9ue0rVNnjBKj86f2Rg%3D%3D";
            Assert.AreEqual(expected, signature);
        }
Esempio n. 2
0
 /// <summary>
 /// Cancels a failed domain action.
 /// </summary>
 /// <param name="domain">The domain to cancel the action for.</param>
 public void CancelDomainAction(Domain domain)
 {
     SetSignatureCookies("cancelDomainAction", new object[] { domain });
     Client.cancelDomainAction(Mapper.Map <Remote.Domain>(domain));
 }
Esempio n. 3
0
 /// <summary>
 /// Retries a failed domain action with new domain data. The Domain#name field must contain
 /// the name of the Domain, the nameserver, contacts, dnsEntries fields contain the new data for this domain.
 /// Set a field to null to not change the data.
 /// </summary>
 /// <param name="domain">The domain with data to retry.</param>
 public void RetryCurrentDomainActionWithNewData(Domain domain)
 {
     SetSignatureCookies("retryCurrentDomainActionWithNewData", new object[] { domain });
     Client.retryCurrentDomainActionWithNewData(Mapper.Map <Remote.Domain>(domain));
 }
Esempio n. 4
0
 /// <summary>
 /// Retry a transfer action with a new authcode.
 /// </summary>
 /// <param name="domain">The domain to try the transfer with a different authcode for.</param>
 /// <param name="newAuthCode">New authorization code to try.</param>
 public void RetryTransferWithDifferentAuthCode(Domain domain, string newAuthCode)
 {
     SetSignatureCookies("retryTransferWithDifferentAuthCode", new object[] { domain, newAuthCode });
     Client.retryTransferWithDifferentAuthCode(Mapper.Map <Remote.Domain>(domain), newAuthCode);
 }
Esempio n. 5
0
 /// <summary>
 /// Registers a domain name, will automatically create and sign a proposition for it.
 /// </summary>
 /// <param name="domain">The domain object holding information about the domain that needs to be registered.</param>
 /// <remarks>Requires "readwrite" mode.</remarks>
 public void Register(Domain domain)
 {
     SetSignatureCookies("register", new object[] { domain });
     Client.register(Mapper.Map <Remote.Domain>(domain));
 }
Esempio n. 6
0
 /// <summary>
 /// Transfers a domain without changing the owner.
 /// </summary>
 /// <param name="domain">The Domain object holding information about the domain that needs to be transfered.</param>
 /// <param name="authCode">The authorization code for domains needing this for transfers (e.g. .com or .org transfers). Leave empty when n/a.</param>
 public void TransferWithoutOwnerChange(Domain domain, string authCode)
 {
     SetSignatureCookies("transferWithoutOwnerChange", new object[] { domain, authCode });
     Client.transferWithoutOwnerChange(Mapper.Map <Remote.Domain>(domain), authCode);
 }
Esempio n. 7
0
 /// <summary>
 /// Cancels a failed domain action.
 /// </summary>
 /// <param name="domain">The domain to cancel the action for.</param>
 public async Task CancelDomainActionAsync(Domain domain)
 {
     SetSignatureCookies("cancelDomainAction", new object[] { domain });
     await Client.cancelDomainActionAsync(Mapper.Map <Remote.Domain>(domain));
 }
Esempio n. 8
0
 /// <summary>
 /// Retry a transfer action with a new authcode.
 /// </summary>
 /// <param name="domain">The domain to try the transfer with a different authcode for.</param>
 /// <param name="newAuthCode">New authorization code to try.</param>
 public async Task RetryTransferWithDifferentAuthCodeAsync(Domain domain, string newAuthCode)
 {
     SetSignatureCookies("retryTransferWithDifferentAuthCode", new object[] { domain, newAuthCode });
     await Client.retryTransferWithDifferentAuthCodeAsync(Mapper.Map <Remote.Domain>(domain), newAuthCode);
 }
Esempio n. 9
0
 /// <summary>
 /// Retries a failed domain action with new domain data. The Domain#name field must contain
 /// the name of the Domain, the nameserver, contacts, dnsEntries fields contain the new data for this domain.
 /// Set a field to null to not change the data.
 /// </summary>
 /// <param name="domain">The domain with data to retry.</param>
 public async Task RetryCurrentDomainActionWithNewDataAsync(Domain domain)
 {
     SetSignatureCookies("retryCurrentDomainActionWithNewData", new object[] { domain });
     await Client.retryCurrentDomainActionWithNewDataAsync(Mapper.Map <Remote.Domain>(domain));
 }
Esempio n. 10
0
 /// <summary>
 /// Transfers a domain without changing the owner.
 /// </summary>
 /// <param name="domain">The Domain object holding information about the domain that needs to be transfered.</param>
 /// <param name="authCode">The authorization code for domains needing this for transfers (e.g. .com or .org transfers). Leave empty when n/a.</param>
 public async Task TransferWithoutOwnerChangeAsync(Domain domain, string authCode)
 {
     SetSignatureCookies("transferWithoutOwnerChange", new object[] { domain, authCode });
     await Client.transferWithoutOwnerChangeAsync(Mapper.Map <Remote.Domain>(domain), authCode);
 }
Esempio n. 11
0
 /// <summary>
 /// Registers a domain name, will automatically create and sign a proposition for it.
 /// </summary>
 /// <param name="domain">The domain object holding information about the domain that needs to be registered.</param>
 /// <remarks>Requires "readwrite" mode.</remarks>
 public async Task RegisterAsync(Domain domain)
 {
     SetSignatureCookies("register", new object[] { domain });
     await Client.registerAsync(Mapper.Map <Remote.Domain>(domain));
 }