Skip to content
Browse files

Added a test keystore

Added a test to testKeystore to validate it's working
Fixed bug in Keystore found with testing (load takes password)
Removed comment from SAMLService
  • Loading branch information...
1 parent bef5c2b commit 98bac81277c88becf75354eb5e0c609f9dc66d1a Anthony Israel-Davis committed May 27, 2011
Showing with 14 additions and 8 deletions.
  1. BIN keystore.jks
  2. +1 −1 src/Keystore.cfc
  3. +3 −4 src/SAMLService.cfc
  4. +10 −3 tests/testKeystore.cfc
View
BIN keystore.jks
Binary file not shown.
View
2 src/Keystore.cfc
@@ -9,7 +9,7 @@
var KeyStoreClass = CreateObject("Java" , "java.security.KeyStore");
var keystore = KeyStoreClass.getInstance("JKS"); // JKS is the keystore type - may be variable
- keystore.load(inputStream,arguments.certificateAlias);
+ keystore.load(inputStream,arguments.keyPass.toCharArray());
variables.key = keystore.getKey(arguments.certificateAlias,arguments.keyPass.toCharArray());
variables.cert = keystore.getCertificate(arguments.certificateAlias);
variables.publickey = variables.cert.getPublicKey();
View
7 src/SAMLService.cfc
@@ -205,8 +205,6 @@
<cfreturn samlAssertionXML>
</cffunction>
- <!--- TODO Refactor this into either a more friendly function or multiple functions --->
-
<cffunction name="signSAML" output="false" access="public">
<cfargument name="samlAssert">
<cfargument name="assertionId">
@@ -216,12 +214,13 @@
var samlAssertionElement = samlAssertionXML.getDocumentElement();
var samlAssertionDocument = samlAssertionElement.GetOwnerDocument();
var samlAssertion = samlAssertionDocument.getFirstChild();
- var signature = getSignature();
-
+
var conditionsNode = samlAssertionElement.getElementsByTagName('saml:Conditions');
var assertionNode = samlAssertionElement.getElementsByTagName('saml:Assertion');
var statusNode = samlAssertionElement.getElementsByTagName('samlp:Status');
+ var signature = getSignature();
+
//set up signature transforms
var transforms = variables.TransformsClass.init(assertionNode.item(0).getOwnerDocument());
transforms.addTransform(variables.transformEnvStr);
View
13 tests/testKeystore.cfc
@@ -1,10 +1,17 @@
<cfcomponent extends="mxunit.framework.TestCase" output="false">
<cffunction name="setup">
- <cfset keystore = createObject("component","cfSAML.src.Keystore")>
- <!--- <cfset kestore.init(keystoreFile,keyPass,certificateAlias)> --->
+ <cfscript>
+ var currentDirectory = getDirectoryFromPath(getCurrentTemplatePath());
+ var keystoreFile = reREplace(currentDirectory,"tests[/|\\]","keystore.jks");
+ keystore = createObject("component","cfSAML.src.Keystore").init(keystoreFile,"password","selfsigned");
+ </cfscript>
</cffunction>
- <cffunction name="testGetKeyStoreFile_returns_string">
+ <cffunction name="testGetKey_returns_certKey">
+ <cfscript>
+ //This test may be brittle depending on the certKey
+ assertTrue(IsInstanceOf(keystore.getKey(),"org.bouncycastle.jce.provider.JCERSAPrivateCrtKey"))
+ </cfscript>
</cffunction>
</cfcomponent>

0 comments on commit 98bac81

Please sign in to comment.
Something went wrong with that request. Please try again.