This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jwt header | |
var header = new { typ = "JWT", alg = "RS256" }; | |
// encoding | |
var headerBytes = Encoding.UTF8.GetBytes(_jsonProvider.Serialize(header)); | |
var headerEncoded = _base64Encoder.ToBase64UrlEncodedString(headerBytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jwt claimset | |
var issueTime = _dateTimeConverter.ToUnixTimeStamp(date); | |
var expiryTime = _dateTimeConverter.ToUnixTimeStamp(date.AddMinutes(60)); | |
var claim = new | |
{ | |
iss = serviceAccountEmail, | |
scope = "https://www.googleapis.com/auth/bigquery", | |
aud = "https://accounts.google.com/o/oauth2/token", | |
iat = issueTime, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// signature | |
var signature = headerEncoded + "." + claimEncoded; | |
var signatureBytes = Encoding.UTF8.GetBytes(signature); | |
var certificate = new X509Certificate2(privateKey, privateKeyPassword); | |
// sign signature using SHA256 with RSA | |
var rsa = (RSACryptoServiceProvider)certificate.PrivateKey; | |
// As of .NET 3.5 SP1 the CSP instance works with a provider of type PROV_RSA_AES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var post = new Dictionary<string, string> | |
{ | |
{"grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer"}, | |
{"assertion", jwt } | |
}; | |
var response = _httpClientProvider.PostAsync(URI, _httpContentProvider.GetFormUrlEncodedContent(post)); | |
var accessToken = _jsonProvider.Deserialize<AccessToken>(response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AccessToken | |
{ | |
[JsonProperty(PropertyName = "access_token")] | |
public string Token { get; set; } | |
[JsonProperty(PropertyName = "token_type")] | |
public string TokenType { get; set; } | |
[JsonProperty(PropertyName = "expires_in")] | |
public int ExpiresIn { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('http').createServer(handler), | |
io = require('socket.io').listen(app), | |
fs = require('fs'); | |
app.listen(8888); | |
function handler (req, res) { | |
fs.readFile(__dirname + req.url, function (err, data) { | |
if (err) { | |
res.writeHead(500); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="/jquery/1.4.4/jquery.min.js" ></script> | |
<script src="/socket.io/socket.io.js" ></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('#connect-button').click(function() { | |
$('#form-container').show(300); | |
var socket = io.connect('<hostname>', {port: 8888}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var converter = (function () { | |
'use strict'; | |
var romanNumeralsArray = [ | |
{roman: 'I', number: 1}, | |
{roman: 'V', number: 5}, | |
{roman: 'X', number: 10}, | |
{roman: 'L', number: 50}, | |
{roman: 'C', number: 100}, | |
{roman: 'D', number: 500}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var environment = process.env.NODE_ENV || ''; | |
var config = require('../config_' + environment), | |
sql = require('node-sqlserver'), | |
visit = {}; | |
visit.log = function (message, callback) { | |
var visitparams = [], | |
encodedmsg = unescape(message.data), | |
msg = JSON.parse(encodedmsg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config_development = {} | |
config_development.CLOUD_AMQP = 'amqp://127.0.0.1:5672'; | |
config_development.EXCHANGE_NAME = 'DataExchange'; | |
config_development.QUEUE_NAME = 'SqlSubscriberQueue'; | |
config_development.SQL = {}; | |
config_development.SQL.ConnectionString = 'Driver={SQL Server Native Client 10.0};Server=(local);Database=Reporting;Trusted_Connection={Yes}'; | |
var parsesqlconnectionstring = (function () { |
OlderNewer