CreateAddressBookEntry() public method

Creates a signed address book entry that describes the public information in this endpoint.
public CreateAddressBookEntry ( CryptoSettings cryptoServices ) : AddressBookEntry
cryptoServices CryptoSettings The crypto services to use for signing the address book entry.
return AddressBookEntry
Example #1
0
        /// <summary>
        /// Saves the information required to send this channel messages to the blob store,
        /// and returns the URL to share with senders.
        /// </summary>
        /// <param name="endpoint">The endpoint for which an address book entry should be created and published.</param>
        /// <param name="cancellationToken">A cancellation token to abort the publish.</param>
        /// <returns>A task whose result is the absolute URI to the address book entry.</returns>
        public async Task <Uri> PublishAddressBookEntryAsync(OwnEndpoint endpoint, CancellationToken cancellationToken = default(CancellationToken))
        {
            Requires.NotNull(endpoint, "endpoint");

            var abe       = endpoint.CreateAddressBookEntry(this.CryptoProvider);
            var abeWriter = new StringWriter();
            await Utilities.SerializeDataContractAsBase64Async(abeWriter, abe).ConfigureAwait(false);

            var ms       = new MemoryStream(Encoding.UTF8.GetBytes(abeWriter.ToString()));
            var location = await this.CloudBlobStorage.UploadMessageAsync(ms, DateTime.MaxValue, AddressBookEntry.ContentType, cancellationToken : cancellationToken).ConfigureAwait(false);

            var fullLocationWithFragment = new Uri(
                location,
                "#" + this.CryptoProvider.CreateWebSafeBase64Thumbprint(endpoint.PublicEndpoint.SigningKeyPublicMaterial));

            return(fullLocationWithFragment);
        }
		/// <summary>
		/// Saves the information required to send this channel messages to the blob store,
		/// and returns the URL to share with senders.
		/// </summary>
		/// <param name="endpoint">The endpoint for which an address book entry should be created and published.</param>
		/// <param name="cancellationToken">A cancellation token to abort the publish.</param>
		/// <returns>A task whose result is the absolute URI to the address book entry.</returns>
		public async Task<Uri> PublishAddressBookEntryAsync(OwnEndpoint endpoint, CancellationToken cancellationToken = default(CancellationToken)) {
			Requires.NotNull(endpoint, "endpoint");

			var abe = endpoint.CreateAddressBookEntry(this.CryptoProvider);
			var abeWriter = new StringWriter();
			await Utilities.SerializeDataContractAsBase64Async(abeWriter, abe);
			var ms = new MemoryStream(Encoding.UTF8.GetBytes(abeWriter.ToString()));
			var location = await this.CloudBlobStorage.UploadMessageAsync(ms, DateTime.MaxValue, AddressBookEntry.ContentType, cancellationToken: cancellationToken);
			if (this.UrlShortener != null) {
				location = await this.UrlShortener.ShortenAsync(location);
			}

			var fullLocationWithFragment = new Uri(
				location,
				"#" + this.CryptoProvider.CreateWebSafeBase64Thumbprint(endpoint.PublicEndpoint.SigningKeyPublicMaterial));
			return fullLocationWithFragment;
		}