From f57f50bae5536599b2b7cd855e5226da209ab154 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Tue, 29 Nov 2005 02:33:40 +0000 Subject: [PATCH] Modify Acegifier to use Maven build and 1.0.0+ package names. --- .classpath | 6 +++ samples/acegifier/.cvsignore | 1 + samples/acegifier/project.xml | 26 ++++++++++++ .../java/acegifier/WebXmlConverter.java | 41 +++++++++++-------- .../acegifier/web/AcegifierController.java | 36 ++++++++-------- .../java/acegifier/web/AcegifierForm.java | 0 .../classes => main/resources}/acegi-web.xsl | 4 +- .../resources}/web-to-spring.xsl | 36 ++++++++-------- .../acegifier/WebXmlConverterTests.java | 28 +++++++------ 9 files changed, 112 insertions(+), 66 deletions(-) create mode 100644 samples/acegifier/.cvsignore create mode 100644 samples/acegifier/project.xml rename samples/acegifier/src/{ => main}/java/acegifier/WebXmlConverter.java (88%) rename samples/acegifier/src/{ => main}/java/acegifier/web/AcegifierController.java (97%) rename samples/acegifier/src/{ => main}/java/acegifier/web/AcegifierForm.java (100%) rename samples/acegifier/src/{webapp/WEB-INF/classes => main/resources}/acegi-web.xsl (96%) rename samples/acegifier/src/{webapp/WEB-INF/classes => main/resources}/web-to-spring.xsl (84%) rename samples/acegifier/src/test/{ => java}/acegifier/WebXmlConverterTests.java (86%) diff --git a/.classpath b/.classpath index 2e74519346..db25253b10 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,9 @@ + + + @@ -64,5 +67,8 @@ + + + diff --git a/samples/acegifier/.cvsignore b/samples/acegifier/.cvsignore new file mode 100644 index 0000000000..eb5a316cbd --- /dev/null +++ b/samples/acegifier/.cvsignore @@ -0,0 +1 @@ +target diff --git a/samples/acegifier/project.xml b/samples/acegifier/project.xml new file mode 100644 index 0000000000..d3bd4c7e30 --- /dev/null +++ b/samples/acegifier/project.xml @@ -0,0 +1,26 @@ + + + ${basedir}/../project.xml + 3 + acegi-security-sample-acegifier + Acegi Security System for Spring - Acegifier sample + acegisecurity + /home/groups/a/ac/acegisecurity/htdocs/multiproject/acegi-security-sample-acegifier + + scm:cvs:pserver:anonymous@cvs.sourceforge.net:/cvsroot/acegisecurity:acegisecurity + scm:cvs:ext:${maven.username}@cvs.sourceforge.net:/cvsroot/acegisecurity:acegisecurity + http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/acegisecurity/acegisecurity/samples/acegifier/ + + + + dom4j + dom4j + 1.6 + jar + http://www.dom4j.org + + true + + + + diff --git a/samples/acegifier/src/java/acegifier/WebXmlConverter.java b/samples/acegifier/src/main/java/acegifier/WebXmlConverter.java similarity index 88% rename from samples/acegifier/src/java/acegifier/WebXmlConverter.java rename to samples/acegifier/src/main/java/acegifier/WebXmlConverter.java index 3f815e8f30..e984d925b1 100644 --- a/samples/acegifier/src/java/acegifier/WebXmlConverter.java +++ b/samples/acegifier/src/main/java/acegifier/WebXmlConverter.java @@ -1,21 +1,26 @@ package acegifier; -import org.springframework.core.io.ClassPathResource; -import org.springframework.util.Assert; -import org.dom4j.Document; -import org.dom4j.DocumentHelper; -import org.dom4j.DocumentException; -import org.dom4j.Node; -import org.dom4j.io.SAXReader; -import org.dom4j.io.DocumentSource; -import org.dom4j.io.DocumentResult; - -import javax.xml.transform.*; -import javax.xml.transform.stream.StreamSource; import java.io.IOException; import java.io.InputStream; import java.util.List; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamSource; + +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Node; +import org.dom4j.io.DocumentResult; +import org.dom4j.io.DocumentSource; +import org.dom4j.io.SAXReader; +import org.springframework.core.io.ClassPathResource; +import org.springframework.util.Assert; + /** * A utility to translate a web.xml file into a set of acegi security spring beans. * @@ -47,15 +52,19 @@ public class WebXmlConverter { private Document newWebXml, acegiBeansXml; public WebXmlConverter() throws IOException, TransformerConfigurationException { - TransformerFactory tf = TransformerFactory.newInstance(); - - acegiSecurityTransformer = tf.newTransformer(createTransformerSource(WEB_TO_SPRING_XSL_FILE)); + TransformerFactory tf = TransformerFactory.newInstance(); + Source source = createTransformerSource(WEB_TO_SPRING_XSL_FILE); + System.out.println("1"); + acegiSecurityTransformer = tf.newTransformer(source); + System.out.println("2"); newWebXmlTransformer = tf.newTransformer(createTransformerSource(NEW_WEB_XSLT_FILE)); + System.out.println("3"); } private Source createTransformerSource(String fileName) throws IOException { ClassPathResource resource = new ClassPathResource(fileName); - return new StreamSource(resource.getInputStream()); + Source source = new StreamSource(resource.getInputStream()); + return source; } /** diff --git a/samples/acegifier/src/java/acegifier/web/AcegifierController.java b/samples/acegifier/src/main/java/acegifier/web/AcegifierController.java similarity index 97% rename from samples/acegifier/src/java/acegifier/web/AcegifierController.java rename to samples/acegifier/src/main/java/acegifier/web/AcegifierController.java index 6403dde9b3..2f460d5bcf 100644 --- a/samples/acegifier/src/java/acegifier/web/AcegifierController.java +++ b/samples/acegifier/src/main/java/acegifier/web/AcegifierController.java @@ -1,28 +1,28 @@ package acegifier.web; -import org.springframework.web.servlet.mvc.SimpleFormController; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.validation.BindException; -import org.springframework.validation.Errors; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.BeansException; -import net.sf.acegisecurity.util.InMemoryResource; - -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.io.XMLWriter; -import org.dom4j.io.OutputFormat; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.xml.transform.TransformerException; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; -import net.sf.acegisecurity.util.FilterChainProxy; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.transform.TransformerException; + +import org.acegisecurity.util.FilterChainProxy; +import org.acegisecurity.util.InMemoryResource; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.XMLWriter; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.validation.BindException; +import org.springframework.validation.Errors; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.SimpleFormController; + import acegifier.WebXmlConverter; /** diff --git a/samples/acegifier/src/java/acegifier/web/AcegifierForm.java b/samples/acegifier/src/main/java/acegifier/web/AcegifierForm.java similarity index 100% rename from samples/acegifier/src/java/acegifier/web/AcegifierForm.java rename to samples/acegifier/src/main/java/acegifier/web/AcegifierForm.java diff --git a/samples/acegifier/src/webapp/WEB-INF/classes/acegi-web.xsl b/samples/acegifier/src/main/resources/acegi-web.xsl similarity index 96% rename from samples/acegifier/src/webapp/WEB-INF/classes/acegi-web.xsl rename to samples/acegifier/src/main/resources/acegi-web.xsl index 011c210d83..3690679a8b 100644 --- a/samples/acegifier/src/webapp/WEB-INF/classes/acegi-web.xsl +++ b/samples/acegifier/src/main/resources/acegi-web.xsl @@ -43,10 +43,10 @@ Acegi Filter Chain Proxy - net.sf.acegisecurity.util.FilterToBeanProxy + org.acegisecurity.util.FilterToBeanProxy targetClass - net.sf.acegisecurity.util.FilterChainProxy + org.acegisecurity.util.FilterChainProxy diff --git a/samples/acegifier/src/webapp/WEB-INF/classes/web-to-spring.xsl b/samples/acegifier/src/main/resources/web-to-spring.xsl similarity index 84% rename from samples/acegifier/src/webapp/WEB-INF/classes/web-to-spring.xsl rename to samples/acegifier/src/main/resources/web-to-spring.xsl index 2a041ebc36..e6bfe0c6d2 100644 --- a/samples/acegifier/src/webapp/WEB-INF/classes/web-to-spring.xsl +++ b/samples/acegifier/src/main/resources/web-to-spring.xsl @@ -71,7 +71,7 @@ ======================== AUTHENTICATION ======================= - + @@ -81,13 +81,13 @@ - + - + superuser=password, @@ -97,32 +97,32 @@ - + foobar anonymousUser,ROLE_ANONYMOUS - + foobar - + - + - + springRocks - + springRocks @@ -134,7 +134,7 @@ --> - + @@ -154,13 +154,13 @@ - + - + Your Realm @@ -180,7 +180,7 @@ Make sure that these properties match your setup. In particular, remember to switch your login form action from "j_security_check" to "j_acegi_security_check" - + / @@ -189,7 +189,7 @@ - + false @@ -204,7 +204,7 @@ if you wish to use channel security, add "channelProcessingFilter," in front of "httpSessionContextIntegrationFilter" in the list below - + CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON @@ -219,7 +219,7 @@ - + false @@ -229,7 +229,7 @@ An access decision voter that reads ROLE_* configuration settings - + @@ -240,7 +240,7 @@ original intention but there isn't a direct mapping to the acegi way of doing things. You should modify the permissions as required, removing anonymous access where necessary. - + diff --git a/samples/acegifier/src/test/acegifier/WebXmlConverterTests.java b/samples/acegifier/src/test/java/acegifier/WebXmlConverterTests.java similarity index 86% rename from samples/acegifier/src/test/acegifier/WebXmlConverterTests.java rename to samples/acegifier/src/test/java/acegifier/WebXmlConverterTests.java index 9e1dd27ada..cc27178b6c 100644 --- a/samples/acegifier/src/test/acegifier/WebXmlConverterTests.java +++ b/samples/acegifier/src/test/java/acegifier/WebXmlConverterTests.java @@ -1,23 +1,26 @@ package acegifier; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + import junit.framework.TestCase; -import net.sf.acegisecurity.UserDetails; -import net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor; -import net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter; -import net.sf.acegisecurity.providers.ProviderManager; -import net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider; -import net.sf.acegisecurity.providers.dao.memory.InMemoryDaoImpl; -import net.sf.acegisecurity.util.InMemoryResource; + +import org.acegisecurity.UserDetails; +import org.acegisecurity.intercept.web.FilterSecurityInterceptor; +import org.acegisecurity.intercept.web.SecurityEnforcementFilter; +import org.acegisecurity.providers.ProviderManager; +import org.acegisecurity.providers.dao.DaoAuthenticationProvider; +import org.acegisecurity.providers.dao.memory.InMemoryDaoImpl; +import org.acegisecurity.util.InMemoryResource; +import org.dom4j.Document; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.XMLWriter; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; -import org.dom4j.Document; -import org.dom4j.io.OutputFormat; -import org.dom4j.io.XMLWriter; -import java.io.IOException; -import java.io.ByteArrayOutputStream; +import acegifier.WebXmlConverter; /** * Tests the WebXmlConverter by applying it to a sample web.xml file. @@ -29,6 +32,7 @@ public class WebXmlConverterTests extends TestCase { public void testFileConversion() throws Exception { WebXmlConverter converter = new WebXmlConverter(); + Thread.dumpStack(); Resource r = new ClassPathResource("test-web.xml"); converter.setInput(r.getInputStream());