Put verify under different function. Added new error codes for verification failures.

This commit is contained in:
Arun M 2017-12-16 16:39:52 +05:30
parent 912e4b5ff9
commit 7a511c46fe
7 changed files with 204 additions and 30 deletions

View file

@ -59,11 +59,42 @@ struct DecodeErrorCategory: std::error_category
}
};
/**
*/
struct VerificationErrorCategory: std::error_category
{
const char* name() const noexcept override
{
return "verification";
}
std::string message(int ev) const override
{
switch (static_cast<VerificationErrc>(ev))
{
case VerificationErrc::InvalidAlgorithm:
return "invalid algorithm";
case VerificationErrc::TokenExpired:
return "token expired";
case VerificationErrc::InvalidIssuer:
return "invalid issuer";
case VerificationErrc::InvalidAudience:
return "invalid audience";
case VerificationErrc::ImmatureSignature:
return "immature signature";
};
assert (0 && "Code not reached");
}
};
// Create global object for the error categories
const AlgorithmErrCategory theAlgorithmErrCategory {};
const DecodeErrorCategory theDecodeErrorCategory {};
const VerificationErrorCategory theVerificationErrorCategory {};
}
@ -78,6 +109,10 @@ std::error_code make_error_code(DecodeErrc err)
return { static_cast<int>(err), theDecodeErrorCategory };
}
std::error_code make_error_code(VerificationErrc err)
{
return { static_cast<int>(err), theVerificationErrorCategory };
}
} // END namespace jwt