public AutomaticValueResult GetAutomaticValueForClaim(ClaimKey claim, TokenBuilderContext context) { Ensure.That(claim).IsNotNull(); Ensure.That(context).IsNotNull(); if (claim == ClaimKey.Expires) { if (context.Configuration?.GetRefreshTokenLength() != null) { var expiry = context.ReferenceTime .Add(context.Configuration.GetRefreshTokenLength().Value) .ToUnixTimestamp(); return(AutomaticValueResult.CreateSuccess(claim, expiry)); } else { return(AutomaticValueResult.CreateFail(claim, "Refresh token length value not found in configuration.")); } } else { return(AutomaticValueResult.CreateFail(claim, $"{claim} can not be automatically derived.")); } }
public ITokenBuilder WithClaim <T>(ClaimKey claimKey, T value) { this.throwOnDuplicateClaim(claimKey); this.payload[claimKey] = value; return(this); }
public ITokenBuilder WithClaim(ClaimKey claimKey) { this.throwOnDuplicateClaim(claimKey); this.automaticClaims.Add(claimKey); return(this); }