/// <summary> /// Generates a new Token for some <see cref="subject"/> /// </summary> /// <param name="subject">The subject to generate the token for</param> /// <param name="issuer">As who to create the token (the owner of the <see cref="signingPair"/>)</param> /// <param name="signingPair">The <see cref="SigningKeyPair"/> of the <see cref="issuer"/></param> /// <param name="expirationTime">The unix time when this token expires</param> /// <param name="claims">Optional additional claims to add to the token, may not be one of [iss,sub,id,iat] as these are already set</param> /// <returns>The newly created and signed token</returns> public Token GenerateNewToken( EntityId subject, EntityId issuer, SigningKeyPair signingPair, long expirationTime, params KeyValuePair <string, string>[] claims) { return(ConstructToken(subject, issuer, expirationTime) .AddClaims(claims) .Sign(signingPair)); }
/// <summary> /// Generates a new Token for some <see cref="subject"/> /// </summary> /// <param name="subject">The subject to generate the token for</param> /// <param name="issuer">As who to create the token</param> /// <param name="signingPair">The <see cref="SigningKeyPair"/> of the <see cref="issuer"/></param> /// <param name="claims">Optional additional claims to add to the token, may not be one of [iss,sub,id,iat] as these are already set</param> /// <returns>The newly created and signed token</returns> public Token GenerateNewToken( EntityId subject, EntityId issuer, SigningKeyPair signingPair, params KeyValuePair <string, string>[] claims) { return(new Token() .AddClaim("iss", issuer.ToString()) .AddClaim("sub", subject.ToString()) .AddClaim("id", ThreadSaveIdGenerator.NextId.ToString()) .AddClaim("iat", DateTime.UtcNow.ToFileTimeUtc().ToString()) .AddClaims(claims) .Sign(signingPair)); }
/// <summary> /// Signs the Token with a KeyPair /// </summary> /// <param name="keyPair">The keypair to use to sign the token</param> public Token Sign(SigningKeyPair keyPair) { signature.algorythm = keyPair.algorythm; signature.GenerateSignature(SignableContent, keyPair); return(this); }
public SecureReference(SigningKeyPair keyPair) { KeyPair = keyPair; }
/// <summary> /// Adds a new Signing KeyPair and persists it /// </summary> /// <param name="owner">The owner of the keyPair</param> /// <param name="keyPair"></param> public void AddSigningKeyPair(EntityId owner, SigningKeyPair keyPair) { signingKeyPairs.Add(owner, keyPair); }