This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch http-interceptor in repository https://gitbox.apache.org/repos/asf/struts.git
commit b3ff475e1cf5ef07edeb6322d300c74b32b0a15f Author: Lukasz Lenart <[email protected]> AuthorDate: Sat Apr 19 17:49:50 2014 +0200 Defines annotations to control access based on http method Defines main annotation AllowedMethod and helper annotations used in most common situation, eg. GetOnly, PostOnly, etc. --- .../struts2/interceptor/httpmethod/AllowedMethod.java | 14 ++++++++++++++ .../org/apache/struts2/interceptor/httpmethod/GetOnly.java | 14 ++++++++++++++ .../apache/struts2/interceptor/httpmethod/GetPostOnly.java | 14 ++++++++++++++ .../apache/struts2/interceptor/httpmethod/PostOnly.java | 14 ++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java new file mode 100644 index 000000000..05d3795f9 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/AllowedMethod.java @@ -0,0 +1,14 @@ +package org.apache.struts2.interceptor.httpmethod; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface AllowedMethod { + + HttpMethod[] value() default {}; + +} diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetOnly.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetOnly.java new file mode 100644 index 000000000..2c782bd5c --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetOnly.java @@ -0,0 +1,14 @@ +package org.apache.struts2.interceptor.httpmethod; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface GetOnly { + + HttpMethod[] value() default { HttpMethod.GET }; + +} diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetPostOnly.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetPostOnly.java new file mode 100644 index 000000000..9f8df0230 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/GetPostOnly.java @@ -0,0 +1,14 @@ +package org.apache.struts2.interceptor.httpmethod; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface GetPostOnly { + + HttpMethod[] value() default { HttpMethod.GET, HttpMethod.POST }; + +} diff --git a/core/src/main/java/org/apache/struts2/interceptor/httpmethod/PostOnly.java b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/PostOnly.java new file mode 100644 index 000000000..1163188f1 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/interceptor/httpmethod/PostOnly.java @@ -0,0 +1,14 @@ +package org.apache.struts2.interceptor.httpmethod; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface PostOnly { + + HttpMethod[] value() default { HttpMethod.POST }; + +}
