<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: SAML, SSO and ColdFusion</title>
	<link>http://blog.tagworldwide.com/?p=19</link>
	<description></description>
	<pubDate>Tue, 07 Sep 2010 17:36:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: CFFusionDev</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-436</link>
		<dc:creator>CFFusionDev</dc:creator>
		<pubDate>Wed, 15 Apr 2009 16:10:08 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-436</guid>
		<description>Hi there,

I have my code running thanks to your blog. :-)

One question about line 
isValid = xmlSignature.checkSignatureValue(x509cert);

isValid returns *NO* in my case. Only thing different from your case is that assertion sent to me is not Base64 Encoded which means I dont 
use this line from your code on SP side
xmlResponse=CharsetEncode(BinaryDecode(form.SAMLRequest,”Base64″)
  ,”utf-8″);

Does that make any difference or you think it has to do with certificate in ds:X509Certificate element meaning this public key/certificate is different than what was used for signing?

Thanks,</description>
		<content:encoded><![CDATA[<p>Hi there,</p>
<p>I have my code running thanks to your blog. <img src='http://blog.tagworldwide.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>One question about line<br />
isValid = xmlSignature.checkSignatureValue(x509cert);</p>
<p>isValid returns *NO* in my case. Only thing different from your case is that assertion sent to me is not Base64 Encoded which means I dont<br />
use this line from your code on SP side<br />
xmlResponse=CharsetEncode(BinaryDecode(form.SAMLRequest,”Base64″)<br />
  ,”utf-8″);</p>
<p>Does that make any difference or you think it has to do with certificate in ds:X509Certificate element meaning this public key/certificate is different than what was used for signing?</p>
<p>Thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CFFusionDev</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-435</link>
		<dc:creator>CFFusionDev</dc:creator>
		<pubDate>Mon, 13 Apr 2009 17:10:27 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-435</guid>
		<description>Update... I still need code as mentioned in my earlier post and I am getting error when using current code below 



xmlResponse= tokenXML;

docElement= XmlParse(variables.xmlResponse).getDocumentElement();

SignatureConstants=CreateObject("Java", "org.apache.xml.security.utils.Constants");

SignatureSpecNS=SignatureConstants.SignatureSpecNS; 

xmlSignatureClass = CreateObject("Java","org.apache.xml.security.signature.XMLSignature");

xmlSignature = xmlSignatureClass.init(docElement.getElementsByTagNameNS(SignatureSpecNS,"Signature").item(0),""); // this lines gives error. see details below
//Exceptions 13:00:53.053 - Object Exception - in **** Object Instantiation //Exception.


keyInfo=xmlSignature.getKeyInfo();

X509CertificateResolverCN = CreateObject("Java","org.apache.xml.security.keys.keyresolver.implementations.X509CertificateResolverClass");

keyResolver=CreateObject("Java",X509CertificateResolverCN).init();

keyInfo.registerInternalKeyResolver(keyResolver);

x509cert = keyInfo.getX509Certificate();



For clarification purpose, its this line that throws error.

xmlSignature = xmlSignatureClass.init(docElement.getElementsByTagNameNS(SignatureSpecNS,"Signature").item(0),"");


I am trying to find solution but if you have suggestions please email me at CFFusionDev AT Gmail Dot Com.

Thanks,</description>
		<content:encoded><![CDATA[<p>Update&#8230; I still need code as mentioned in my earlier post and I am getting error when using current code below </p>
<p>xmlResponse= tokenXML;</p>
<p>docElement= XmlParse(variables.xmlResponse).getDocumentElement();</p>
<p>SignatureConstants=CreateObject(&#8221;Java&#8221;, &#8220;org.apache.xml.security.utils.Constants&#8221;);</p>
<p>SignatureSpecNS=SignatureConstants.SignatureSpecNS; </p>
<p>xmlSignatureClass = CreateObject(&#8221;Java&#8221;,&#8221;org.apache.xml.security.signature.XMLSignature&#8221;);</p>
<p>xmlSignature = xmlSignatureClass.init(docElement.getElementsByTagNameNS(SignatureSpecNS,&#8221;Signature&#8221;).item(0),&#8221;"); // this lines gives error. see details below<br />
//Exceptions 13:00:53.053 - Object Exception - in **** Object Instantiation //Exception.</p>
<p>keyInfo=xmlSignature.getKeyInfo();</p>
<p>X509CertificateResolverCN = CreateObject(&#8221;Java&#8221;,&#8221;org.apache.xml.security.keys.keyresolver.implementations.X509CertificateResolverClass&#8221;);</p>
<p>keyResolver=CreateObject(&#8221;Java&#8221;,X509CertificateResolverCN).init();</p>
<p>keyInfo.registerInternalKeyResolver(keyResolver);</p>
<p>x509cert = keyInfo.getX509Certificate();</p>
<p>For clarification purpose, its this line that throws error.</p>
<p>xmlSignature = xmlSignatureClass.init(docElement.getElementsByTagNameNS(SignatureSpecNS,&#8221;Signature&#8221;).item(0),&#8221;");</p>
<p>I am trying to find solution but if you have suggestions please email me at CFFusionDev AT Gmail Dot Com.</p>
<p>Thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Howie</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-403</link>
		<dc:creator>Howie</dc:creator>
		<pubDate>Tue, 05 Aug 2008 18:48:00 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-403</guid>
		<description>is this portion of code correct?
transforms = TransformsClass
.init(samlAssertionDocument
transforms.addTransform(transformOmitCommentsStr);

I changed it to 

transforms = TransformsClass.init(samlAssertionDocument);
transforms.addTransform(transformOmitCommentsStr);
transforms.addTransform(transformEnvStr);

and got past that error but now i am getting 
Cannot resolve element with ID 940A010B-188B-73FA-E68F75D98735111E  
on the signature.sign(key);
which is probably unrelated</description>
		<content:encoded><![CDATA[<p>is this portion of code correct?<br />
transforms = TransformsClass<br />
.init(samlAssertionDocument<br />
transforms.addTransform(transformOmitCommentsStr);</p>
<p>I changed it to </p>
<p>transforms = TransformsClass.init(samlAssertionDocument);<br />
transforms.addTransform(transformOmitCommentsStr);<br />
transforms.addTransform(transformEnvStr);</p>
<p>and got past that error but now i am getting<br />
Cannot resolve element with ID 940A010B-188B-73FA-E68F75D98735111E<br />
on the signature.sign(key);<br />
which is probably unrelated</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-361</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Mon, 02 Jun 2008 20:36:37 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-361</guid>
		<description>Well, in one of those "is it plugged in?" kinda moments, I just realized I'm trying to process a SAML 2.0 packet with your SAML 1.0 processing code, so that's probably the source of my consistent failures :)

I must not be getting the correct XML elements passed into the certificate validation functions because of the differences in protocols.  

Back to the docs I go!</description>
		<content:encoded><![CDATA[<p>Well, in one of those &#8220;is it plugged in?&#8221; kinda moments, I just realized I&#8217;m trying to process a SAML 2.0 packet with your SAML 1.0 processing code, so that&#8217;s probably the source of my consistent failures <img src='http://blog.tagworldwide.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I must not be getting the correct XML elements passed into the certificate validation functions because of the differences in protocols.  </p>
<p>Back to the docs I go!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Clausen</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-360</link>
		<dc:creator>Jon Clausen</dc:creator>
		<pubDate>Mon, 02 Jun 2008 18:48:22 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-360</guid>
		<description>@all - sorry about the formatting, looks like the comment system stripped out the tags the above is inside a cfscript block.  The cffunction tag has one argument, document whichi is the SAM assertion XML object.</description>
		<content:encoded><![CDATA[<p>@all - sorry about the formatting, looks like the comment system stripped out the tags the above is inside a cfscript block.  The cffunction tag has one argument, document whichi is the SAM assertion XML object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Clausen</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-359</link>
		<dc:creator>Jon Clausen</dc:creator>
		<pubDate>Mon, 02 Jun 2008 18:40:01 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-359</guid>
		<description>@David,@Justin

- Guys actually, my suggestion works on CF8 and CF7.   My dev server is CF8 and the production server is still CF7.

Here's the full content of my signing function:




var samlAssertionXML=arguments.document;
var xmlout = "";
//Create our Signing Objects from XMLSEC
var samlAssertionElement =  samlAssertionXML.getDocumentElement();
var samlAssertionDocument = samlAssertionElement.GetOwnerDocument();
var samlAssertion = samlAssertionDocument.getFirstChild();
var SignatureSpecNS = CreateObject("Java", "org.apache.xml.security.utils.Constants").SignatureSpecNS;
var TransformsClass = CreateObject("Java","org.apache.xml.security.transforms.Transforms");
var SecInit = CreateObject("Java", "org.apache.xml.security.Init").Init().init();
var XMLSignatureClass = CreateObject("Java", "org.apache.xml.security.signature.XMLSignature");
var sigType = XMLSignatureClass.ALGO_ID_SIGNATURE_DSA;
var signature = XMLSignatureClass.init(samlAssertionDocument, toString(""), sigType); 
//transform class vars
var transformEnvStr = "";
var transformOmitCommentsStr ="";
var transforms ="";
//Insert signature
samlAssertionElement
  .insertBefore(signature 
  .getElement(),samlAssertion.getFirstChild());
//transform document for XMLSEC into enveloped signature
transformEnvStr =  
TransformsClass.TRANSFORM_ENVELOPED_SIGNATURE;
transformOmitCommentsStr =
TransformsClass.TRANSFORM_C14N_EXCL_WITH_COMMENTS;
transforms = TransformsClass.init(samlAssertionDocument);
transforms.addTransform(transformOmitCommentsStr);
transforms.addTransform(transformEnvStr);
//Scope our Cert and key variables
getAuthCert();
//Now add our signature
signature.addDocument("#chr(35)##controller.getBean("AssertionID")#"
  , transforms);
signature.addKeyInfo(variables.cert);
signature.addKeyInfo(variables.publickey);
signature.sign(variables.key);
xmlout = samlAssertionXML;
return xmlout;




HTH,
Jon</description>
		<content:encoded><![CDATA[<p>@David,@Justin</p>
<p>- Guys actually, my suggestion works on CF8 and CF7.   My dev server is CF8 and the production server is still CF7.</p>
<p>Here&#8217;s the full content of my signing function:</p>
<p>var samlAssertionXML=arguments.document;<br />
var xmlout = &#8220;&#8221;;<br />
//Create our Signing Objects from XMLSEC<br />
var samlAssertionElement =  samlAssertionXML.getDocumentElement();<br />
var samlAssertionDocument = samlAssertionElement.GetOwnerDocument();<br />
var samlAssertion = samlAssertionDocument.getFirstChild();<br />
var SignatureSpecNS = CreateObject(&#8221;Java&#8221;, &#8220;org.apache.xml.security.utils.Constants&#8221;).SignatureSpecNS;<br />
var TransformsClass = CreateObject(&#8221;Java&#8221;,&#8221;org.apache.xml.security.transforms.Transforms&#8221;);<br />
var SecInit = CreateObject(&#8221;Java&#8221;, &#8220;org.apache.xml.security.Init&#8221;).Init().init();<br />
var XMLSignatureClass = CreateObject(&#8221;Java&#8221;, &#8220;org.apache.xml.security.signature.XMLSignature&#8221;);<br />
var sigType = XMLSignatureClass.ALGO_ID_SIGNATURE_DSA;<br />
var signature = XMLSignatureClass.init(samlAssertionDocument, toString(&#8221;"), sigType);<br />
//transform class vars<br />
var transformEnvStr = &#8220;&#8221;;<br />
var transformOmitCommentsStr =&#8221;";<br />
var transforms =&#8221;";<br />
//Insert signature<br />
samlAssertionElement<br />
  .insertBefore(signature<br />
  .getElement(),samlAssertion.getFirstChild());<br />
//transform document for XMLSEC into enveloped signature<br />
transformEnvStr =<br />
TransformsClass.TRANSFORM_ENVELOPED_SIGNATURE;<br />
transformOmitCommentsStr =<br />
TransformsClass.TRANSFORM_C14N_EXCL_WITH_COMMENTS;<br />
transforms = TransformsClass.init(samlAssertionDocument);<br />
transforms.addTransform(transformOmitCommentsStr);<br />
transforms.addTransform(transformEnvStr);<br />
//Scope our Cert and key variables<br />
getAuthCert();<br />
//Now add our signature<br />
signature.addDocument(&#8221;#chr(35)##controller.getBean(&#8221;AssertionID&#8221;)#&#8221;<br />
  , transforms);<br />
signature.addKeyInfo(variables.cert);<br />
signature.addKeyInfo(variables.publickey);<br />
signature.sign(variables.key);<br />
xmlout = samlAssertionXML;<br />
return xmlout;</p>
<p>HTH,<br />
Jon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Rutter</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-358</link>
		<dc:creator>David Rutter</dc:creator>
		<pubDate>Mon, 02 Jun 2008 17:23:07 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-358</guid>
		<description>Hi Justin,

You can use this in CF7 - our original implementation was on CF7.
We had to use some introspection code as follows 

  Init = CreateObject("Java", "org.apache.xml.security.Init");
  emptyArray = ArrayNew(1);
  initMethod=Init.GetClass().GetMethod("init",emptyArray);
  initMethod.invoke(Init,emptyArray);

Jon's suggestion is obviously the better way but I think this is CF8 only.

  var Init = CreateObject(”Java”, “org.apache.xml.security.Init”).Init().init()</description>
		<content:encoded><![CDATA[<p>Hi Justin,</p>
<p>You can use this in CF7 - our original implementation was on CF7.<br />
We had to use some introspection code as follows </p>
<p>  Init = CreateObject(&#8221;Java&#8221;, &#8220;org.apache.xml.security.Init&#8221;);<br />
  emptyArray = ArrayNew(1);<br />
  initMethod=Init.GetClass().GetMethod(&#8221;init&#8221;,emptyArray);<br />
  initMethod.invoke(Init,emptyArray);</p>
<p>Jon&#8217;s suggestion is obviously the better way but I think this is CF8 only.</p>
<p>  var Init = CreateObject(”Java”, “org.apache.xml.security.Init”).Init().init()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-357</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Fri, 30 May 2008 18:18:24 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-357</guid>
		<description>Hi David,

I recently found your article while researching Coldfusion &#38; SAML examples online.  I'm in the middle of trying to put together a SAML Consumer-only SSO scenerio for a site that runs on CF MX 7.  I noticed your steps assume CF 8, but nothing I've seen in there so far looks implicit to 8, except possibly some of the really lower-level Java stuff that I'm not quite as familliar with.  As far as you know, will your example run on MX as well, or are there known road-blocks there?  

While implementing your SAML Consumer/decryption code as a test, I keep getting tripped up on the "keyInfo" field, which CF MX claims is never defined, thus the getX509Certificate() and final isValid() calls against that object fail.

The one part that's a little unclear to me is where in the flow of the process the init override code snippit has to fall?  I've written a saml.cfc file that has a comsume() method in it that handles the POST, and within there, have implemented your code.  I just pasted the init block right at the top of that function, and it doesn't seem to be complaining... 

Anyhow... any insight into the CF MX vs. 8 issue would be appreciated.  It'd be nice to know I'm not beating my head against a wall I cannot overcome :)

-Justin</description>
		<content:encoded><![CDATA[<p>Hi David,</p>
<p>I recently found your article while researching Coldfusion &amp; SAML examples online.  I&#8217;m in the middle of trying to put together a SAML Consumer-only SSO scenerio for a site that runs on CF MX 7.  I noticed your steps assume CF 8, but nothing I&#8217;ve seen in there so far looks implicit to 8, except possibly some of the really lower-level Java stuff that I&#8217;m not quite as familliar with.  As far as you know, will your example run on MX as well, or are there known road-blocks there?  </p>
<p>While implementing your SAML Consumer/decryption code as a test, I keep getting tripped up on the &#8220;keyInfo&#8221; field, which CF MX claims is never defined, thus the getX509Certificate() and final isValid() calls against that object fail.</p>
<p>The one part that&#8217;s a little unclear to me is where in the flow of the process the init override code snippit has to fall?  I&#8217;ve written a saml.cfc file that has a comsume() method in it that handles the POST, and within there, have implemented your code.  I just pasted the init block right at the top of that function, and it doesn&#8217;t seem to be complaining&#8230; </p>
<p>Anyhow&#8230; any insight into the CF MX vs. 8 issue would be appreciated.  It&#8217;d be nice to know I&#8217;m not beating my head against a wall I cannot overcome <img src='http://blog.tagworldwide.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>-Justin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Clausen</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-349</link>
		<dc:creator>Jon Clausen</dc:creator>
		<pubDate>Thu, 22 May 2008 21:39:43 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-349</guid>
		<description>Update:  My problem was related to instantiating the org.apache.xml.security.Init object with createObject().  There's a known issue in the way that CF handles Init().

I simply changed:

var Init = CreateObject("Java", "org.apache.xml.security.Init").Init()

to

var Init = CreateObject("Java", "org.apache.xml.security.Init").Init().init()

and the problem was solved.

Thanks again for you work on this.  It was a lifesaver.</description>
		<content:encoded><![CDATA[<p>Update:  My problem was related to instantiating the org.apache.xml.security.Init object with createObject().  There&#8217;s a known issue in the way that CF handles Init().</p>
<p>I simply changed:</p>
<p>var Init = CreateObject(&#8221;Java&#8221;, &#8220;org.apache.xml.security.Init&#8221;).Init()</p>
<p>to</p>
<p>var Init = CreateObject(&#8221;Java&#8221;, &#8220;org.apache.xml.security.Init&#8221;).Init().init()</p>
<p>and the problem was solved.</p>
<p>Thanks again for you work on this.  It was a lifesaver.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Clausen</title>
		<link>http://blog.tagworldwide.com/?p=19#comment-344</link>
		<dc:creator>Jon Clausen</dc:creator>
		<pubDate>Thu, 22 May 2008 04:26:38 +0000</pubDate>
		<guid>http://blog.tagworldwide.com/?p=19#comment-344</guid>
		<description>David,

Great post.  Your walkthrough and Phil Duba's SAML and Coldfusion series have been lifesavers in trying to implement an SSO.   Not to make you debug my code or anything, but I've tried both Phil's and your method and in both cases seem to be throwing an instantiation error when attempting to pass the samlAssertionDocument into the constructor of the XMLSignatureClass.   

Looking at the javadocs, the constructor for the XMLSignature class seems to be getting the correct types passed in but throws "The class must not be an interface or an abstract class"

Any thoughts or lessons learned in your work on this which might provide me a clue?

Thanks.</description>
		<content:encoded><![CDATA[<p>David,</p>
<p>Great post.  Your walkthrough and Phil Duba&#8217;s SAML and Coldfusion series have been lifesavers in trying to implement an SSO.   Not to make you debug my code or anything, but I&#8217;ve tried both Phil&#8217;s and your method and in both cases seem to be throwing an instantiation error when attempting to pass the samlAssertionDocument into the constructor of the XMLSignatureClass.   </p>
<p>Looking at the javadocs, the constructor for the XMLSignature class seems to be getting the correct types passed in but throws &#8220;The class must not be an interface or an abstract class&#8221;</p>
<p>Any thoughts or lessons learned in your work on this which might provide me a clue?</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
