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 @@
-
- * 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 @@ - - - - -Congratulations! Your web.xml file has been "Acegified" successfully.
- --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}
-
-
--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 @@ - - -