From 156965b370521cfe841e36f2707575fef4e44677 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Tue, 24 Jul 2007 18:20:22 +0000 Subject: [PATCH] SEC-181: Remove acegifier application. --- samples/acegifier/.cvsignore | 1 - samples/acegifier/pom.xml | 52 --- samples/acegifier/project.xml | 45 --- .../main/java/acegifier/WebXmlConverter.java | 144 --------- .../acegifier/web/AcegifierController.java | 158 --------- .../java/acegifier/web/AcegifierForm.java | 38 --- .../src/main/resources/acegi-web.xsl | 118 ------- .../src/main/resources/web-to-spring.xsl | 302 ------------------ .../main/webapp/WEB-INF/acegifier-servlet.xml | 56 ---- .../webapp/WEB-INF/applicationContext.xml | 7 - .../WEB-INF/freemarker/acegificationForm.ftl | 20 -- .../freemarker/acegificationResults.ftl | 39 --- .../acegifier/src/main/webapp/WEB-INF/web.xml | 51 --- .../java/acegifier/WebXmlConverterTests.java | 102 ------ .../acegifier/src/test/resources/test-web.xml | 108 ------- 15 files changed, 1241 deletions(-) delete mode 100644 samples/acegifier/.cvsignore delete mode 100644 samples/acegifier/pom.xml delete mode 100644 samples/acegifier/project.xml delete mode 100644 samples/acegifier/src/main/java/acegifier/WebXmlConverter.java delete mode 100644 samples/acegifier/src/main/java/acegifier/web/AcegifierController.java delete mode 100644 samples/acegifier/src/main/java/acegifier/web/AcegifierForm.java delete mode 100644 samples/acegifier/src/main/resources/acegi-web.xsl delete mode 100644 samples/acegifier/src/main/resources/web-to-spring.xsl delete mode 100644 samples/acegifier/src/main/webapp/WEB-INF/acegifier-servlet.xml delete mode 100644 samples/acegifier/src/main/webapp/WEB-INF/applicationContext.xml delete mode 100644 samples/acegifier/src/main/webapp/WEB-INF/freemarker/acegificationForm.ftl delete mode 100644 samples/acegifier/src/main/webapp/WEB-INF/freemarker/acegificationResults.ftl delete mode 100644 samples/acegifier/src/main/webapp/WEB-INF/web.xml delete mode 100644 samples/acegifier/src/test/java/acegifier/WebXmlConverterTests.java delete mode 100644 samples/acegifier/src/test/resources/test-web.xml diff --git a/samples/acegifier/.cvsignore b/samples/acegifier/.cvsignore deleted file mode 100644 index eb5a316cbd..0000000000 --- a/samples/acegifier/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -target diff --git a/samples/acegifier/pom.xml b/samples/acegifier/pom.xml deleted file mode 100644 index b106dafd63..0000000000 --- a/samples/acegifier/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - 4.0.0 - org.acegisecurity - acegi-security-samples-acegifier - war - acegi-security-samples-acegifier - - org.acegisecurity - acegi-security-samples - 1.0.5-SNAPSHOT - - - - org.acegisecurity - acegi-security - ${pom.version} - jar - - - org.springframework - spring-webmvc - 2.0.4 - jar - - - javax.servlet - servlet-api - 2.4 - provided - - - dom4j - dom4j - 1.6 - jar - - - jaxen - jaxen - 1.1-beta-8 - jar - - - freemarker - freemarker - 2.3.4 - jar - - - - diff --git a/samples/acegifier/project.xml b/samples/acegifier/project.xml deleted file mode 100644 index 6f37e19c58..0000000000 --- a/samples/acegifier/project.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - ${basedir}/../project.xml - 3 - acegi-security-sample-acegifier - Acegi Security System for Spring - Acegifier sample - /home/groups/a/ac/acegisecurity/htdocs/multiproject/acegi-security-sample-acegifier - - scm:svn:https://acegisecurity.svn.sourceforge.net/svnroot/acegisecurity/trunk/acegisecurity - scm:svn:https://acegisecurity.svn.sourceforge.net/svnroot/acegisecurity/trunk/acegisecurity - http://acegisecurity.svn.sourceforge.net/viewcvs.cgi/acegisecurity/trunk/acegisecurity/samples/acegifier/ - - - - dom4j - dom4j - 1.6 - jar - http://www.dom4j.org - - true - - - - jaxen - jaxen - 1.1-beta-8 - jar - http://www.jaxen.org - - true - - - - freemarker - freemarker - 2.3.4 - jar - http://www.freemarker.org/ - - true - - - - diff --git a/samples/acegifier/src/main/java/acegifier/WebXmlConverter.java b/samples/acegifier/src/main/java/acegifier/WebXmlConverter.java deleted file mode 100644 index b54cb360e5..0000000000 --- a/samples/acegifier/src/main/java/acegifier/WebXmlConverter.java +++ /dev/null @@ -1,144 +0,0 @@ -package acegifier; - -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. - * - *

