public ServerAlias CreateAlias()
        {
            ServerAlias result;

            if (_inProcessRadioButton.Checked)
            {
                InProcessAlias inProcess = new InProcessAlias();
                inProcess.InstanceName = _inProcessInstanceNameTextBox.Text;
                result = inProcess;
            }
            else
            {
                ConnectionAlias connection = new ConnectionAlias();
                connection.HostName           = _hostNameTextBox.Text;
                connection.InstanceName       = _instanceNameTextBox.Text;
                connection.OverridePortNumber = Int32.Parse(_portNumberConnectionTextBox.Text);
                result = connection;
            }

            result.SessionInfo.Password = _password.Text;
            result.SessionInfo.UserID   = _userID.Text;

            result.Name = _aliasNameTextBox.Text;

            return(result);
        }
Exemple #2
0
        public ServerAlias CreateAlias()
        {
            ServerAlias result;

            if (tcAliasType.SelectedTab == tpInProcessAlias)
            {
                InProcessAlias inProcess = new InProcessAlias();
                inProcess.InstanceName = _cbInProcessInstanceName.Text;
                inProcess.IsEmbedded   = cbEmbedded.Checked;
                result = inProcess;
            }
            else
            {
                ConnectionAlias connection = new ConnectionAlias();
                connection.HostName                   = tbHost.Text;
                connection.InstanceName               = cbInstanceName.Text;
                connection.OverridePortNumber         = OverridePortNumber;
                connection.SecurityMode               = SecurityMode;
                connection.OverrideListenerPortNumber = OverrideListenerPortNumber;
                connection.ListenerSecurityMode       = ListenerSecurityMode;
                connection.ClientConfigurationName    = tbEndpointConfigurationName.Text;
                connection.ClientSideLoggingEnabled   = cbClientSideLogging.Checked;
                result = connection;
            }

            result.Name        = tbAliasName.Text;
            result.IsUserAlias = cbIsUserAlias.Checked;
            CopyInstance(_sessionInfo, result.SessionInfo);

            return(result);
        }
Exemple #3
0
        public void SetFromAlias(ServerAlias alias)
        {
            tbAliasName.Text = alias.Name;
            CopyInstance(alias.SessionInfo, _sessionInfo);
            SessionInfoPropertyGrid.Refresh();
            cbIsUserAlias.Checked = alias.IsUserAlias;

            InProcessAlias  inProcess  = alias as InProcessAlias;
            ConnectionAlias connection = alias as ConnectionAlias;

            if (inProcess != null)
            {
                tcAliasType.SelectedTab       = tpInProcessAlias;
                _cbInProcessInstanceName.Text = inProcess.InstanceName;
                cbEmbedded.Checked            = inProcess.IsEmbedded;
            }
            else
            {
                tcAliasType.SelectedTab          = tpConnectionAlias;
                tbHost.Text                      = connection.HostName;
                cbInstanceName.Text              = connection.InstanceName;
                OverridePortNumber               = connection.OverridePortNumber;
                SecurityMode                     = connection.SecurityMode;
                OverrideListenerPortNumber       = connection.OverrideListenerPortNumber;
                ListenerSecurityMode             = connection.ListenerSecurityMode;
                tbEndpointConfigurationName.Text = connection.ClientConfigurationName;
                cbClientSideLogging.Checked      = connection.ClientSideLoggingEnabled;
            }
        }
