// Token: 0x06000676 RID: 1654 RVA: 0x000136BC File Offset: 0x000118BC
        public static OwaCompositeIdentity CreateFromCompositeIdentity(CompositeIdentity compositeIdentity)
        {
            if (compositeIdentity == null)
            {
                throw new ArgumentNullException("compositeIdentity", "You must specify the source CompositeIdentity.");
            }
            OwaIdentity owaIdentity = OwaIdentity.GetOwaIdentity(compositeIdentity.PrimaryIdentity);

            if (owaIdentity == null)
            {
                ExTraceGlobals.CoreCallTracer.TraceError(0L, "[OwaIdentity::CreateFromCompositeIdentity] - failed to resolve primary identity.");
                throw new OwaIdentityException("Cannot create security context for the specified composite identity. Failed to resolve the primary identity.");
            }
            OwaIdentity[] array = new OwaIdentity[compositeIdentity.SecondaryIdentitiesCount];
            int           num   = 0;

            foreach (IIdentity identity in compositeIdentity.SecondaryIdentities)
            {
                array[num] = OwaIdentity.GetOwaIdentity(identity);
                if (array[num] == null)
                {
                    ExTraceGlobals.CoreCallTracer.TraceError(0L, string.Format("[OwaIdentity::CreateFromCompositeIdentity] - failed to resolve secondary identity {0}.", num));
                    throw new OwaIdentityException(string.Format("Cannot create security context for the specified composite identity. Failed to resolve a secondary identity {0}.", num));
                }
                num++;
            }
            return(new OwaCompositeIdentity(owaIdentity, array));
        }
Example #2
0
        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.");
        }