protected virtual SecurityToken CreateSecurityToken(ProtocolResponse oauthResponse) { string tokenType = oauthResponse.BodyParameters["token_type"]; string accessTokenString = oauthResponse.BodyParameters["access_token"]; var token = new JwtSecurityToken(accessTokenString); return token; }
protected virtual WebToken ExtractSecurityTokenFromResponse(ProtocolResponse oauthResponse) { string lifetime = oauthResponse.BodyParameters["wrap_access_token_expires_in"]; string accessTokenString = oauthResponse.BodyParameters["wrap_access_token"]; var token = new WebToken(accessTokenString); token.Expiration.AddSeconds(int.Parse(lifetime)); return token; }
private ProtocolResponse CreateJwtTokenResponse(JwtSecurityToken token) { var handler = new JwtSecurityTokenHandler(); string tokenString = handler.WriteToken(token); var bodyParameters = new Dictionary<string,string> { {"access_token", tokenString}, {"token_type", "urn:ietf:params:oauth:token-type:jwt"}, {"expires_in", "900"} }; var oauthResponse = new ProtocolResponse(bodyParameters); return oauthResponse; }
private ProtocolResponse CreateSwtTokenResponse() { var builder = new StringBuilder(); builder.AppendFormat("Issuer={0}&", HttpUtility.UrlEncode("http://mysts")); builder.AppendFormat("Audience={0}", HttpUtility.UrlEncode("myScope")); var bodyParameters = new Dictionary<string,string> { {"wrap_access_token", builder.ToString()}, {"wrap_access_token_expires_in", "900"} }; var oauthResponse = new ProtocolResponse(bodyParameters); return oauthResponse; }