Skip to content

Commit acaffe9

Browse files
committed
Updated docs, removed Favicon references from demos to clean logs, added URL and Header validation to Access control demo
1 parent eb1788e commit acaffe9

6 files changed

Lines changed: 58 additions & 7 deletions

File tree

‎impl-servlet/src/main/java/org/ocpsoft/rewrite/servlet/impl/ServletContextConfigurationCacheProvider.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* <pre>
3333
* &lt;context-param&gt;
3434
* &lt;param-name&gt;org.ocpsoft.rewrite.config.CONFIG_RELOADING&lt;/param-name&gt;
35-
* &lt;param-value&gt;false&lt;/param-value&gt;
35+
* &lt;param-value&gt;true&lt;/param-value&gt;
3636
* &lt;/context-param&gt;
3737
* </pre>
3838
*

‎showcase/access-control/src/main/java/org/ocpsoft/rewrite/showcase/access/AccessRewriteConfiguration.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.ocpsoft.rewrite.config.jodatime.JodaTime;
1010
import org.ocpsoft.rewrite.config.jodatime.TimeCondition;
1111
import org.ocpsoft.rewrite.servlet.config.DispatchType;
12-
import org.ocpsoft.rewrite.servlet.config.Forward;
1312
import org.ocpsoft.rewrite.servlet.config.Domain;
13+
import org.ocpsoft.rewrite.servlet.config.Forward;
1414
import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
1515
import org.ocpsoft.rewrite.servlet.config.Lifecycle;
1616
import org.ocpsoft.rewrite.servlet.config.Path;
@@ -26,7 +26,6 @@ public class AccessRewriteConfiguration extends HttpConfigurationProvider
2626
public Configuration getConfiguration(final ServletContext context)
2727
{
2828
return ConfigurationBuilder.begin()
29-
3029
/*
3130
* Enable the root menu.
3231
*/
@@ -71,7 +70,7 @@ public boolean matches(final DateTime time)
7170
@Override
7271
public int priority()
7372
{
74-
return 0;
73+
return 10;
7574
}
7675

7776
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.ocpsoft.rewrite.showcase.access;
2+
3+
import javax.servlet.ServletContext;
4+
5+
import org.ocpsoft.rewrite.config.Configuration;
6+
import org.ocpsoft.rewrite.config.ConfigurationBuilder;
7+
import org.ocpsoft.rewrite.config.Direction;
8+
import org.ocpsoft.rewrite.context.EvaluationContext;
9+
import org.ocpsoft.rewrite.event.Rewrite;
10+
import org.ocpsoft.rewrite.param.Constraint;
11+
import org.ocpsoft.rewrite.servlet.config.Header;
12+
import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
13+
import org.ocpsoft.rewrite.servlet.config.SendStatus;
14+
import org.ocpsoft.rewrite.servlet.config.URL;
15+
16+
/**
17+
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
18+
*
19+
*/
20+
public class InputValidationRewriteConfiguration extends HttpConfigurationProvider
21+
{
22+
@Override
23+
public Configuration getConfiguration(final ServletContext context)
24+
{
25+
return ConfigurationBuilder.begin()
26+
27+
.addRule()
28+
.when(Direction.isInbound()
29+
.and(URL.matches("{badthings}")
30+
.or(Header.exists("{badthings}"))
31+
.or(Header.valueExists("{badthings}")
32+
)
33+
)
34+
)
35+
.perform(SendStatus.error(404)) // or take some protective action
36+
.where("badthings").constrainedBy(selectedCharacters);
37+
38+
}
39+
40+
private Constraint<String> selectedCharacters = new Constraint<String>() {
41+
@Override
42+
public boolean isSatisfiedBy(Rewrite event, EvaluationContext context, String value)
43+
{
44+
return value.matches(".*[+%'\"^$#\\\\(\\\\)*<>].*");
45+
// Don't forget unicode!
46+
}
47+
};
48+
49+
@Override
50+
public int priority()
51+
{
52+
return Integer.MIN_VALUE;
53+
}
54+
55+
}

‎showcase/access-control/src/main/webapp/resources/forge-template.xhtml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ and open the template in the editor.
1414
<title>#{empty pageTitle ? '{#pageTitle}' : pageTitle}</title>
1515
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
1616
<meta http-equiv="imagetoolbar" content="no" />
17-
<link rel="icon" href="#{resource['favicon.ico']}" />
1817
<h:outputStylesheet name="forge-style.css" />
1918

2019
<style>

‎showcase/access-control/src/main/webapp/resources/timer-template.xhtml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ and open the template in the editor.
1515
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
1616
<meta http-equiv="imagetoolbar" content="no" />
1717
<meta http-equiv="refresh" content="1" />
18-
<link rel="icon" href="#{resource['favicon.ico']}" />
1918
<h:outputStylesheet name="forge-style.css" />
2019

2120
<style>

‎showcase/composite-query/src/main/webapp/resources/forge-template.xhtml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ and open the template in the editor.
1414
<title>#{empty pageTitle ? '{#pageTitle}' : pageTitle}</title>
1515
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
1616
<meta http-equiv="imagetoolbar" content="no" />
17-
<link rel="icon" href="#{resource['favicon.ico']}" />
1817
<h:outputStylesheet name="forge-style.css" />
1918

2019
<style>

0 commit comments

Comments
 (0)