Skip to content

Instantly share code, notes, and snippets.

View Isaac-Kleinman's full-sized avatar

Isaac Kleinman Isaac-Kleinman

View GitHub Profile
@Isaac-Kleinman
Isaac-Kleinman / gist:1601862
Created January 12, 2012 17:23
vim: enclose the text on a line with '', e.g. ^ some_text $ turns into ^ 'some_text', $
x,ys/[^[:space:]]\+/'&',/
@Isaac-Kleinman
Isaac-Kleinman / jugglefest.pl
Created May 29, 2013 14:26
Yodle presented this programming challenge as an interview 'fizz buzz' problem: http://www.yodlecareers.com/puzzles/jugglefest.html. Attached is my verified solution.
#!/usr/bin/perl
#####21 Juggle Fest or
##### the Hospital/Residents Problem with ties and partial lists
use strict;
use List::Util qw( reduce sum );
use feature qw( say );
@Isaac-Kleinman
Isaac-Kleinman / svcutil_output.txt
Created May 5, 2014 21:47
svcutil output for eMedNy Medical History Service
C:\Users\IKleinman\Temp>svcutil https://service01.emedny.org:7602/MHService?wsdl
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.17929]
Copyright (c) Microsoft Corporation. All rights reserved.
Attempting to download metadata from 'https://service01.emedny.org:7602/MHService?wsdl' using WS-Metadata Exchange or DISCO.
Warning: The following Policy Assertions were not Imported:
XPath://wsdl:definitions[@targetNamespace='http://org/emedny/mhs/']/wsdl:binding[@name='MHS']
Assertions:
<dpe:summary xmlns:dpe='http://www.datapower.com/extensions'>..</dpe:summary>
@Isaac-Kleinman
Isaac-Kleinman / output.config
Created May 5, 2014 21:54
svcutil generated config file
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="MHService_MHSPort">
<!-- WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'http://org/emedny/mhs/': -->
<!-- <wsdl:binding name='MHS'> -->
<!-- <dpe:summary xmlns:dpe="http://www.datapower.com/extensions">..</dpe:summary> -->
<!-- <sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">..</sp:SupportingTokens> -->
@Isaac-Kleinman
Isaac-Kleinman / emedny_request.xml
Created May 5, 2014 21:56
eMedNy-provided SOAP Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mhs="http://org/emedny/mhs/" xmlns:urn="urn:hl7-org:v3">
<soapenv:Header>
<wsse:Security soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-e00c8062-83d2-4f04-88fc-996218e7bb3d">MIICeDCC....(eMedNY signed user MLS cert).......</wsse:BinarySecurityToken>
<wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-securi
@Isaac-Kleinman
Isaac-Kleinman / firstDraftClient.cs
Created May 5, 2014 21:59
A first attempt at configuring the SOAP request programmatically
AsymmetricSecurityBindingElement sec;
sec = (AsymmetricSecurityBindingElement) SecurityBindingElement.CreateMutualCertificateBindingElement(
MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10);
sec.DefaultAlgorithmSuite = SecurityAlgorithmSuite.TripleDesRsa15;
sec.IncludeTimestamp = false;
sec.AllowSerializedSigningTokenOnReply = true;
sec.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
sec.EndpointSupportingTokenParameters.Signed.Add( new UserNameSecurityTokenParameters( ));
@Isaac-Kleinman
Isaac-Kleinman / firstDraftClient.xml
Created May 5, 2014 22:00
Message Generated by firstDraftClient.cs
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:BinarySecurityToken u:Id="uuid-604c12aa-1a76-4f40-b7e3-57857b596549-3" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
MIICL...(USER CERTIFICATE)...lmdGpDz8gbg646R5gzebF1waazrrVM=</o:BinarySecurityToken>
<e:EncryptedKey Id="_0" xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<o:SecurityTokenReference>
<o:KeyIde
@Isaac-Kleinman
Isaac-Kleinman / firstDraftException.txt
Created May 5, 2014 22:02
Exception thrown when running firstDraftClient.cs
Unhandled Exception: System.ServiceModel.Security.SecurityNegotiationException: Could not establish
trust relationship for the SSL/TLS secure channel with authority 'service01.emedny.org:7602'.
---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. --->
using System;
using System.ServiceModel.Channels;
using System.Xml;
namespace eMedNySOAPClient
{
public class CustomTextMessageBindingElement : MessageEncodingBindingElement
{
private MessageVersion msgVersion;
private string mediaType;
using System.ServiceModel.Channels;
namespace eMedNySOAPClient
{
public class CustomTextMessageEncoderFactory : MessageEncoderFactory
{
private MessageEncoder encoder;
internal CustomTextMessageEncoderFactory(string contentType, MessageVersion msgVersion)
{