Ejemplo n.º 1
0
 /// <summary>
 /// Makes a copy of the ConsentToken object.
 /// </summary>
 /// <param name="consentToken"></param>
 void copy(ConsentToken consentToken)
 {
     this.delegationToken = consentToken.delegationToken;
     this.refreshToken = consentToken.refreshToken;
     this.sessionKey = consentToken.sessionKey;
     this.expiry = consentToken.expiry;
     this.offers = consentToken.offers;
     this.locationID = consentToken.locationID;
     this.cid = consentToken.cid;
     this.offersString = consentToken.offersString;
     this.decodedToken = consentToken.decodedToken;
     this.token = consentToken.token;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Attempts to obtain a new, refreshed token and return it. The 
 /// original token is not modified.
 /// </summary>
 /// <param name="token">ConsentToken object.</param>
 /// <returns>Refreshed ConsentToken object.</returns>
 public ConsentToken RefreshConsentToken(ConsentToken token)
 {
     return RefreshConsentToken(token, null);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Attempts to obtain a new, refreshed token and return it. The 
        /// original token is not modified.
        /// </summary>
        /// <param name="token">ConsentToken object.</param>
        /// <param name="ru">The registered/configured return URL will be 
        /// overridden by 'ru' specified here.</param>
        /// <returns>Refreshed ConsentToken object.</returns>
        public ConsentToken RefreshConsentToken(ConsentToken token, string ru)
        {
            if (token == null)
            {
                debug("Error: RefreshConsentToken: Null consent token.");
                return null;
            }

            return RefreshConsentToken(token.OffersString, token.RefreshToken, ru);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Processes the consent token string that is returned in the POST 
        /// response by the Delegated Authentication service after a 
        /// user has granted consent.
        /// </summary>
        /// <param name="token">Raw token.</param>
        /// <param name="context">If you specify it, <paramref
        /// name="context"/> will be returned as-is in the sign-in
        /// response for site-specific use.</param>
        /// <returns></returns>
        public ConsentToken ProcessConsentToken(string token, string context)
        {
            string decodedToken = token;

            if (string.IsNullOrEmpty(token))
            {
                debug("Error: ProcessConsentToken: Null token.");
                return null;
            }

            NameValueCollection parsedToken =
              parse(HttpUtility.UrlDecode(token));

            if (!string.IsNullOrEmpty(parsedToken["eact"]))
            {
                decodedToken = DecodeAndValidateToken(parsedToken["eact"]);
                if (string.IsNullOrEmpty(decodedToken))
                {
                    debug("Error: ProcessConsentToken: Failed to decode/validate token: " +
                          token);
                    return null;
                }

                parsedToken = parse(decodedToken);
                decodedToken = HttpUtility.UrlEncode(decodedToken);
            }

            ConsentToken consentToken = null;
            try
            {
                consentToken = new ConsentToken(this,
                                                parsedToken["delt"],
                                                parsedToken["reft"],
                                                parsedToken["skey"],
                                                parsedToken["exp"],
                                                parsedToken["offer"],
                                                parsedToken["lid"],
                                                context, decodedToken,
                                                token);
            }
            catch (Exception e)
            {
                debug("Error: ProcessConsentToken: Contents of token considered invalid: " + e);
            }

            return consentToken;
        }