Exemplo n.º 1
0
        public SharePointAcsContext(Uri spHostUrl, Uri spAppWebUrl, string spLanguage, string spClientTag, string spProductNumber, string contextToken, SharePointContextToken contextTokenObj, SharePointConfiguration configuration)
            : base(spHostUrl, spAppWebUrl, spLanguage, spClientTag, spProductNumber)
        {
            if (string.IsNullOrEmpty(contextToken))
            {
                throw new ArgumentNullException(nameof(contextToken));
            }

            if (contextTokenObj == null)
            {
                throw new ArgumentNullException(nameof(contextTokenObj));
            }

            this.contextToken = contextToken;
            this.contextTokenObj = contextTokenObj;
            this.TokenHandler = new TokenHandler(configuration);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves an access token from ACS to call the source of the specified context token at the specified 
        /// targetHost. The targetHost must be registered for the principal that sent the context token.
        /// </summary>
        /// <param name="contextToken">Context token issued by the intended access token audience</param>
        /// <param name="targetHost">Url authority of the target principal</param>
        /// <returns>An access token with an audience matching the context token's source</returns>
        public OAuth2AccessTokenResponse GetAccessToken(SharePointContextToken contextToken, string targetHost)
        {
            string targetPrincipalName = contextToken.TargetPrincipalName;

            // Extract the refreshToken from the context token
            string refreshToken = contextToken.RefreshToken;

            if (String.IsNullOrEmpty(refreshToken))
            {
                return null;
            }

            string targetRealm = _realm ?? contextToken.Realm;

            return GetAccessToken(refreshToken,
                                  targetPrincipalName,
                                  targetHost,
                                  targetRealm);
        }
Exemplo n.º 3
0
        public SharePointAcsContext(Uri spHostUrl, Uri spAppWebUrl, string spLanguage, string spClientTag, string spProductNumber, string contextToken, SharePointContextToken contextTokenObj, SharePointConfiguration configuration)
            : base(spHostUrl, spAppWebUrl, spLanguage, spClientTag, spProductNumber)
        {
            if (string.IsNullOrEmpty(contextToken))
            {
                throw new ArgumentNullException(nameof(contextToken));
            }

            if (contextTokenObj == null)
            {
                throw new ArgumentNullException(nameof(contextTokenObj));
            }

            this.contextToken    = contextToken;
            this.contextTokenObj = contextTokenObj;
            this.TokenHandler    = new TokenHandler(configuration);
        }