Skip to content

Instantly share code, notes, and snippets.

View DinoChiesa's full-sized avatar

Dino Chiesa DinoChiesa

View GitHub Profile
@DinoChiesa
DinoChiesa / HelloWorldPort.wsdl
Created October 3, 2013 18:44
HelloWorld WSDL
<wsdl:definitions
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:wsp="http://www.w3.org/ns/ws-policy"
xmlns:wsp200409="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsp200607="http://www.w3.org/2006/07/ws-policy"
xmlns:ns0="http://default_package/" targetNamespace="http://default_package/">
// createKeyPair.js
// ------------------------------------------------------------------
//
// created: Thu Feb 28 15:49:15 2019
// last saved: <2023-March-29 14:19:28>
/* jshint esversion:9, node: true */
/* global process, console, Buffer, require */
const crypto = require('crypto');
@DinoChiesa
DinoChiesa / httpsig-in-postman-pre-request-script.js
Created January 26, 2016 23:18
pre-request script for Postman, to perform HttpSignature calculation. Also SHA-256 message digest.
function computeHttpSignature(config, headerHash) {
var template = 'keyId="${keyId}",algorithm="${algorithm}",headers="${headers}",signature="${signature}"',
sig = template;
// compute sig here
var signingBase = '';
config.headers.forEach(function(h){
if (signingBase !== '') { signingBase += '\n'; }
signingBase += h.toLowerCase() + ": " + headerHash[h];
});
@DinoChiesa
DinoChiesa / target-1.xml
Created April 5, 2022 01:51
Apigee target endpoint showing the use of implicit GCP authentication
<TargetEndpoint name="target-1">
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>AM-Query</Name>
</Step>
</Request>
<Response>
<Step>
<Name>AM-Clean-Response-Headers</Name>
// GenerateGcpAccessTokenForServiceAccount.java
// ------------------------------------------------------------------
//
// Requires Java 11 or later
//
// compile: javac -cp
// lib/nimbus-jose-jwt-8.22.jar:lib/json-smart-1.3.2.jar:lib/bcprov-jdk15on-1.64.jar:lib/bcpkix-jdk15on-1.64.jar %f
//
// run: java -classpath
// lib/nimbus-jose-jwt-8.22.jar:lib/json-smart-1.3.2.jar:lib/bcprov-jdk15on-1.64.jar:lib/bcpkix-jdk15on-1.64.jar %n
@DinoChiesa
DinoChiesa / weightedRandomSelector2.js
Created December 2, 2021 21:15
perform a weighted random selection in JS
// weightedRandomSelector.js
//
// This is a simple weighted random selector, works in Rhino, can use within an
// Apigee JavaScript step.
//
// last saved: <2021-December-02 13:11:16>
//
// --------------------------------------------------------
(function (){
@DinoChiesa
DinoChiesa / json-Stringify.js
Created September 29, 2021 19:45
diagnose JSON.stringify failure
/* jshint esversion:6, node:false, strict:implied */
/* global print, context */
function createPartialCopy(obj, partialPropertyList) {
// create new "partial copy" with only a subset of properties
return partialPropertyList.reduce(function(a, prop) {
a[prop] = obj[prop];
return a;
}, {});
}
@DinoChiesa
DinoChiesa / showcertssubjectandissuer
Created August 13, 2021 19:20
bash script, depends on openssl and perl, to show cert chain subject and issuer for a host. Runs on OS X
#!/bin/bash
# uncomment to debug
# set -x
usage() {
printf "%s: display subject and issuer of certificates in the chain that a host presents\n" $0
printf "usage:\n"
printf " %s HOSTNAME\n" $0
printf " show cert subject and issuer\n\n"
@DinoChiesa
DinoChiesa / JS-ShredJSON.xml
Last active June 10, 2021 17:15
Shred JSON into context variables
<Javascript name='JS-ShredJSON' timeLimit='200' >
<Properties>
<Property name='output-prefix'>private</Property>
<Property name='source'>ContextVariableContainingJSON</Property>
</Properties>
<ResourceURL>jsc://extractJsonToContextVars.js</ResourceURL>
</Javascript>
@DinoChiesa
DinoChiesa / getTokenWithServiceAccount.js
Last active April 16, 2021 00:18
get a GCP token using a Service Account .json file
// getTokenWithServiceAccount.js
// ------------------------------------------------------------------
// uses only builtin modules, no external dependencies.
/* jshint esversion:9, node:true, strict:implied */
/* global process, console, Buffer */
const crypto = require('crypto'),
util = require('util'),