internal static OwaClientSecurityContextIdentity CreateFromAdfsIdentity(AdfsIdentity adfsIdentity)
 {
     if (adfsIdentity == null)
     {
         throw new ArgumentNullException("adfsIdentity");
     }
     return(OwaClientSecurityContextIdentity.InternalCreateFromClientSecurityContextIdentity(adfsIdentity, adfsIdentity.MemberName, adfsIdentity.UserOrganizationId));
 }
Пример #2
0
        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()));
            }
        }
Пример #3
0
        // Token: 0x060007D3 RID: 2003 RVA: 0x00019C68 File Offset: 0x00017E68
        public static bool IsPublicComputerSession(HttpContext httpContext)
        {
            LiveIDIdentity liveIDIdentity = httpContext.User.Identity as LiveIDIdentity;
            AdfsIdentity   adfsIdentity   = httpContext.User.Identity as AdfsIdentity;
            bool           result;

            if (liveIDIdentity != null)
            {
                string text = httpContext.Request.Headers["X-LoginAttributes"];
                if (string.IsNullOrWhiteSpace(text))
                {
                    if (liveIDIdentity.LoginAttributes != null)
                    {
                        result = !liveIDIdentity.LoginAttributes.IsInsideCorpnetSession;
                        ExTraceGlobals.CoreTracer.TraceError <uint, bool>(0L, "[UserContextUtilities::IsPublicComputerSession] session is a live identity session. LoginAttributes header is NULL. LoginAttributes in the identity is {0}, IsInsideCorpnetSession = {1}.", liveIDIdentity.LoginAttributes.Value, liveIDIdentity.LoginAttributes.IsInsideCorpnetSession);
                    }
                    else
                    {
                        result = true;
                        ExTraceGlobals.CoreTracer.TraceError(0L, "[UserContextUtilities::IsPublicComputerSession] session is a live identity session. LoginAttributes header is NULL and identity.LoginAttributes is also NULL. Defaulting to public.");
                    }
                }
                else
                {
                    LiveIdLoginAttributes liveIdLoginAttributes = new LiveIdLoginAttributes(Convert.ToUInt32(text));
                    result = !liveIdLoginAttributes.IsInsideCorpnetSession;
                    ExTraceGlobals.CoreTracer.TraceDebug(0L, "[UserContextUtilities::IsPublicComputerSession] session is a live identity session. LoginAttributes header value is {0}, LoginAttributes = {1}, IsInsideCorpnetSession = {2}, LoginAttributes in the identity is {3}, IsInsideCorpnetSession = {4}", new object[]
                    {
                        text,
                        liveIdLoginAttributes.Value,
                        liveIdLoginAttributes.IsInsideCorpnetSession,
                        (liveIDIdentity.LoginAttributes != null) ? liveIDIdentity.LoginAttributes.Value.ToString() : string.Empty,
                        (liveIDIdentity.LoginAttributes != null) ? liveIDIdentity.LoginAttributes.IsInsideCorpnetSession.ToString() : string.Empty
                    });
                    httpContext.Response.AppendToLog("&loginAttributesBE=" + text);
                }
            }
            else if (adfsIdentity != null)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <bool>(0L, "[UserContextUtilities::IsPublicComputerSession] session is a ADFS identity session is public computer: {0}.", adfsIdentity.IsPublicSession);
                result = adfsIdentity.IsPublicSession;
            }
            else
            {
                result = true;
                ExTraceGlobals.CoreTracer.TraceDebug(0L, "[SessionSettingsType::SetPublicComputerSession] session is NOT a live identity nor an ADFS identity session. Hence, defaulting to public computer session.");
            }
            return(result);
        }