コード例 #1
0
 public bool AuthenticateUser(ChallengeResponse challengeResponse)
 {
     if (authAndPayService.IsValidChallengeResponse(challengeResponse))
     {
         authAndPayService.AuthenticateUser(challengeResponse.UserName, challengeResponse.EpochTime);
         return true;
     }
     return false;
 }
コード例 #2
0
        public ChallengeResponse ParseAuthChallenge(string input, string userName,string key)
        {
            char[] seps={'/'};//For Epoche Time
            String [] values = input.Split(seps);//For Epoche Time

               string op =  CalculateHMAC(input, userName, key);

            ChallengeResponse cmac = new ChallengeResponse
            {
                EpochTime = Convert.ToInt64 ( values[1]),
                UserName = userName,
                HMAC = op
            };
            return cmac;
        }
コード例 #3
0
 public bool IsValidChallengeResponse(ChallengeResponse challengeResponse)
 {
     string challenge = GetAuthChallenge(challengeResponse.UserName,challengeResponse.EpochTime);
     string secret = GetSecretOfUser(challengeResponse.UserName);
     string input = String.Format("{0}/{1}/{2}/{3}",
         "01",
         challengeResponse.EpochTime,
         challenge,challengeResponse.UserName);
     string hash = cryptoService.CalculateHmac(secret, challenge);
     return (challengeResponse.HMAC != null && challengeResponse.HMAC.Equals(hash));
 }