// Token: 0x06000677 RID: 1655 RVA: 0x000137A0 File Offset: 0x000119A0
        internal static OwaIdentity CreateFromAuthZClientInfo(AuthZClientInfo authZClientInfo)
        {
            if (authZClientInfo == null)
            {
                throw new ArgumentNullException("authZClientInfo", "You must specify the source AuthZClientInfo.");
            }
            OwaIdentity owaIdentity = OwaClientSecurityContextIdentity.CreateFromClientSecurityContext(authZClientInfo.ClientSecurityContext, authZClientInfo.PrimarySmtpAddress, "OverrideClientSecurityContext");

            if (owaIdentity == null)
            {
                ExTraceGlobals.CoreCallTracer.TraceError(0L, "[OwaIdentity::CreateFromAuthZClientInfo] - was unable to create the security context for " + authZClientInfo.PrimarySmtpAddress);
                throw new OwaIdentityException("Cannot create security context for the specified identity. Failed to resolve the identity " + authZClientInfo.PrimarySmtpAddress);
            }
            if (authZClientInfo.SecondaryClientInfoItems.Count > 0)
            {
                OwaIdentity[] array = new OwaIdentity[authZClientInfo.SecondaryClientInfoItems.Count];
                int           num   = 0;
                foreach (AuthZClientInfo authZClientInfo2 in authZClientInfo.SecondaryClientInfoItems)
                {
                    array[num] = OwaClientSecurityContextIdentity.CreateFromClientSecurityContext(authZClientInfo2.ClientSecurityContext, authZClientInfo2.PrimarySmtpAddress, "OverrideClientSecurityContext");
                    if (array[num] == null)
                    {
                        ExTraceGlobals.CoreCallTracer.TraceError(0L, "[OwaIdentity::CreateFromAuthZClientInfo] - was unable to create the security context for composite identity. Failed to resolve secondary identity " + authZClientInfo2.PrimarySmtpAddress);
                        throw new OwaIdentityException(string.Format("Cannot create security context for the specified composite identity. Failed to resolve the secondary identity {0}: {1}.", num, authZClientInfo2.PrimarySmtpAddress));
                    }
                    num++;
                }
                owaIdentity = new OwaCompositeIdentity(owaIdentity, array);
            }
            return(owaIdentity);
        }
        // Token: 0x06000685 RID: 1669 RVA: 0x00013980 File Offset: 0x00011B80
        public override bool IsEqualsTo(OwaIdentity otherIdentity)
        {
            OwaCompositeIdentity owaCompositeIdentity = otherIdentity as OwaCompositeIdentity;

            if (owaCompositeIdentity == null)
            {
                return(false);
            }
            bool flag = otherIdentity.UserSid.Equals(this.UserSid);

            if (flag)
            {
                if (this.secondaryIdentities.Count != this.secondaryIdentities.Count)
                {
                    return(false);
                }
                for (int i = 0; i < this.secondaryIdentities.Count; i++)
                {
                    if (!this.secondaryIdentities[i].IsEqualsTo(owaCompositeIdentity.secondaryIdentities[i]))
                    {
                        return(false);
                    }
                }
            }
            return(flag);
        }
        protected static OwaIdentity GetOwaIdentity(IIdentity identity)
        {
            CompositeIdentity compositeIdentity = identity as CompositeIdentity;

            if (compositeIdentity != null)
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaIdentity::ResolveLogonIdentity] - Trying to resolve CompositeIdentity.");
                return(OwaCompositeIdentity.CreateFromCompositeIdentity(compositeIdentity));
            }
            WindowsIdentity windowsIdentity = identity as WindowsIdentity;

            if (windowsIdentity != null)
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaIdentity::ResolveLogonIdentity] - Trying to resolve WindowsIdentity.");
                if (windowsIdentity.IsAnonymous)
                {
                    ExTraceGlobals.CoreCallTracer.TraceError(0L, "[OwaIdentity::ResolveLogonIdentity] - Windows identity cannot be anonymous.");
                    throw new OwaIdentityException("Cannot create security context for anonymous windows identity.");
                }
                return(OwaWindowsIdentity.CreateFromWindowsIdentity(windowsIdentity));
            }
            else
            {
                LiveIDIdentity liveIDIdentity = identity as LiveIDIdentity;
                if (liveIDIdentity != null)
                {
                    ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaIdentity::ResolveLogonIdentity] - Trying to resolve LiveIDIdentity.");
                    return(OwaClientSecurityContextIdentity.CreateFromLiveIDIdentity(liveIDIdentity));
                }
                WindowsTokenIdentity windowsTokenIdentity = identity as WindowsTokenIdentity;
                if (windowsTokenIdentity != null)
                {
                    ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaIdentity::ResolveLogonIdentity] - Trying to resolve WindowsTokenIdentity.");
                    return(OwaClientSecurityContextIdentity.CreateFromClientSecurityContextIdentity(windowsTokenIdentity));
                }
                OAuthIdentity oauthIdentity = identity as OAuthIdentity;
                if (oauthIdentity != null)
                {
                    ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaIdentity::ResolveLogonIdentity] - Trying to resolve OAuthIdentity.");
                    return(OwaClientSecurityContextIdentity.CreateFromOAuthIdentity(oauthIdentity));
                }
                AdfsIdentity adfsIdentity = identity as AdfsIdentity;
                if (adfsIdentity != null)
                {
                    ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaIdentity::ResolveLogonIdentity] - Trying to resolve AdfsIdentity.");
                    return(OwaClientSecurityContextIdentity.CreateFromAdfsIdentity(identity as AdfsIdentity));
                }
                SidBasedIdentity sidBasedIdentity = identity as SidBasedIdentity;
                if (sidBasedIdentity != null)
                {
                    ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaIdentity::ResolveLogonIdentity] - Trying to resolve SidBasedIdentity.");
                    return(OwaClientSecurityContextIdentity.CreateFromsidBasedIdentity(sidBasedIdentity));
                }
                ExTraceGlobals.CoreCallTracer.TraceError <Type>(0L, "[OwaIdentity::ResolveLogonIdentity] - Cannot resolve unsupported identity type: {0}.", identity.GetType());
                throw new NotSupportedException(string.Format("Unexpected identity type. {0}", identity.GetType()));
            }
        }
        internal static OwaIdentity ResolveLogonIdentity(HttpContext httpContext, AuthZClientInfo effectiveCaller)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            OwaIdentity owaIdentity;

            if (effectiveCaller != null && effectiveCaller.ClientSecurityContext != null)
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "[OwaIdentity::ResolveLogonIdentity] - Taking identity from overrideClientSecurityContext. User: {0}.", effectiveCaller.PrimarySmtpAddress);
                owaIdentity = OwaCompositeIdentity.CreateFromAuthZClientInfo(effectiveCaller);
            }
            else
            {
                ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaIdentity::ResolveLogonIdentity] - Looking for identity on httpContext.");
                IIdentity userIdentity = CompositeIdentityBuilder.GetUserIdentity(httpContext);
                if (userIdentity == null)
                {
                    ExTraceGlobals.CoreCallTracer.TraceError(0L, "[OwaIdentity::ResolveLogonIdentity] - httpContext was passed without an identity");
                    throw new OwaIdentityException("The httpContext must have an identity associated with it.");
                }
                owaIdentity = OwaIdentity.GetOwaIdentity(userIdentity);
            }
            if (owaIdentity != null)
            {
                string logonName = owaIdentity.GetLogonName();
                ExTraceGlobals.CoreCallTracer.TraceDebug(0L, "[OwaIdentity::ResolveLogonIdentity] Successfully resolved logon identity. Type={0}, AuthType={1}, Name={2}, IsPartial={3}", new object[]
                {
                    owaIdentity.GetType(),
                    owaIdentity.AuthenticationType ?? string.Empty,
                    logonName ?? string.Empty,
                    owaIdentity.IsPartial
                });
                return(owaIdentity);
            }
            ExTraceGlobals.CoreCallTracer.TraceError(0L, "[OwaIdentity::ResolveLogonIdentity] - was unable to create the security context.");
            throw new OwaIdentityException("Cannot create security context for the specified identity.");
        }