internal static OwaClientSecurityContextIdentity CreateFromsidBasedIdentity(SidBasedIdentity sidBasedIdentity)
 {
     if (sidBasedIdentity == null)
     {
         throw new ArgumentNullException("sidBasedIdentity");
     }
     return(OwaClientSecurityContextIdentity.InternalCreateFromClientSecurityContextIdentity(sidBasedIdentity, sidBasedIdentity.MemberName, sidBasedIdentity.UserOrganizationId));
 }
 internal static OwaClientSecurityContextIdentity CreateFromAdfsIdentity(AdfsIdentity adfsIdentity)
 {
     if (adfsIdentity == null)
     {
         throw new ArgumentNullException("adfsIdentity");
     }
     return(OwaClientSecurityContextIdentity.InternalCreateFromClientSecurityContextIdentity(adfsIdentity, adfsIdentity.MemberName, adfsIdentity.UserOrganizationId));
 }
 internal static OwaClientSecurityContextIdentity CreateFromLiveIDIdentity(LiveIDIdentity liveIDIdentity)
 {
     if (liveIDIdentity == null)
     {
         throw new ArgumentNullException("liveIDIdentity");
     }
     return(OwaClientSecurityContextIdentity.InternalCreateFromClientSecurityContextIdentity(liveIDIdentity, liveIDIdentity.MemberName, liveIDIdentity.UserOrganizationId));
 }
 internal static OwaClientSecurityContextIdentity CreateFromClientSecurityContextIdentity(ClientSecurityContextIdentity cscIdentity)
 {
     if (cscIdentity == null)
     {
         throw new ArgumentNullException("cscIdentity");
     }
     return(OwaClientSecurityContextIdentity.InternalCreateFromClientSecurityContextIdentity(cscIdentity, cscIdentity.Name, null));
 }
        internal static OwaClientSecurityContextIdentity CreateFromOAuthIdentity(OAuthIdentity oauthIdentity)
        {
            if (oauthIdentity == null)
            {
                throw new ArgumentNullException("oauthIdentity");
            }
            ExAssert.RetailAssert(!oauthIdentity.IsAppOnly, "IsApplyOnly cannot be null in OAuthIdentity.");
            ExAssert.RetailAssert(oauthIdentity.ActAsUser != null, "ActAsUser cannot be null in OAuthIdentity.");
            string partitionId = string.Empty;

            if (!(oauthIdentity.OrganizationId == null) && !(oauthIdentity.OrganizationId.PartitionId == null))
            {
                partitionId = oauthIdentity.OrganizationId.PartitionId.ToString();
            }
            SidBasedIdentity cscIdentity = new SidBasedIdentity(oauthIdentity.ActAsUser.UserPrincipalName, oauthIdentity.ActAsUser.Sid.Value, oauthIdentity.ActAsUser.UserPrincipalName, oauthIdentity.AuthenticationType, partitionId)
            {
                UserOrganizationId = oauthIdentity.OrganizationId
            };

            return(OwaClientSecurityContextIdentity.InternalCreateFromClientSecurityContextIdentity(cscIdentity, oauthIdentity.ActAsUser.UserPrincipalName, null));
        }