Exemple #4
0
        private ServerAlias GetServerAlias(string instanceName, int portNumber)
        {
            var alias = new ConnectionAlias();

            alias.HostName           = "localhost";
            alias.InstanceName       = instanceName;
            alias.OverridePortNumber = portNumber;
            // TODO: User credentials for instances...
            alias.SessionInfo.UserID = "Admin";

            return(alias);
        }
        public void FixtureSetup()
        {
            InstanceManager.Load();

            FConfigurationManager = new SQLCEServerConfigurationManager();
            FConfiguration        = FConfigurationManager.GetTestConfiguration("TestOOPInstance");

            if (InstanceManager.Instances.HasInstance("TestOOPInstance"))
            {
                InstanceManager.Instances.Remove("TestOOPInstance");
            }

            InstanceManager.Instances.Add("TestOOPInstance", FConfiguration);
            InstanceManager.Save();

            ProcessStartInfo LProcessStartInfo = new ProcessStartInfo();

            LProcessStartInfo.FileName              = Path.Combine(ServerConfigurationManager.GetInstallationDirectory(), "Dataphor\\bin\\DAEServer.exe");
            LProcessStartInfo.WorkingDirectory      = Path.GetDirectoryName(LProcessStartInfo.FileName);
            LProcessStartInfo.Arguments             = "-n \"TestOOPInstance\"";
            LProcessStartInfo.UseShellExecute       = false;
            LProcessStartInfo.RedirectStandardInput = true;
            FProcess = Process.Start(LProcessStartInfo);

            // TODO: This should be a wait for the process, but WaitForInputIdle only works on GUI apps
            //Thread.Sleep(10000);

            ConnectionAlias LAlias = new ConnectionAlias();

            LAlias.Name         = "TestOOPInstanceConnection";
            LAlias.InstanceName = "TestOOPInstance";

            int LRetryCount = 0;

            while ((FDataSession == null) && (LRetryCount++ < 3))
            {
                Thread.Sleep(500);
                try
                {
                    FDataSession       = new DataSession();
                    FDataSession.Alias = LAlias;
                    FDataSession.Open();
                }
                catch
                {
                    FDataSession = null;
                }
            }
        }
        public void SetFromAlias(ServerAlias alias)
        {
            _aliasNameTextBox.Text = alias.Name;

            InProcessAlias  inProcess  = alias as InProcessAlias;
            ConnectionAlias connection = alias as ConnectionAlias;

            if (inProcess != null)
            {
                _inProcessRadioButton.Checked      = true;
                _inProcessInstanceNameTextBox.Text = inProcess.InstanceName;
            }
            else
            {
                _connectionRadioButton.Checked    = true;
                _hostNameTextBox.Text             = connection.HostName;
                _instanceNameTextBox.Text         = connection.InstanceName;
                _portNumberConnectionTextBox.Text = connection.OverridePortNumber.ToString();
            }

            _password.Text = alias.SessionInfo.Password;
            _userID.Text   = alias.SessionInfo.UserID;
        }
 /// <summary>Initializes a new instance of the <see cref="ConnectionAlias"/> class.</summary>
 /// <param name="copy">The copy.</param>
 public ConnectionAlias(ConnectionAlias copy)
 {
     Name     = copy.Name;
     ImageUrl = copy.ImageUrl;
 }