- * Also produces a new "acegified" web.xml file with the necessary filters installed - * and the security elements defined by the servlet DTD removed. - * - *

- * This class wraps the XSL transform which actually does most of the work. - *

- * - * @author Luke Taylor - * @version $Id$ - */ -public class WebXmlConverter { - private static final String WEB_TO_SPRING_XSL_FILE = "web-to-spring.xsl"; - private static final String NEW_WEB_XSLT_FILE = "acegi-web.xsl"; - - private Transformer acegiSecurityTransformer, newWebXmlTransformer; - - /** - * The name of the spring-beans file which the beans will be stored in. - * This is required when writing the new web.xml content. - */ - private String acegiOutputFileName = "applicationContext-acegi-security.xml"; - - /** The web.xml content to be converted */ - private Source xmlSource; - /** The results of the conversion */ - private Document newWebXml, acegiBeansXml; - - public WebXmlConverter() throws IOException, TransformerConfigurationException { - 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); - Source source = new StreamSource(resource.getInputStream()); - return source; - } - - /** - * Performs the transformations on the input source. - * Creates new web.xml content and a set of acegi-security Spring beans which can be - * accessed through the appropriate getter methods. - */ - public void doConversion() throws IOException, TransformerException { - Assert.notNull(xmlSource, "The XML input must be set"); - - // Create the modified web.xml file - newWebXmlTransformer.setParameter("acegi-security-context-file", acegiOutputFileName); -// newWebXmlTransformer.setParameter("cas-proxy-url", "http://localhost:8433/cas/proxy"); - DocumentResult result = new DocumentResult(); - newWebXmlTransformer.transform(xmlSource, result); - newWebXml = result.getDocument(); - - result = new DocumentResult(); - acegiSecurityTransformer.transform(xmlSource, result); - acegiBeansXml = result.getDocument(); - } - - /** Set the input as an xml string */ - public void setInput(String xml) throws DocumentException { - setInput(DocumentHelper.parseText(xml)); - } - - /** Set the input as a stream */ - public void setInput(InputStream in) throws DocumentException { - SAXReader reader = new SAXReader(); - setInput(reader.read(in)); - } - - /** set the input as a dom4j document */ - public void setInput(Document document) throws DocumentException { - validateWebXml(document); - xmlSource = new DocumentSource(document); - } - - /** Checks the web.xml to make sure it contains correct data */ - private void validateWebXml(Document document) throws DocumentException { - Node authMethodNode = - document.selectSingleNode("/web-app/login-config/auth-method"); - if (authMethodNode == null) - throw new DocumentException("login-config and auth-method must be present"); - String authMethod = authMethodNode.getStringValue().toUpperCase(); - if (!authMethod.equals("BASIC") && !authMethod.equals("FORM")) { - throw new DocumentException("unsupported auth-method: " + authMethod); - } - List roles = document.selectNodes("/web-app/security-role"); - if (roles.isEmpty()) { - throw new DocumentException("Each role used must be defined in a security-role element"); - } - } - - public String getAcegiOutputFileName() { - return acegiOutputFileName; - } - - public void setAcegiOutputFileName(String acegiOutputFileName) { - this.acegiOutputFileName = acegiOutputFileName; - } - - /** Returns the converted web.xml content */ - public Document getNewWebXml() { - return newWebXml; - } - - /** - * Returns the created spring-beans xml content which should be used in - * the application context file. - */ - public Document getAcegiBeans() { - return acegiBeansXml; - } -} diff --git a/samples/acegifier/src/main/java/acegifier/web/AcegifierController.java b/samples/acegifier/src/main/java/acegifier/web/AcegifierController.java deleted file mode 100644 index c5e64accc6..0000000000 --- a/samples/acegifier/src/main/java/acegifier/web/AcegifierController.java +++ /dev/null @@ -1,158 +0,0 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package acegifier.web; - -import acegifier.WebXmlConverter; - -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 java.io.ByteArrayOutputStream; -import java.io.IOException; - -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import javax.xml.transform.TransformerException; - - -/** - * Takes a submitted web.xml, applies the transformer to it and returns the resulting modified web.xml and - * acegi-app-context.xml file contents. - * - * @author Luke Taylor - * @version $Id$ - */ -public class AcegifierController extends SimpleFormController { - //~ Constructors =================================================================================================== - - public AcegifierController() {} - - //~ Methods ======================================================================================================== - - /** - * Creates a BeanFactory from the spring beans XML document - * - * @param beans DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - private DefaultListableBeanFactory createBeanFactory(Document beans) { - DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); - XmlBeanDefinitionReader beanReader = new XmlBeanDefinitionReader(bf); - beanReader.loadBeanDefinitions(new InMemoryResource(beans.asXML().getBytes())); - - return bf; - } - - public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, - BindException errors) throws Exception { - AcegifierForm conversion = (AcegifierForm) command; - WebXmlConverter converter = new WebXmlConverter(); - int nBeans = 0; - Document newWebXml = null; - Document acegiBeans = null; - - try { - converter.setInput(conversion.getWebXml()); - converter.doConversion(); - newWebXml = converter.getNewWebXml(); - acegiBeans = converter.getAcegiBeans(); - nBeans = validateAcegiBeans(conversion, acegiBeans, errors); - } catch (DocumentException de) { - errors.rejectValue("webXml", "webXmlDocError", "There was a problem with your web.xml: " + de.getMessage()); - } catch (TransformerException te) { - errors.rejectValue("webXml", "transFailure", - "There was an error during the XSL transformation: " + te.getMessage()); - } - - if (errors.hasErrors()) { - return showForm(request, response, errors); - } - - Map model = new HashMap(); - model.put("webXml", prettyPrint(newWebXml)); - model.put("acegiBeansXml", prettyPrint(acegiBeans)); - model.put("nBeans", new Integer(nBeans)); - - return new ModelAndView("acegificationResults", model); - } - - /** - * Creates a formatted XML string from the supplied document - * - * @param document DOCUMENT ME! - * - * @return DOCUMENT ME! - * - * @throws IOException DOCUMENT ME! - */ - private String prettyPrint(Document document) throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - OutputFormat format = OutputFormat.createPrettyPrint(); - format.setTrimText(false); - - XMLWriter writer = new XMLWriter(output, format); - writer.write(document); - writer.flush(); - writer.close(); - - return output.toString(); - } - - /** - * Validates the acegi beans, based on the input form data, and returns the number of spring beans defined - * in the document. - * - * @param conversion DOCUMENT ME! - * @param beans DOCUMENT ME! - * @param errors DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - private int validateAcegiBeans(AcegifierForm conversion, Document beans, Errors errors) { - DefaultListableBeanFactory bf = createBeanFactory(beans); - - //TODO: actually do some proper validation! - try { - bf.getBean("filterChainProxy", FilterChainProxy.class); - } catch (BeansException be) { - errors.rejectValue("webXml", "beansInvalid", - "There was an error creating or accessing the bean factory " + be.getMessage()); - } - - return bf.getBeanDefinitionCount(); - } -} diff --git a/samples/acegifier/src/main/java/acegifier/web/AcegifierForm.java b/samples/acegifier/src/main/java/acegifier/web/AcegifierForm.java deleted file mode 100644 index 986360bf94..0000000000 --- a/samples/acegifier/src/main/java/acegifier/web/AcegifierForm.java +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package acegifier.web; - -/** - * Form backing object for the Acegifier controller. - * - * @author Luke Taylor - * @version $Id$ - */ -public class AcegifierForm { - //~ Instance fields ================================================================================================ - - private String webXml; - - //~ Methods ======================================================================================================== - - public String getWebXml() { - return webXml; - } - - public void setWebXml(String webXml) { - this.webXml = webXml; - } -} diff --git a/samples/acegifier/src/main/resources/acegi-web.xsl b/samples/acegifier/src/main/resources/acegi-web.xsl deleted file mode 100644 index 3690679a8b..0000000000 --- a/samples/acegifier/src/main/resources/acegi-web.xsl +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - edu.yale.its.tp.cas.proxyUrl - - - - - - - Acegi Filter Chain Proxy - org.acegisecurity.util.FilterToBeanProxy - - targetClass - org.acegisecurity.util.FilterChainProxy - - - - - - - - Acegi Filter Chain Proxy - /* - - - - - - - - - org.springframework.web.context.ContextLoaderListener - - - - - - - - - - - - - - - - - - contextConfigLocation - - - - - - - - - - - - - - - - - - contextConfigLocation - - - - - - - - - diff --git a/samples/acegifier/src/main/resources/web-to-spring.xsl b/samples/acegifier/src/main/resources/web-to-spring.xsl deleted file mode 100644 index e3ac82b2f3..0000000000 --- a/samples/acegifier/src/main/resources/web-to-spring.xsl +++ /dev/null @@ -1,302 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - ROLE_ - - , - - - - - -/**=httpSessionContextIntegrationFilter - - - ,authenticationProcessingFilter - - - ,basicProcessingFilter - - - Unsupported auth-method in web.xml, must be FORM or BASIC - - -,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor - - - - - - - - messages - - - - - - - - - - - - ======================== AUTHENTICATION ======================= - - - - - - - - - - - - - - - - - - - - - - - superuser=password, - - - - - - - - foobar - anonymousUser,ROLE_ANONYMOUS - - - - - - foobar - - - - - - - - - - - - - - springRocks - - - - - - springRocks - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Your Realm - - - - - - - - - - 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" - - - - - / - /j_acegi_security_check - - - - - - - false - - - - - - - ======================== FILTER CHAIN ======================= - - if you wish to use channel security, add "channelProcessingFilter," in front - of "httpSessionContextIntegrationFilter" in the list below - - - - CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON - PATTERN_TYPE_APACHE_ANT - - - - - - - - - - - - - false - - - - - - - - An access decision voter that reads ROLE_* configuration settings - - - - - Note the order that entries are placed against the objectDefinitionSource is critical. - The FilterSecurityInterceptor will work from the top of the list down to the FIRST pattern that matches the request URL. - Accordingly, you should place MOST SPECIFIC (ie a/b/c/d.*) expressions first, with LEAST SPECIFIC (ie a/.*) expressions last. - We also include ROLE_ANONYMOUS (the anonymous role) for web.xml role-names of "*". This is obviously different from the - 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. - - - - - - - - CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON - PATTERN_TYPE_APACHE_ANT - - /*=ROLE_ANONYMOUS - - - - - - - - - - - - - * - = - - - - ROLE_ANONYMOUS, - - - - ROLE_ - - - - , - - - - diff --git a/samples/acegifier/src/main/webapp/WEB-INF/acegifier-servlet.xml b/samples/acegifier/src/main/webapp/WEB-INF/acegifier-servlet.xml deleted file mode 100644 index 366501f79b..0000000000 --- a/samples/acegifier/src/main/webapp/WEB-INF/acegifier-servlet.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - messages - - - - - - - - - - - - conversionController - - - - - - /WEB-INF/freemarker/ - - - - - - - - - - - true - true - - .ftl - - - \ No newline at end of file diff --git a/samples/acegifier/src/main/webapp/WEB-INF/applicationContext.xml b/samples/acegifier/src/main/webapp/WEB-INF/applicationContext.xml deleted file mode 100644 index 98bf4d0d5f..0000000000 --- a/samples/acegifier/src/main/webapp/WEB-INF/applicationContext.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/samples/acegifier/src/main/webapp/WEB-INF/freemarker/acegificationForm.ftl b/samples/acegifier/src/main/webapp/WEB-INF/freemarker/acegificationForm.ftl deleted file mode 100644 index 205463d778..0000000000 --- a/samples/acegifier/src/main/webapp/WEB-INF/freemarker/acegificationForm.ftl +++ /dev/null @@ -1,20 +0,0 @@ - - - -<#import "spring.ftl" as spring /> - - - - Acegi Security Web.xml Converter - - -
- <@spring.bind "command.webXml" /> - -
- <@spring.showErrors "
"/> - -
- - - \ No newline at end of file diff --git a/samples/acegifier/src/main/webapp/WEB-INF/freemarker/acegificationResults.ftl b/samples/acegifier/src/main/webapp/WEB-INF/freemarker/acegificationResults.ftl deleted file mode 100644 index eb16ab760b..0000000000 --- a/samples/acegifier/src/main/webapp/WEB-INF/freemarker/acegificationResults.ftl +++ /dev/null @@ -1,39 +0,0 @@ - - - - -Acegi Security Web.xml Converter - - - -

Congratulations! Your web.xml file has been "Acegified" successfully.

- -

Web.xml

-

-This is the converted web.xml file which you should use in your Acegi-Secured -Spring application. It should contain the mechanism for loading the Spring application -context file which defines your security configuration as well as the -necessary filters to apply this configuration. -

- -
-${webXml?xml}
-
- -

Acegi Security Beans

-

-This is the file which defines your security configuration (a standard Spring -application context file). It should be named "applicationContext-acegi-security.xml" -and placed in your WEB-INF directory. -

- -
-${acegiBeansXml?xml}
-
- -

Note that these files may require some manual changes before they work as expected and are -intended as a guide only :).

