void ValidateNonce(ProtectedHeader protectedHeader) { if (!_nonceMgr.ValidateNonce(protectedHeader.Nonce)) { throw new Exception("Bad Nonce"); } }
private string GetSigningInput() { return(Encoding.ASCII.GetBytes( Base64UrlEncode(Encoding.UTF8.GetBytes(ProtectedHeader.ToString()))) + "." + Base64UrlEncode(Encoding.UTF8.GetBytes(Payload))); }
public void Verify() { try { var validationResults = new List <IComputationError>(); var parts = GetParts(); foreach (var prop in ProtectedHeader.Properties()) { switch (prop.Name) { case "alg": ALGVerifySignature(prop.Value <string>(), parts); break; default: throw new JsonWebSignatureException($"\"{prop.Name}\" Header Parameter has not been implemented."); } } throw new JsonWebSignatureException("The JWS signature MUST use an algorithm of \"RS256\", \"RS384\", or \"RS512\"."); } catch (Exception) { throw; } }
public string SerializeCompact() { return(string.Join(".", new string[] { Base64UrlEncode(Encoding.UTF8.GetBytes(ProtectedHeader.ToString())), Base64UrlEncode(Encoding.UTF8.GetBytes(Payload)), Base64UrlEncode(Encoding.ASCII.GetBytes(Signature)) })); }
public string[] GetParts() { string encodedProtectedHeader = Base64UrlEncode(Encoding.UTF8.GetBytes(ProtectedHeader.ToString())); string payload = Base64UrlEncode(Encoding.UTF8.GetBytes(Payload)); string signature = Base64UrlEncode(Encoding.ASCII.GetBytes(Signature)); return(new string[] { encodedProtectedHeader, payload, signature }); }