Skip to content

Commit 35eee47

Browse files
committed
Fixed showcase apps
1 parent ed61482 commit 35eee47

60 files changed

Lines changed: 225 additions & 1755 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎impl-config/src/main/java/org/ocpsoft/rewrite/bind/ParameterizedPattern.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ private String applyTransforms(final Rewrite event, final EvaluationContext cont
364364
}
365365

366366
/**
367-
* Get the {@link org.ocpsoft.rewrite.param.Parameter} with the given name. Return null if no such
368-
* {@link org.ocpsoft.rewrite.param.Parameter} exists.
367+
* Get all {@link RegexCapture} with the given name. Return null if no such
368+
* {@link RegexCapture} exists.
369369
*/
370370
public RegexCapture getParameter(final String name)
371371
{

‎impl-servlet/src/main/java/org/ocpsoft/rewrite/servlet/config/rule/Join.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private void saveCurrentJoin(final HttpServletRequest request)
196196
@Override
197197
public JoinParameter where(final String parameter)
198198
{
199-
return new JoinParameter(this, requestPath.getPathExpression().getParameter(parameter));
199+
return new JoinParameter(this, requestPath.getPathExpression().getParameter(parameter), resourcePath.getPathExpression().getParameter(parameter));
200200
}
201201

202202
@Override

‎pom.xml‎

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<module>integration-gwt</module>
6363
<module>integration-spring</module>
6464
<module>rewrite-servlet</module>
65+
<module>showcase</module>
6566
<module>distribution</module>
6667
</modules>
6768

@@ -154,6 +155,13 @@
154155
<artifactId>rewrite-impl-servlet</artifactId>
155156
<version>${project.version}</version>
156157
</dependency>
158+
<dependency>
159+
<groupId>org.ocpsoft.rewrite</groupId>
160+
<artifactId>rewrite-impl-servlet</artifactId>
161+
<version>${project.version}</version>
162+
<scope>provided</scope>
163+
<classifier>sources</classifier>
164+
</dependency>
157165
<dependency>
158166
<groupId>org.ocpsoft.rewrite</groupId>
159167
<artifactId>rewrite-servlet</artifactId>
@@ -190,7 +198,7 @@
190198
<version>${version.junit}</version>
191199
<scope>test</scope>
192200
</dependency>
193-
201+
194202

195203
<!-- We are overriding version of ShrinkWrap Maven Resolver from
196204
Arquillian BOM -->
@@ -355,7 +363,9 @@
355363
<phase>process-test-classes</phase>
356364
<configuration>
357365
<target>
358-
<copy file="${user.dir}/test-harness/src/main/resources/jbossas-managed-standalone.xml" todir="${project.build.directory}/container/jboss-as-${version.jbossas}/standalone/configuration"/>
366+
<copy
367+
file="${user.dir}/test-harness/src/main/resources/jbossas-managed-standalone.xml"
368+
todir="${project.build.directory}/container/jboss-as-${version.jbossas}/standalone/configuration" />
359369
</target>
360370
</configuration>
361371
<goals>
@@ -427,9 +437,12 @@
427437
<configuration>
428438
<target>
429439
<mkdir dir="${container.download.dir}" />
430-
<get dest="${container.download.dir}" verbose="true" skipexisting="true"
440+
<get dest="${container.download.dir}"
441+
verbose="true" skipexisting="true"
431442
src="http://download.java.net/glassfish/${version.glassfish}/release/glassfish-${version.glassfish}-web.zip" />
432-
<unzip src="${container.download.dir}/glassfish-${version.glassfish}-web.zip" dest="${project.build.directory}/container" />
443+
<unzip
444+
src="${container.download.dir}/glassfish-${version.glassfish}-web.zip"
445+
dest="${project.build.directory}/container" />
433446
</target>
434447
</configuration>
435448
</execution>
@@ -489,12 +502,17 @@
489502
<configuration>
490503
<target>
491504
<mkdir dir="${container.download.dir}" />
492-
<get dest="${container.download.dir}" verbose="true" skipexisting="true"
505+
<get dest="${container.download.dir}"
506+
verbose="true" skipexisting="true"
493507
src="http://archive.apache.org/dist/tomcat/tomcat-7/v${version.tomcat}/bin/apache-tomcat-${version.tomcat}.zip" />
494-
<unzip src="${container.download.dir}/apache-tomcat-${version.tomcat}.zip" dest="${project.build.directory}/container" />
495-
<move file="${project.build.directory}/container/apache-tomcat-${version.tomcat}"
496-
tofile="${project.build.directory}/container/apache-tomcat-7"/>
497-
<echo file="${project.build.directory}/container/apache-tomcat-7/conf/tomcat-users.xml">
508+
<unzip
509+
src="${container.download.dir}/apache-tomcat-${version.tomcat}.zip"
510+
dest="${project.build.directory}/container" />
511+
<move
512+
file="${project.build.directory}/container/apache-tomcat-${version.tomcat}"
513+
tofile="${project.build.directory}/container/apache-tomcat-7" />
514+
<echo
515+
file="${project.build.directory}/container/apache-tomcat-7/conf/tomcat-users.xml">
498516
<![CDATA[
499517
<?xml version="1.0" encoding="UTF-8"?>
500518
<tomcat-users>
@@ -529,7 +547,8 @@
529547
</dependency>
530548
</dependencies>
531549
<repositories>
532-
<!-- We current need this because we have to use the SNAPSHOTS for the Tomcat container adapter -->
550+
<!-- We current need this because we have to use the SNAPSHOTS
551+
for the Tomcat container adapter -->
533552
<repository>
534553
<id>arquillian-snapshots</id>
535554
<url>https://repository-arquillian.forge.cloudbees.com/snapshot/</url>
@@ -541,7 +560,7 @@
541560
</snapshots>
542561
</repository>
543562
</repositories>
544-
</profile>
563+
</profile>
545564

546565
<profile>
547566
<id>TOMCAT_MANAGED_7_OWB</id>
@@ -567,7 +586,7 @@
567586
<scope>test</scope>
568587
</dependency>
569588
</dependencies>
570-
</profile>
589+
</profile>
571590

572591
</profiles>
573592

‎rewrite-servlet/pom.xml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<dependency>
2121
<groupId>org.ocpsoft.rewrite</groupId>
2222
<artifactId>rewrite-impl-servlet</artifactId>
23-
<version>${project.version}</version>
2423
<scope>provided</scope>
2524
<classifier>sources</classifier>
2625
</dependency>

‎showcase/access-control/pom.xml‎

Lines changed: 45 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,47 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4-
<modelVersion>4.0.0</modelVersion>
5-
<parent>
6-
<artifactId>rewrite-showcase</artifactId>
7-
<groupId>org.ocpsoft.rewrite.showcase</groupId>
8-
<version>1.0.6-SNAPSHOT</version>
9-
<relativePath>../</relativePath>
10-
</parent>
11-
<artifactId>rewrite-showcase-access-control</artifactId>
12-
<packaging>war</packaging>
13-
<dependencies>
14-
<dependency>
15-
<groupId>org.jboss.spec</groupId>
16-
<artifactId>jboss-javaee-6.0</artifactId>
17-
<version>2.0.0.Final</version>
18-
<type>pom</type>
19-
<scope>provided</scope>
20-
</dependency>
21-
<dependency>
22-
<groupId>org.ocpsoft.rewrite</groupId>
23-
<artifactId>rewrite-impl-servlet</artifactId>
24-
<scope>compile</scope>
25-
</dependency>
26-
<dependency>
27-
<groupId>org.ocpsoft.rewrite</groupId>
28-
<artifactId>rewrite-config-jodatime</artifactId>
29-
<scope>compile</scope>
30-
</dependency>
31-
<dependency>
32-
<groupId>org.ocpsoft.rewrite</groupId>
33-
<artifactId>rewrite-integration-cdi</artifactId>
34-
<scope>compile</scope>
35-
</dependency>
36-
<dependency>
37-
<groupId>org.ocpsoft.prettytime</groupId>
38-
<artifactId>prettytime</artifactId>
39-
<version>1.0.8.Final</version>
40-
<scope>compile</scope>
41-
</dependency>
42-
</dependencies>
43-
<repositories>
44-
<repository>
45-
<id>ocpsoft</id>
46-
<url>http://ocpsoft.org/repository/</url>
47-
</repository>
48-
</repositories>
49-
<build>
50-
<finalName>access-control</finalName>
51-
<plugins>
52-
<plugin>
53-
<artifactId>maven-compiler-plugin</artifactId>
54-
<version>2.3.2</version>
55-
<configuration>
56-
<source>1.6</source>
57-
<target>1.6</target>
58-
</configuration>
59-
</plugin>
60-
<plugin>
61-
<artifactId>maven-war-plugin</artifactId>
62-
<version>2.1-beta-1</version>
63-
<configuration>
64-
<archive>
65-
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
66-
</archive>
67-
<packagingExcludes>WEB-INF/classes/META-INF/MANIFEST.MF</packagingExcludes>
68-
</configuration>
69-
</plugin>
70-
</plugins>
71-
</build>
72-
<profiles>
73-
<profile>
74-
<id>openshift</id>
75-
<build>
76-
<plugins>
77-
<plugin>
78-
<artifactId>maven-war-plugin</artifactId>
79-
<version>2.1.1</version>
80-
<configuration>
81-
<outputDirectory>deployments</outputDirectory>
82-
<warName>ROOT</warName>
83-
</configuration>
84-
</plugin>
85-
</plugins>
86-
</build>
87-
</profile>
88-
</profiles>
2+
<project
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
4+
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<artifactId>rewrite-showcase</artifactId>
9+
<groupId>org.ocpsoft.rewrite.showcase</groupId>
10+
<version>1.0.6-SNAPSHOT</version>
11+
<relativePath>../</relativePath>
12+
</parent>
13+
14+
<artifactId>rewrite-showcase-access-control</artifactId>
15+
<packaging>war</packaging>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.jboss.spec</groupId>
20+
<artifactId>jboss-javaee-6.0</artifactId>
21+
<type>pom</type>
22+
<scope>provided</scope>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>org.ocpsoft.rewrite</groupId>
27+
<artifactId>rewrite-impl-servlet</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.ocpsoft.rewrite</groupId>
31+
<artifactId>rewrite-config-jodatime</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.ocpsoft.rewrite</groupId>
35+
<artifactId>rewrite-integration-cdi</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.ocpsoft.prettytime</groupId>
39+
<artifactId>prettytime</artifactId>
40+
<scope>compile</scope>
41+
</dependency>
42+
</dependencies>
43+
44+
<build>
45+
<finalName>access-control</finalName>
46+
</build>
8947
</project>

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

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
package org.ocpsoft.rewrite.showcase.access;
22

3-
import javax.inject.Inject;
43
import javax.servlet.ServletContext;
54

65
import org.joda.time.DateTime;
76
import org.ocpsoft.rewrite.config.Configuration;
87
import org.ocpsoft.rewrite.config.ConfigurationBuilder;
8+
import org.ocpsoft.rewrite.config.Direction;
99
import org.ocpsoft.rewrite.config.jodatime.JodaTime;
1010
import org.ocpsoft.rewrite.config.jodatime.TimeCondition;
11+
import org.ocpsoft.rewrite.context.EvaluationContext;
1112
import org.ocpsoft.rewrite.servlet.config.DispatchType;
1213
import org.ocpsoft.rewrite.servlet.config.Domain;
1314
import org.ocpsoft.rewrite.servlet.config.Forward;
15+
import org.ocpsoft.rewrite.servlet.config.HttpCondition;
1416
import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
17+
import org.ocpsoft.rewrite.servlet.config.Lifecycle;
1518
import org.ocpsoft.rewrite.servlet.config.Path;
1619
import org.ocpsoft.rewrite.servlet.config.rule.Join;
20+
import org.ocpsoft.rewrite.servlet.http.event.HttpServletRewrite;
1721

1822
/**
1923
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
2024
*
2125
*/
2226
public class AccessRewriteConfiguration extends HttpConfigurationProvider
2327
{
24-
@Inject
25-
private TimerBean timerBean;
26-
2728
@Override
2829
public Configuration getConfiguration(final ServletContext context)
2930
{
@@ -35,28 +36,54 @@ public Configuration getConfiguration(final ServletContext context)
3536
*/
3637
.addRule(Join.path("/").to("/index.xhtml").withInboundCorrection())
3738

38-
/*
39-
* Time based access control (only grants access during the first half of each minute)
40-
*/
41-
.addRule(Join.path("/{global}").to("/{global}.xhtml")
42-
.when(JodaTime.matches(timeGranted).and(DispatchType.isRequest()))
43-
.withInboundCorrection())
44-
4539
/*
4640
* Domain based access control (only grants access to specific domains)
4741
*/
48-
.addRule(Join.path("/domain").to("/domain.xhtml")
49-
.when(Domain.matches(".*rhcloud.*").or(Domain.matches("localhost"))))
42+
.addRule(Join.path("/domain").to("/domain.xhtml").withInboundCorrection().when(new HttpCondition() {
43+
@Override
44+
public boolean evaluateHttp(HttpServletRewrite event, EvaluationContext context)
45+
{
46+
if (Direction
47+
.isInbound()
48+
.andNot(Domain.matches("localhost").or(
49+
Domain.matches("{1}rhcloud{2}").where("1").matches(".*").where("2")
50+
.matches(".*")))
51+
.evaluate(event, context))
52+
return false;
53+
return true;
54+
}
55+
}))
5056

5157
/*
52-
* Deny access to anything except the index unless we matched one of the rules above.
58+
* Time based access control (only grants access during the first half of each minute)
5359
*/
60+
.addRule(Join.path("/timer").to("/timer.xhtml")
61+
.withInboundCorrection().when(new HttpCondition() {
62+
@Override
63+
public boolean evaluateHttp(HttpServletRewrite event, EvaluationContext context)
64+
{
65+
if (Direction.isInbound().andNot(JodaTime.matches(timeGranted)).evaluate(event, context))
66+
return false;
67+
return true;
68+
}
69+
}))
70+
5471
.defineRule()
55-
.when(Path.matches(".*").and(DispatchType.isRequest())
56-
.andNot(Path.matches(".*javax.faces.resource.*"))
57-
.andNot(Path.matches("/")))
72+
.when(Direction.isInbound()
73+
.and(DispatchType.isForward())
74+
.and(Path.matches("/timer.xhtml"))
75+
.andNot(JodaTime.matches(timeGranted))
76+
.and(DispatchType.isRequest()))
77+
.perform(Lifecycle.handled())
5878

79+
.defineRule()
80+
.when(Direction
81+
.isInbound()
82+
.and(DispatchType.isRequest())
83+
.andNot(Path.matches("{1}javax.faces.resource{2}").where("1").matches(".*").where("2")
84+
.matches(".*")))
5985
.perform(Forward.to("/accessDenied.xhtml"));
86+
6087
}
6188

6289
private final TimeCondition timeGranted = new TimeCondition() {

0 commit comments

Comments
 (0)