Exemple #8
0
        public int Run()
        {
            bool hasErrors = true;

            try
            {
                using (DataSession dataphorConnection = new DataSession())
                {
                    if (File != null)
                    {
                        using (StreamReader file = new StreamReader(File))
                        {
                            Script = file.ReadToEnd();
                        }
                    }
                    if (Script == null)                      // Script was not in the commandline or specified in a file
                    {
                        Console.WriteLine("\r\nMissing D4 script; include on command line or use /File: switch.\r\n");
                        Console.WriteLine(CommandLine.Parser.ArgumentsUsage(this.GetType()));
                        return(1);
                    }
                    if (AliasName == String.Empty)
                    {
                        ConnectionAlias alias = new ConnectionAlias();
                        alias.HostName     = Host;
                        alias.InstanceName = Instance;
                        if (Port > 0)
                        {
                            alias.OverridePortNumber = Port;
                        }
                        dataphorConnection.Alias = alias;
                    }
                    else
                    {
                        dataphorConnection.AliasName = AliasName;
                    }

                    if (User != null)
                    {
                        dataphorConnection.SessionInfo.UserID = User;
                    }

                    if (Password != null)
                    {
                        if (PasswordEncrypted == true)
                        {
                            dataphorConnection.SessionInfo.UnstructuredData = Password;
                        }
                        else
                        {
                            dataphorConnection.SessionInfo.Password = Password;
                        }
                    }

                    dataphorConnection.Open();

                    if (!Quiet)
                    {
                        Console.WriteLine("Executing D4 Script:\r\n{0}\r\n", Script);
                    }

                    ErrorList errors;
                    TimeSpan  timeSpan;
                    ScriptExecutionUtility.ExecuteScript
                    (
                        dataphorConnection.ServerSession,
                        Script,
                        Options,
                        out errors,
                        out timeSpan,
                        delegate(PlanStatistics AStatistics, string AResults)
                    {
                        Console.WriteLine(AResults);
                    },
                        File == null ? null : new DebugLocator("file:" + Path.GetFullPath(File), 1, 1)
                    );
                    foreach (Exception exception in errors)
                    {
                        Console.WriteLine(exception.Message);
                    }

                    hasErrors = ScriptExecutionUtility.ContainsError(errors);
                    if (!Quiet)
                    {
                        Console.WriteLine("Status: {0}  Total Time: {1}", (hasErrors ? "Failed" : "Succeeded"), timeSpan);
                    }
                }
                if (Prompt)
                {
                    if (!Quiet)
                    {
                        Console.Write("Press any key to continue.");
                    }
                    Console.Read();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
            if (hasErrors)
            {
                return(1);
            }
            return(0);
        }
        /// <inheritdoc/>
        public async Task <ConnectionRecord> ProcessRequestAsync(IAgentContext agentContext, DidExchangeRequestMessage requestMessage)
        {
            var myDid = await Did.CreateAndStoreMyDidAsync(agentContext.Wallet, "{}");

            DidDoc didDoc = null;

            if (requestMessage.DidDoc.Data.Base64 is { } data)
            {
                var isValidSignature = await requestMessage.DidDoc.Data.VerifyJsonWebSignature();

                if (isValidSignature == false)
                {
                    throw new AriesFrameworkException(ErrorCode.InvalidSignatureEncoding,
                                                      "The given JSON web signature is invalid");
                }

                var json = data.FromBase64Url();
                didDoc = json.ToObject <DidDoc>();
            }

            // Todo: Handle resolvable Dids
            if (didDoc == null)
            {
                throw new NotImplementedException("Request message must provide an attached did document");
            }

            if (didDoc.Keys.All(key => key.Type == DidDocExtensions.DefaultKeyType) == false)
            {
                throw new NotImplementedException($"Only {DidDocExtensions.DefaultKeyType} is supported");
            }

            var indyService = (IndyAgentDidDocService)didDoc.Services.First(service => service is IndyAgentDidDocService);

            var agentEndpoint = new AgentEndpoint(indyService.ServiceEndpoint, null, indyService.RoutingKeys.ToArray());

            var connectionRecord = new ConnectionRecord
            {
                Id    = Guid.NewGuid().ToString(),
                Alias = new ConnectionAlias {
                    Name = requestMessage.Label
                },
                MyDid    = DidUtils.ConvertVerkeyToDidKey(myDid.VerKey),
                MyVk     = myDid.VerKey,
                TheirDid = requestMessage.Did,
                TheirVk  = didDoc.Keys.FirstOrDefault(key => key.Controller == requestMessage.Did)?.PublicKeyBase58
                           ?? throw new NullReferenceException("Missing public for controller"),
                                 Endpoint = agentEndpoint,
                                 State    = ConnectionState.Negotiating
            };
            await _recordService.AddAsync(agentContext.Wallet, connectionRecord);

            _eventAggregator.Publish(
                new ServiceMessageProcessingEvent
            {
                MessageType = requestMessage.Type,
                RecordId    = connectionRecord.Id,
                ThreadId    = requestMessage.GetThreadId()
            });

            return(connectionRecord);
        }