- - - - \ No newline at end of file diff --git a/samples/acegifier/src/main/webapp/WEB-INF/web.xml b/samples/acegifier/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index aa302262e2..0000000000 --- a/samples/acegifier/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - Acegifier Application - - - contextConfigLocation - - /WEB-INF/applicationContext.xml - - - - - - - /convert.htm - - - - org.springframework.web.context.ContextLoaderListener - - - - org.springframework.web.context.ContextLoaderListener - - - - - acegifier - org.springframework.web.servlet.DispatcherServlet - 1 - - - - acegifier - *.htm - - - diff --git a/samples/acegifier/src/test/java/acegifier/WebXmlConverterTests.java b/samples/acegifier/src/test/java/acegifier/WebXmlConverterTests.java deleted file mode 100644 index dd643b4465..0000000000 --- a/samples/acegifier/src/test/java/acegifier/WebXmlConverterTests.java +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package acegifier; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import junit.framework.TestCase; - -import org.dom4j.Document; -import org.dom4j.io.OutputFormat; -import org.dom4j.io.XMLWriter; - -/** - * Tests the WebXmlConverter by applying it to a sample web.xml file. - * - * @author Luke Taylor - * @version $Id$ - */ -public class WebXmlConverterTests extends TestCase { - - private static final String XML_TRANSFORMER = "javax.xml.transform.TransformerFactory"; - - public void testFileConversion() throws Exception { - /* - - THIS TEST HAS BEEN DISABLED AS IT BREAKS THE BUILD (see SEC-181 for details) - - WebXmlConverter converter; - try { - converter = new WebXmlConverter(); - } catch (Exception e) { - // TODO: Something went wrong, set transforer manually and retry... - System.out.println("**** WARNING: NEEDING TO FALLBACK TO A MANUAL SYSTEM PROPERTY ****"); - System.setProperty(XML_TRANSFORMER, "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"); - System.out.println(XML_TRANSFORMER + ": " + System.getProperty(XML_TRANSFORMER)); - converter = new WebXmlConverter(); - } - - Resource r = new ClassPathResource("test-web.xml"); - converter.setInput(r.getInputStream()); - converter.doConversion(); - - DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); - XmlBeanDefinitionReader beanReader = new XmlBeanDefinitionReader(bf); - - beanReader.loadBeanDefinitions( - new InMemoryResource(converter.getAcegiBeans().asXML().getBytes())); - assertNotNull(bf.getBean("filterChainProxy")); - - ProviderManager pm = (ProviderManager) bf.getBean("authenticationManager"); - assertNotNull(pm); - assertEquals(3, pm.getProviders().size()); - - DaoAuthenticationProvider dap = - (DaoAuthenticationProvider) bf.getBean("daoAuthenticationProvider"); - assertNotNull(dap); - - InMemoryDaoImpl dao = (InMemoryDaoImpl) dap.getUserDetailsService(); - UserDetails user = dao.loadUserByUsername("superuser"); - assertEquals("password",user.getPassword()); - assertEquals(2, user.getAuthorities().length); - assertNotNull(bf.getBean("anonymousProcessingFilter")); - assertNotNull(bf.getBean("anonymousAuthenticationProvider")); - assertNotNull(bf.getBean("httpSessionContextIntegrationFilter")); - assertNotNull(bf.getBean("rememberMeProcessingFilter")); - assertNotNull(bf.getBean("rememberMeAuthenticationProvider")); - - ExceptionTranslationFilter etf = - (ExceptionTranslationFilter) bf.getBean("exceptionTranslationFilter"); - assertNotNull(etf); - assertNotNull(etf.getAuthenticationEntryPoint()); - System.out.println(prettyPrint(converter.getNewWebXml())); - System.out.println(prettyPrint(converter.getAcegiBeans())); - */ - } - - private String prettyPrint(Document document) throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - OutputFormat format = OutputFormat.createPrettyPrint(); - format.setNewlines(true); - format.setTrimText(false); - XMLWriter writer = new XMLWriter(output, format); - writer.write(document); - writer.flush(); - writer.close(); - return output.toString(); - } -} diff --git a/samples/acegifier/src/test/resources/test-web.xml b/samples/acegifier/src/test/resources/test-web.xml deleted file mode 100644 index bd133ce6a2..0000000000 --- a/samples/acegifier/src/test/resources/test-web.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - Contacts Sample Application - - - contextConfigLocation - - /WEB-INF/applicationContext-common-business.xml - /WEB-INF/applicationContext-common-authorization.xml - - - - - log4jConfigLocation - /WEB-INF/classes/log4j.properties - - - - contacts - org.springframework.web.servlet.DispatcherServlet - 1 - - - - org.springframework.web.context.ContextLoaderListener - - - - org.springframework.web.util.Log4jConfigListener - - - - org.acegisecurity.ui.session.HttpSessionEventPublisher - - - - remoting - org.springframework.web.servlet.DispatcherServlet - 2 - - - - contacts - *.htm - - - - remoting - /remoting/* - - - - index.jsp - - - - - /index.jsp - - - * - - - - - - /hello.htm - - - * - - - - - - /logoff.jsp - - - * - - - - - form - - /acegilogin.jsp - /acegilogin.jsp?login_error=1 - - - - - - user - - - - dummy - - - \ No newline at end of file