protected void validateVersion(OAuthMessage message)
 {
     String versionString = message.getParameter(OAuth.OAUTH_VERSION);
     if (versionString != null)
     {
         double version = double.Parse(versionString);
         if (version < minVersion || maxVersion < version)
         {
             OAuthProblemException problem = new OAuthProblemException("version_rejected");
             problem.setParameter("oauth_acceptable_versions", minVersion + "-" + maxVersion);
             throw problem;
         }
     }
 }
Exemple #2
0
        /** This implementation doesn't check the nonce value. */
        protected void validateTimestampAndNonce(OAuthMessage message)
        {
            message.requireParameters(new[] { OAuth.OAUTH_TIMESTAMP, OAuth.OAUTH_NONCE });
            DateTime timestamp = UnixTime.ToDateTime(double.Parse(message.getParameter(OAuth.OAUTH_TIMESTAMP)));
            DateTime now       = DateTime.UtcNow;
            DateTime min       = now.AddSeconds(0 - timestampWindow);
            DateTime max       = now.AddSeconds(timestampWindow);

            if (timestamp < min || max < timestamp)
            {
                OAuthProblemException problem = new OAuthProblemException("timestamp_refused");
                problem.setParameter("oauth_acceptable_timestamps", min + "-" + max);
                throw problem;
            }
        }
Exemple #3
0
        protected void validateVersion(OAuthMessage message)
        {
            String versionString = message.getParameter(OAuth.OAUTH_VERSION);

            if (versionString != null)
            {
                double version = double.Parse(versionString);
                if (version < minVersion || maxVersion < version)
                {
                    OAuthProblemException problem = new OAuthProblemException("version_rejected");
                    problem.setParameter("oauth_acceptable_versions", minVersion + "-" + maxVersion);
                    throw problem;
                }
            }
        }
Exemple #4
0
        /**
         * Verify that the required parameter names are contained in the actual
         * collection.
         *
         * @throws OAuthProblemException
         *                 one or more parameters are absent.
         * @throws IOException
         */
        public void requireParameters(String[] names)
        {
            ICollection <string> present = getParameterMap().Keys;
            List <string>        absent  = new List <string>();

            foreach (String required in names)
            {
                if (!present.Contains(required))
                {
                    absent.Add(required);
                }
            }
            if (absent.Count != 0)
            {
                OAuthProblemException problem = new OAuthProblemException(
                    "parameter_absent");
                problem.setParameter("oauth_parameters_absent", OAuth.percentEncode(absent));
                throw problem;
            }
        }
 /** This implementation doesn't check the nonce value. */
 protected void validateTimestampAndNonce(OAuthMessage message)
 {
     message.requireParameters(new[] { OAuth.OAUTH_TIMESTAMP, OAuth.OAUTH_NONCE });
     DateTime timestamp = UnixTime.ToDateTime(double.Parse(message.getParameter(OAuth.OAUTH_TIMESTAMP)));
     DateTime now = DateTime.UtcNow;
     DateTime min = now.AddSeconds(0 - timestampWindow);
     DateTime max = now.AddSeconds(timestampWindow);
     if (timestamp < min || max < timestamp)
     {
         OAuthProblemException problem = new OAuthProblemException("timestamp_refused");
         problem.setParameter("oauth_acceptable_timestamps", min + "-" + max);
         throw problem;
     }
 }
Exemple #6
0
 /**
  * Verify that the required parameter names are contained in the actual
  * collection.
  * 
  * @throws OAuthProblemException
  *                 one or more parameters are absent.
  * @throws IOException
  */
 public void requireParameters(String[] names)
 {
     ICollection<string> present = getParameterMap().Keys;
     List<string> absent = new List<string>();
     foreach (String required in names)
     {
         if (!present.Contains(required))
         {
             absent.Add(required);
         }
     }
     if (absent.Count != 0)
     {
         OAuthProblemException problem = new OAuthProblemException(
             "parameter_absent");
         problem.setParameter("oauth_parameters_absent", OAuth.percentEncode(absent));
         throw problem;
     }
 }