This is an automated email from the ASF dual-hosted git repository. radcortez pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 8c2ce3a491706307f836c1fdc0977f5d3c602c4b Author: Roberto Cortez <radcor...@yahoo.com> AuthorDate: Thu Jan 17 12:27:50 2019 +0000 TOMEE-2365 - Added API annotations literals. --- .../mechanism/http/AutoApplySession.java | 8 +++ .../mechanism/http/LoginToContinue.java | 80 ++++++++++++++++++++++ .../authentication/mechanism/http/RememberMe.java | 1 + 3 files changed, 89 insertions(+) diff --git a/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java b/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java index 6af744b..534e78f 100644 --- a/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java +++ b/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java @@ -16,6 +16,7 @@ */ package javax.security.enterprise.authentication.mechanism.http; +import javax.enterprise.util.AnnotationLiteral; import javax.interceptor.InterceptorBinding; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; @@ -29,4 +30,11 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; @Retention(RUNTIME) @Target(TYPE) public @interface AutoApplySession { + @SuppressWarnings("all") + public final static class Literal extends AnnotationLiteral<AutoApplySession> implements AutoApplySession { + private static final long serialVersionUID = 1L; + + public static final Literal INSTANCE = new Literal(); + + } } diff --git a/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java b/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java index e38f0d1..37faac9 100644 --- a/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java +++ b/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java @@ -16,6 +16,7 @@ */ package javax.security.enterprise.authentication.mechanism.http; +import javax.enterprise.util.AnnotationLiteral; import javax.enterprise.util.Nonbinding; import javax.interceptor.InterceptorBinding; import java.lang.annotation.Inherited; @@ -41,4 +42,83 @@ public @interface LoginToContinue { @Nonbinding String errorPage() default "/login-error"; + + @SuppressWarnings("all") final class Literal extends AnnotationLiteral<LoginToContinue> implements LoginToContinue { + private static final long serialVersionUID = 1L; + + private final String loginPage; + private final boolean useForwardToLogin; + private final String useForwardToLoginExpression; + private final String errorPage; + + public static LiteralBuilder builder() { + return new LiteralBuilder(); + } + + public static class LiteralBuilder { + private String loginPage = "/login"; + private boolean useForwardToLogin = true; + private String useForwardToLoginExpression; + private String errorPage = "/login-error"; + + public LiteralBuilder loginPage(String loginPage) { + this.loginPage = loginPage; + return this; + } + + public LiteralBuilder useForwardToLogin(boolean useForwardToLogin) { + this.useForwardToLogin = useForwardToLogin; + return this; + } + + public LiteralBuilder useForwardToLoginExpression(String useForwardToLoginExpression) { + this.useForwardToLoginExpression = useForwardToLoginExpression; + return this; + } + + public LiteralBuilder errorPage(String errorPage) { + this.errorPage = errorPage; + return this; + } + + public Literal build() { + return new Literal( + loginPage, + useForwardToLogin, + useForwardToLoginExpression, + errorPage); + } + } + + public Literal(String loginPage, + boolean useForwardToLogin, + String useForwardToLoginExpression, + String errorPage) { + this.loginPage = loginPage; + this.useForwardToLogin = useForwardToLogin; + this.useForwardToLoginExpression = useForwardToLoginExpression; + this.errorPage = errorPage; + } + + @Override + public String loginPage() { + return loginPage; + } + + @Override + public boolean useForwardToLogin() { + return useForwardToLogin; + } + + @Override + public String useForwardToLoginExpression() { + return useForwardToLoginExpression; + } + + @Override + public String errorPage() { + return errorPage; + } + + } } diff --git a/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java b/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java index e8b7e47..065e54f 100644 --- a/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java +++ b/tomee/tomee-security/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java @@ -58,6 +58,7 @@ public @interface RememberMe { @Nonbinding String isRememberMeExpression() default ""; + @SuppressWarnings("all") final class Literal extends AnnotationLiteral<RememberMe> implements RememberMe { private static final long serialVersionUID = 1L;