Beispiel #1
0
        public void RetrieveKeyCertificate()
        {
            KeyCertificate certificate =
                _targetAuthority.GetKeyCertificate(RetrievalOptions.UseCache);

            return;
        }
Beispiel #2
0
        internal KeyCertificate Parse(string content)
        {
            bool           exceptionTriggered = false;
            KeyCertificate result             = new KeyCertificate();

            _currentState = ParserState.KeyCertificateVersion;
            base.SetContent(content, _expectedKeywords[ParserState.Certification]);
            try {
                _performStandardChecks = true;
                while ((ParserState.Done != _currentState) && base.AcquireNextLine())
                {
StateSwitched:
                    if (_performStandardChecks)
                    {
                        AssertExpectedKeyword(_currentState, CurrentKeyword);
                    }
                    else
                    {
                        _performStandardChecks = true;
                    }

                    switch (_currentState)
                    {
                    case ParserState.KeyCertificateVersion:
                        if (3 != FetchIntegerItem())
                        {
                            ParsingError("Version '{0}' not supported.", CurrentItemText);
                        }
                        AssertEndOfLine(ParserState.Address, false, true);
                        break;

                    case ParserState.Address:
                        if (_expectedKeywords[ParserState.Address] != CurrentKeyword)
                        {
                            SwitchToState(ParserState.Fingerprint);
                            goto StateSwitched;
                        }
                        result.EndPoint = FetchIPEndPoint();
                        AssertEndOfLine(ParserState.Fingerprint);
                        break;

                    case ParserState.Fingerprint:
                        result.Fingerprint = FetchHexadecimalEncodedString();
                        AssertEndOfLine(ParserState.Published);
                        break;

                    case ParserState.Published:
                        result.Published = FetchTimestampItem();
                        AssertEndOfLine(ParserState.Expires);
                        break;

                    case ParserState.Expires:
                        result.Expires = FetchTimestampItem();
                        AssertEndOfLine(ParserState.IdentityKey);
                        break;

                    case ParserState.IdentityKey:
                        result.IdentityKey = FetchRsaPublicKey();
                        AssertEndOfLine(ParserState.SigningKey);
                        break;

                    case ParserState.SigningKey:
                        result.SigningKey = FetchRsaPublicKey();
                        AssertEndOfLine(ParserState.CrossCertificate);
                        break;

                    case ParserState.CrossCertificate:
                        result.CrossSignature = FetchSignature(true);
                        AssertEndOfLine(ParserState.Certification);
                        break;

                    case ParserState.Certification:
                        // TODO : This must be extracted from this method and performed during
                        // a later step.
                        if (CaptureOptionalItem())
                        {
                            ParsingError("Key certificate signature entry contains extra parameters.");
                        }
                        result.Signature = FetchSignature();
                        AssertEndOfLine(ParserState.Done);
                        result.ToBeHashed = base._toBeHashed;
                        break;

                    default:
                        throw new ParsingException("Internal error : unexpected state {0}",
                                                   _currentState);
                    }
                }
            }
            catch (Exception e) {
                if (!(e is ParsingException))
                {
                    throw new ParsingException(e);
                }
                exceptionTriggered = true;
                throw;
            }
            finally {
                if (!exceptionTriggered)
                {
                    if (ParserState.Done != _currentState)
                    {
                        ParsingError("Ending with unexpected parser state {0}", _currentState);
                    }
                    if (base.AcquireNextLine())
                    {
                        ParsingError("End state reached with remaining lines.");
                    }
                }
            }
            throw new NotImplementedException();
        }