예제 #1
0
                public override void ProcessTextCode(eResponseTextContext pTextContext, cByteList pCode, cByteList pArguments, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cCommandHookInitial), nameof(ProcessTextCode), pTextContext, pCode, pArguments);

                    if (pTextContext == eResponseTextContext.greetingok || pTextContext == eResponseTextContext.greetingpreauth || pTextContext == eResponseTextContext.success)
                    {
                        if (pCode.Equals(kCapability))
                        {
                            if (pArguments != null)
                            {
                                cBytesCursor lCursor = new cBytesCursor(pArguments);

                                if (lCursor.ProcessCapability(out var lCapabilities, out var lAuthenticationMechanisms, lContext) && lCursor.Position.AtEnd)
                                {
                                    lContext.TraceVerbose("received capabilities: {0} {1}", lCapabilities, lAuthenticationMechanisms);
                                    Capabilities             = lCapabilities;
                                    AuthenticationMechanisms = lAuthenticationMechanisms;
                                    return;
                                }
                            }

                            lContext.TraceWarning("likely malformed capability response");
                        }
                    }
                }
예제 #2
0
 internal cBodyPartExtensionData(cBodyPartDisposition pDisposition, cStrings pLanguages, string pLocation, cBodyPartExtensionValues pExtensionValues)
 {
     Disposition     = pDisposition;
     Languages       = pLanguages;
     Location        = pLocation;
     ExtensionValues = pExtensionValues;
 }
예제 #3
0
 internal cResponseText(IList <byte> pCodeText, IList <byte> pArgumentsText, eResponseTextCode pCode, cStrings pArguments, string pText)
 {
     CodeText      = cTools.ASCIIBytesToString(pCodeText);
     ArgumentsText = cTools.UTF8BytesToString(pArgumentsText);
     Code          = pCode;
     Arguments     = pArguments;
     Text          = pText;
 }
예제 #4
0
 internal cResponseText(IList <byte> pCodeText, eResponseTextCode pCode, string pText)
 {
     CodeText      = cTools.ASCIIBytesToString(pCodeText);
     ArgumentsText = null;
     Code          = pCode;
     Arguments     = null;
     Text          = pText;
 }
예제 #5
0
 internal cResponseText(string pText)
 {
     CodeText      = null;
     ArgumentsText = null;
     Code          = eResponseTextCode.none;
     Arguments     = null;
     Text          = pText;
 }
예제 #6
0
파일: base.cs 프로젝트: bacome/imapclient
            private void ZSetCapabilities(cStrings pCapabilities, cStrings pAuthenticationMechanisms, cTrace.cContext pParentContext)
            {
                var lContext = pParentContext.NewMethod(nameof(cSession), nameof(ZSetCapabilities), pCapabilities, pAuthenticationMechanisms);

                _Capabilities = new cCapabilities(pCapabilities, pAuthenticationMechanisms, mIgnoreCapabilities);
                mPipeline.SetCapabilities(_Capabilities, lContext);
                mSynchroniser.InvokePropertyChanged(nameof(cIMAPClient.Capabilities), lContext);
            }
예제 #7
0
        public bool ProcessCapability(out cStrings rCapabilities, out cStrings rAuthenticationMechanisms, cTrace.cContext pParentContext)
        {
            // NOTE: this routine does not return the cursor to its original position if it fails
            //  (that is why it is called PROCESScapablity not GETcapability)

            var lContext = pParentContext.NewMethod(nameof(cBytesCursor), nameof(ProcessCapability));

            var lCapabilities             = new List <string>();
            var lAuthenticationMechanisms = new List <string>();

            while (true)
            {
                if (SkipBytes(kCapabilityAuthEquals))
                {
                    if (!GetToken(cCharset.Atom, null, null, out string lAtom))
                    {
                        lContext.TraceWarning("likely malformed capability: auth=<not atom>?");
                        rCapabilities             = null;
                        rAuthenticationMechanisms = null;
                        return(false);
                    }

                    lAuthenticationMechanisms.Add(lAtom);
                }
                else
                {
                    if (!GetToken(cCharset.Atom, null, null, out string lAtom))
                    {
                        lContext.TraceWarning("likely malformed capability: not atom?");
                        rCapabilities             = null;
                        rAuthenticationMechanisms = null;
                        return(false);
                    }

                    lCapabilities.Add(lAtom);
                }

                if (!SkipByte(cASCII.SPACE))
                {
                    break;
                }
            }

            if (!lCapabilities.Contains("IMAP4rev1", StringComparer.InvariantCultureIgnoreCase))
            {
                lContext.TraceWarning("likely malformed capability: not imap4rev1?");
                rCapabilities             = null;
                rAuthenticationMechanisms = null;
                return(false);
            }

            rCapabilities             = new cStrings(lCapabilities);
            rAuthenticationMechanisms = new cStrings(lAuthenticationMechanisms);
            return(true);
        }
