Пример #1
0
        private T_Type GetTypeOfLexeme(string s)
        {
            T_Type type = null;

            type = Keywords.FirstOrDefault(a => Regex.Match(s, a.Pattern).Success);
            if (type != null)
            {
                return(type);
            }
            type = Operators.FirstOrDefault(a => Regex.Match(s, a.Pattern).Success);
            if (type != null)
            {
                return(type);
            }
            type = PunctuationMarks.FirstOrDefault(a => Regex.Match(s, a.Pattern).Success);
            if (type != null)
            {
                return(type);
            }
            type = Constants.FirstOrDefault(a => Regex.Match(s, a.Pattern).Success);
            if (type != null)
            {
                return(type);
            }
            type = Identifiers.FirstOrDefault(a => Regex.Match(s, a.Pattern).Success);
            if (type != null)
            {
                return(type);
            }
            return(null);
        }
Пример #2
0
 private void ReturnIdOrTokenOrLabel(LexerState lexerState, Symbol symbol)
 {
     if (_tokens.Contains(CurrentToken.ToString()))
     {
         CurrentToken.TokenIndex = _tokens.IndexOf(CurrentToken.ToString()) + 1;
         Log(LogEventLevel.Information, "Found token {0}", false, CurrentToken);
         ReturnToken(CurrentToken, symbol);
     }
     else if (symbol.Class?.Class == Class.Colon || Parsed.Last().Substring == "goto")
     {
         //Label
         ReturnLabel(new StateMachine.Transition(lexerState, LexerState.LabelDefinition, symbol));
     }
     else
     {
         Log(LogEventLevel.Information, "Not found token - treat as ID: {0}", false, CurrentToken);
         var identifier =
             Identifiers.FirstOrDefault(x => x.Name == CurrentToken.ToString())?.Clone() as IdentifierToken;
         if (identifier == null)
         {
             identifier = new IdentifierToken(CurrentToken.ToString())
             {
                 TokenIndex = IdIndex
             };
             Identifiers.Add(identifier);
         }
         identifier.Line = Line;
         ReturnToken(identifier, symbol);
     }
 }
Пример #3
0
 public PersonIdentifier GetIdentifier(string systemName)
 {
     return(Identifiers.FirstOrDefault(_ => _.Definition.SystemName == systemName));
 }
Пример #4
0
        public async Task Run()
        {
            // Create client alias core object + specify which environment you want to use
            var acmeClient = new AcmeClient(EnviromentUri);

            // Create new Account
            var account = await acmeClient.CreateNewAccountAsync(ContactEmail);

            // Create new Order
            var order = await acmeClient.NewOrderAsync(account, Identifiers);

            // Create DNS challenge (DNS is required for wildcard certificate)
            var challenges = await acmeClient.GetDnsChallenges(account, order);

            try
            {
                // Creation of all DNS entries
                foreach (var challenge in challenges)
                {
                    var dnsKey  = challenge.VerificationKey;
                    var dnsText = challenge.VerificationValue;


                    await AddTxtEntry(challenge.DnsKey, dnsText);

                    // value can be e.g.: eBAdFvukOz4Qq8nIVFPmNrMKPNlO8D1cr9bl8VFFsJM

                    // Create DNS TXT record e.g.:
                    // key: _acme-challenge.your.domain.com
                    // value: eBAdFvukOz4Qq8nIVFPmNrMKPNlO8D1cr9bl8VFFsJM
                }

                await Task.Delay(60000);

                // Validation of all DNS entries
                foreach (var challenge in challenges)
                {
                    await acmeClient.ValidateChallengeAsync(account, challenge);

                    Challenge freshChallenge;
                    do
                    {
                        // Verify status of challenge
                        freshChallenge = await acmeClient.GetChallengeAsync(account, challenge);

                        if (freshChallenge.Status == ChallengeStatus.Invalid)
                        {
                            throw new Exception("Something is wrong with your DNS TXT record(s)!");
                        }

                        if (freshChallenge.Status != ChallengeStatus.Valid)
                        {
                            await Task.Delay(5000);
                        }
                    } while (freshChallenge.Status == ChallengeStatus.Valid);
                }
            }
            finally
            {
                foreach (var challenge in challenges)
                {
                    await ClearTxtEntries(challenge.DnsKey);
                }
            }

            var commonName = Identifiers.FirstOrDefault(i => !i.StartsWith("*"));

            // Generate certificate
            var certificate = await acmeClient.GenerateCertificateAsync(account, order, commonName);

            // Save files locally
            var password = "******";
            await LocalFileHandler.WriteAsync($"{commonName}.pfx", certificate.GeneratePfx(password));

            await LocalFileHandler.WriteAsync($"{commonName}.crt", certificate.GenerateCrt(password));

            await LocalFileHandler.WriteAsync($"{commonName}.crt.pem", certificate.GenerateCrtPem(password));

            await LocalFileHandler.WriteAsync($"{commonName}.key.pem", certificate.GenerateKeyPem());

            Assert.Pass();
        }