public T GetClaimValue <T>(string key, ITokenSpec tokenSpec) { T value = default(T); if (this.automaticClaims.Contains(key)) { var context = this.createContext(); var result = tokenSpec .GetAutomaticValueForClaim(key, context) .ThrowOnFail(); value = (T)result.Value; } else if (this.payload.Keys.Contains(key)) { value = (T)this.payload[key]; } return(value); }
private IDictionary <string, object> deriveAutomaticClaims( ITokenSpec tokenSpec, IEnumerable <string> automaticClaims, TokenBuilderContext context) { Dictionary <string, object> answer = new Dictionary <string, object>(); foreach (var claim in automaticClaims) { var result = tokenSpec .GetAutomaticValueForClaim(claim, context) .ThrowOnFail(); if (result.Value != null) { answer[claim] = result.Value; } } return(answer); }