예제 #8
0
            private void ZAuthenticated(cStrings pOldPipelineCapabilities, cCommandHookInitial pHook, cResponseText pResponseText, cAccountId pAccountId, cTrace.cContext pParentContext)
            {
                var lContext = pParentContext.NewMethod(nameof(cSession), nameof(ZAuthenticated));

                if (pHook.Capabilities != null)
                {
                    ZSetCapabilities(pHook.Capabilities, pHook.AuthenticationMechanisms, lContext);
                }
                else if (!ReferenceEquals(pOldPipelineCapabilities, mPipeline.Capabilities))
                {
                    ZSetCapabilities(mPipeline.Capabilities, mPipeline.AuthenticationMechanisms, lContext);
                }

                ZSetHomeServerReferral(pResponseText, lContext);
                ZSetConnectedAccountId(pAccountId, lContext);
            }
예제 #9
0
        internal cCapabilities(cStrings pCapabilities, cStrings pAuthenticationMechanisms, fCapabilities pIgnoreCapabilities)
        {
            Capabilities             = pCapabilities ?? throw new ArgumentNullException(nameof(pCapabilities));
            AuthenticationMechanisms = pAuthenticationMechanisms ?? throw new ArgumentNullException(nameof(pAuthenticationMechanisms));

            fCapabilities lCapabilities = 0;

            if (pCapabilities.Contains("LoginDisabled", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.logindisabled;
            }
            if (pCapabilities.Contains("StartTLS", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.starttls;
            }
            if (pCapabilities.Contains("Idle", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.idle;
            }
            if (pCapabilities.Contains("Literal+", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.literalplus;
            }
            if (pCapabilities.Contains("Literal-", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.literalminus;
            }
            if (pCapabilities.Contains("Enable", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.enable;
            }
            if (pCapabilities.Contains("UTF8=Accept", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.utf8accept;
            }
            if (pCapabilities.Contains("UTF8=Only", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.utf8only;
            }
            if (pCapabilities.Contains("List-Extended", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.listextended;
            }
            if (pCapabilities.Contains("Children", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.children;
            }
            if (pCapabilities.Contains("SASL-IR", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.sasl_ir;
            }
            if (pCapabilities.Contains("Login-Referrals", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.loginreferrals;
            }
            if (pCapabilities.Contains("Mailbox-Referrals", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.mailboxreferrals;
            }
            if (pCapabilities.Contains("Id", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.id;
            }
            if (pCapabilities.Contains("Binary", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.binary;
            }
            if (pCapabilities.Contains("Namespace", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.namespaces;
            }
            if (pCapabilities.Contains("List-Status", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.liststatus;
            }
            if (pCapabilities.Contains("Special-Use", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.specialuse;
            }
            if (pCapabilities.Contains("ESearch", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.esearch;
            }
            if (pCapabilities.Contains("Sort", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.sort;
            }
            if (pCapabilities.Contains("Sort=Display", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.sortdisplay;
            }
            if (pCapabilities.Contains("ESort", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.esort;
            }
            //if (pCapabilities.Contains("Thread=OrderedSubject", StringComparer.InvariantCultureIgnoreCase)) lCapabilities |= fCapabilities.threadorderedsubject;
            //if (pCapabilities.Contains("Thread=References", StringComparer.InvariantCultureIgnoreCase)) lCapabilities |= fCapabilities.threadreferences;
            if (pCapabilities.Contains("CondStore", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.condstore;
            }
            if (pCapabilities.Contains("QResync", StringComparer.InvariantCultureIgnoreCase))
            {
                lCapabilities |= fCapabilities.qresync | fCapabilities.condstore;
            }

            EffectiveCapabilities = lCapabilities & ~pIgnoreCapabilities;
        }
예제 #10
0
 internal cSinglePartExtensionData(string pMD5, cBodyPartDisposition pDisposition, cStrings pLanguages, string pLocation, cBodyPartExtensionValues pExtensions) : base(pDisposition, pLanguages, pLocation, pExtensions)
 {
     MD5 = pMD5;
 }
예제 #11
0
 internal cMultiPartExtensionData(cBodyStructureParameters pParameters, cBodyPartDisposition pDisposition, cStrings pLanguages, string pLocation, cBodyPartExtensionValues pExtensionValues) : base(pDisposition, pLanguages, pLocation, pExtensionValues)
 {
     Parameters = pParameters;
 }
예제 #12
0
 private cHeaderFieldMsgIds(string pName, cBytes pValue, cStrings pMsgIds) : base(pName, pValue)
 {
     MsgIds = pMsgIds;
 }