Exemplo n.º 1
0
 /// <summary>
 /// Creates authenticated client backed by the specified channel. The supplied
 /// signer is used to authenticate the caller for every call.
 /// </summary>
 /// <param name = "channel">RPC channel to use</param>
 /// <param name = "memberId">member id</param>
 /// <param name = "crypto">engine to use for signing requests, tokens, etc</param>
 /// <returns>newly created client</returns>
 public static Client Authenticated(
     ManagedChannel channel,
     string memberId,
     ICryptoEngine crypto)
 {
     return(new Client(memberId, crypto, channel));
 }
Exemplo n.º 2
0
            /// <summary>
            /// Builds and returns a new <see cref="TokenClient"/> instance.
            /// </summary>
            /// <returns>the <see cref="TokenClient"/> instance</returns>
            public TokenClient Build()
            {
                var channelOptions = new List <ChannelOption>();

                channelOptions.Add(new ChannelOption("grpc.keepalive_permit_without_calls", keepAlive ? 1 : 0));
                channelOptions.Add(new ChannelOption("grpc.keepalive_time_ms", keepAliveTimeMs));
                var channel = new Channel(
                    hostName,
                    port,
                    useSsl ? new SslCredentials() : ChannelCredentials.Insecure,
                    channelOptions);

                Interceptor[] interceptors =
                {
                    new AsyncTimeoutInterceptor(timeoutMs),
                    new AsyncMetadataInterceptor(metadata =>
                    {
                        metadata.Add("token-sdk", "csharp");
                        metadata.Add(
                            "token-sdk-version",
                            Assembly.GetExecutingAssembly().GetName().Version.ToString(3));
                        metadata.Add("token-dev-key", devKey);
                        return(metadata);
                    })
                };
                var newChannel = new ManagedChannel(channel, interceptors);

                return(new TokenClient(
                           newChannel,
                           cryptoEngine ?? new TokenCryptoEngineFactory(new InMemoryKeyStore()),
                           tokenCluster ?? TokenCluster.SANDBOX));
            }
Exemplo n.º 3
0
 /// <summary>
 /// Creates an instance of a Token SDK.
 /// </summary>
 /// <param name="channel">the gRPC channel</param>
 /// <param name="cryptoEngineFactory">the crypto factory to create crypto engine</param>
 /// <param name="tokenCluster">the token cluster to connect to</param>
 public TokenClient(
     ManagedChannel channel,
     ICryptoEngineFactory cryptoEngineFactory,
     TokenCluster tokenCluster)
 {
     this.channel             = channel;
     this.cryptoEngineFactory = cryptoEngineFactory;
     this.tokenCluster        = tokenCluster;
 }
Exemplo n.º 4
0
        protected void AddRemoveChannel(ManagedChannel channel, ChangeEventArgs e)
        {
            if ((bool)e.Value)
            {
                ScanProfile.Channels.Add(channel);
            }
            else
            {
                ScanProfile.Channels.Remove(channel);
            }

            IsChanged = true;
        }
Exemplo n.º 5
0
            /// <summary>
            /// Builds and returns a new <see cref="TokenClient"/> instance.
            /// </summary>
            /// <returns>the <see cref="TokenClient"/> instance</returns>
            public virtual TokenClient Build()
            {
                var metadata   = GetHeaders();
                var newChannel = ManagedChannel.NewBuilder(hostName, port, useSsl)
                                 .WithTimeout(timeoutMs)
                                 .WithMetadata(metadata)
                                 .UseKeepAlive(keepAlive)
                                 .WithKeepAliveTime(keepAliveTimeMs)
                                 .Build();

                return(new TokenClient(
                           newChannel,
                           cryptoEngine ?? new TokenCryptoEngineFactory(new InMemoryKeyStore()),
                           tokenCluster ?? TokenCluster.SANDBOX));
            }
Exemplo n.º 6
0
            /// <summary>
            /// Builds and returns a new <see cref="TokenClient"/> instance.
            /// </summary>
            /// <returns>the <see cref="TokenClient"/> instance</returns>
            public TokenClient Build()
            {
                var channel = new Channel(hostName, port, useSsl ? new SslCredentials() : ChannelCredentials.Insecure);

                Interceptor[] interceptors =
                {
                    new AsyncTimeoutInterceptor(timeoutMs),
                    new AsyncMetadataInterceptor(metadata =>
                    {
                        metadata.Add("token-sdk", "csharp");
                        metadata.Add(
                            "token-sdk-version",
                            Assembly.GetExecutingAssembly().GetName().Version.ToString(3));
                        metadata.Add("token-dev-key", devKey);
                        return(metadata);
                    })
                };
                var newChannel = new ManagedChannel(channel, interceptors);

                return(new TokenClient(
                           newChannel,
                           cryptoEngine ?? new TokenCryptoEngineFactory(new InMemoryKeyStore()),
                           tokenCluster ?? TokenCluster.SANDBOX));
            }
Exemplo n.º 7
0
 /// <summary>
 /// Instantiates a client.
 /// </summary>
 /// <param name="memberId">the member id</param>
 /// <param name="cryptoEngine">the crypto engine used to sign for authentication, request
 /// payloads, etc</param>
 /// <param name="channel">managed channel</param>
 public Client(string memberId, ICryptoEngine cryptoEngine, ManagedChannel channel)
     : base(memberId, cryptoEngine, channel)
 {
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates new unauthenticated client backed by the specified channel.
 /// </summary>
 /// <param name = "channel">RPC channel to use</param>
 /// <returns>newly created client</returns>
 public static UnauthenticatedClient Unauthenticated(ManagedChannel channel)
 {
     return(new UnauthenticatedClient(new GatewayService.GatewayServiceClient(channel.BuildInvoker())));
 }
Exemplo n.º 9
0
 protected override void ReplaceSoundFile(ManagedChannel channel = null)
 {
 }
Exemplo n.º 10
0
 protected bool IsChecked(ManagedChannel channel) => ScanProfile.Channels.Contains(channel);