|
From: Pelle B. <pe...@us...> - 2004-04-14 23:44:55
|
Update of /cvsroot/neuclear/neuclear-id/src/test-cactus/org/neuclear/id/auth In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3790/src/test-cactus/org/neuclear/id/auth Modified Files: AuthenticationFilterTest.java AuthenticationServletTest.java Log Message: Got the cactus tests working and the sample web app Index: AuthenticationServletTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/test-cactus/org/neuclear/id/auth/AuthenticationServletTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AuthenticationServletTest.java 1 Apr 2004 23:19:51 -0000 1.2 --- AuthenticationServletTest.java 14 Apr 2004 23:44:46 -0000 1.3 *************** *** 6,15 **** import org.neuclear.commons.NeuClearException; import org.neuclear.commons.Utility; import org.neuclear.commons.crypto.Base64; import org.neuclear.commons.crypto.signers.JCESigner; import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.id.SignatureRequest; import org.neuclear.id.SignedNamedObject; - import org.neuclear.id.resolver.Resolver; import org.neuclear.id.verifier.VerifyingReader; import org.neuclear.xml.XMLException; --- 6,18 ---- import org.neuclear.commons.NeuClearException; import org.neuclear.commons.Utility; + import org.neuclear.commons.crypto.Base32; import org.neuclear.commons.crypto.Base64; + import org.neuclear.commons.crypto.CryptoTools; import org.neuclear.commons.crypto.signers.JCESigner; + import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.commons.crypto.signers.TestCaseSigner; + import org.neuclear.id.Identity; import org.neuclear.id.SignatureRequest; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.verifier.VerifyingReader; import org.neuclear.xml.XMLException; *************** *** 41,44 **** --- 44,50 ---- $Id$ $Log$ + Revision 1.3 2004/04/14 23:44:46 pelle + Got the cactus tests working and the sample web app + Revision 1.2 2004/04/01 23:19:51 pelle Split Identity into Signatory and Identity class. *************** *** 99,108 **** assertTrue(obj instanceof SignatureRequest); SignatureRequest sigreq = (SignatureRequest) obj; ! assertEquals(sigreq.getSignatory().getName(), "neu://test"); assertEquals(sigreq.getUnsigned().getElement().getName(), "AuthenticationTicket"); ! assertEquals(sigreq.getUserid(), "neu://bob@test"); ! assertEquals(Resolver.resolveIdentity("neu://bob@test").getSigner(), forms[0].getAction()); } JCESigner signer; --- 105,118 ---- assertTrue(obj instanceof SignatureRequest); SignatureRequest sigreq = (SignatureRequest) obj; ! assertEquals(getPublicKeyName("neu://test"), sigreq.getSignatory().getName()); assertEquals(sigreq.getUnsigned().getElement().getName(), "AuthenticationTicket"); ! assertEquals(Identity.DEFAULT_SIGNER, forms[0].getAction()); } + protected String getPublicKeyName(String alias) throws NonExistingSignerException { + return Base32.encode(CryptoTools.digest(signer.getPublicKey(alias).getEncoded())); + } + + JCESigner signer; Index: AuthenticationFilterTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/test-cactus/org/neuclear/id/auth/AuthenticationFilterTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AuthenticationFilterTest.java 2 Mar 2004 18:59:13 -0000 1.1 --- AuthenticationFilterTest.java 14 Apr 2004 23:44:46 -0000 1.2 *************** *** 4,8 **** --- 4,11 ---- import org.apache.cactus.WebRequest; import org.neuclear.commons.NeuClearException; + import org.neuclear.commons.crypto.Base32; import org.neuclear.commons.crypto.Base64; + import org.neuclear.commons.crypto.CryptoTools; + import org.neuclear.commons.crypto.signers.NonExistingSignerException; import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.id.SignedNamedObject; *************** *** 35,38 **** --- 38,44 ---- $Id$ $Log$ + Revision 1.2 2004/04/14 23:44:46 pelle + Got the cactus tests working and the sample web app + Revision 1.1 2004/03/02 18:59:13 pelle Further cleanups in neuclear-id. Moved everything under id. *************** *** 63,68 **** public void beginValid(WebRequest theRequest) throws GeneralSecurityException, NeuClearException, XMLException { ! AuthenticationTicketBuilder authreq = new AuthenticationTicketBuilder("neu://bob@test", "neu://test", "http://localhost"); ! SignedNamedObject signed = authreq.convert("neu://bob@test",signer); theRequest.setContentType("application/x-www-form-urlencoded"); String b64 = Base64.encode(signed.getEncoded().getBytes()); --- 69,74 ---- public void beginValid(WebRequest theRequest) throws GeneralSecurityException, NeuClearException, XMLException { ! AuthenticationTicketBuilder authreq = new AuthenticationTicketBuilder("http://localhost"); ! SignedNamedObject signed = authreq.convert("neu://bob@test", signer); theRequest.setContentType("application/x-www-form-urlencoded"); String b64 = Base64.encode(signed.getEncoded().getBytes()); *************** *** 81,85 **** ServletResponse theResponse) throws IOException, ServletException { assertNotNull(request.getUserPrincipal()); ! assertEquals("neu://bob@test", request.getUserPrincipal().getName()); } --- 87,96 ---- ServletResponse theResponse) throws IOException, ServletException { assertNotNull(request.getUserPrincipal()); ! try { ! assertEquals(Base32.encode(CryptoTools.digest(signer.getPublicKey("neu://bob@test").getEncoded())), request.getUserPrincipal().getName()); ! } catch (NonExistingSignerException e) { ! e.printStackTrace(); ! assertTrue(false); ! } } *************** *** 96,100 **** public void beginUnsigned(WebRequest theRequest) throws GeneralSecurityException, NeuClearException, XMLException { ! AuthenticationTicketBuilder authreq = new AuthenticationTicketBuilder("neu://bob@test", "neu://test", "http://localhost"); theRequest.setContentType("application/x-www-form-urlencoded"); String b64 = XMLSecTools.encodeElementBase64(authreq); --- 107,111 ---- public void beginUnsigned(WebRequest theRequest) throws GeneralSecurityException, NeuClearException, XMLException { ! AuthenticationTicketBuilder authreq = new AuthenticationTicketBuilder("http://localhost"); theRequest.setContentType("application/x-www-form-urlencoded"); String b64 = XMLSecTools.encodeElementBase64(authreq); |