diff --git a/api/src/main/java/javax/security/enterprise/CallerPrincipal.java b/api/src/main/java/javax/security/enterprise/CallerPrincipal.java index 57936ff..71d71ee 100644 --- a/api/src/main/java/javax/security/enterprise/CallerPrincipal.java +++ b/api/src/main/java/javax/security/enterprise/CallerPrincipal.java @@ -23,7 +23,7 @@ * Principal that represents the caller principal associated with the invocation being * processed by the container (e.g. the current HTTP request). */ -public class CallerPrincipal implements Principal, Serializable { +public class CallerPrincipal implements Principal { private static final long serialVersionUID = -6951555039431667786L; diff --git a/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java b/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java index 880ae39..545e5e1 100644 --- a/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java +++ b/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/AutoApplySession.java @@ -23,7 +23,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.util.AnnotationLiteral; import javax.interceptor.InterceptorBinding; /** @@ -57,18 +56,5 @@ @Retention(RUNTIME) @Target(TYPE) public @interface AutoApplySession { - - /** - * A default literal for the {@link AutoApplySession} annotation. - * - * @since 1.1 - */ - @SuppressWarnings("all") - public final static class Literal extends AnnotationLiteral implements AutoApplySession { - - private static final long serialVersionUID = 1L; - - public static final Literal INSTANCE = new Literal(); - - } + } diff --git a/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java b/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java deleted file mode 100644 index 1de72a0..0000000 --- a/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2018 Payara Services Limited. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ -package javax.security.enterprise.authentication.mechanism.http; - -import javax.security.enterprise.AuthenticationException; -import javax.security.enterprise.AuthenticationStatus; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * This class is an implementation of the HttpAuthenticationMechanism interface that can be - * subclassed by developers wishing to provide extra or different functionality. - *

- * All methods default to calling the wrapped object. - * - */ -public class HttpAuthenticationMechanismWrapper implements HttpAuthenticationMechanism { - - private final HttpAuthenticationMechanism httpAuthenticationMechanism; - - public HttpAuthenticationMechanismWrapper(HttpAuthenticationMechanism httpAuthenticationMechanism) { - this.httpAuthenticationMechanism = httpAuthenticationMechanism; - } - - public HttpAuthenticationMechanism getWrapped() { - return httpAuthenticationMechanism; - } - - @Override - public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, - HttpMessageContext httpMessageContext) throws AuthenticationException { - return getWrapped().validateRequest(request, response, httpMessageContext); - } - - @Override - public AuthenticationStatus secureResponse(HttpServletRequest request, HttpServletResponse response, - HttpMessageContext httpMessageContext) throws AuthenticationException { - return getWrapped().secureResponse(request, response, httpMessageContext); - } - - @Override - public void cleanSubject(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMessageContext) { - getWrapped().cleanSubject(request, response, httpMessageContext); - } - -} \ No newline at end of file diff --git a/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java b/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java index 1223d4c..5e5c3b4 100644 --- a/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java +++ b/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/LoginToContinue.java @@ -24,7 +24,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.util.AnnotationLiteral; import javax.enterprise.util.Nonbinding; import javax.interceptor.InterceptorBinding; @@ -53,91 +52,6 @@ @Target(TYPE) public @interface LoginToContinue { - /** - * A default literal type for the {@link LoginToContinue} annotation. - * - * @since 1.1 - */ - @SuppressWarnings("all") - public final static class Literal extends AnnotationLiteral 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; - } - - } - /** * The resource (page) a caller should get to see in case the originally requested * resource requires authentication, and the caller is currently not authenticated. diff --git a/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java b/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java index 95eec55..3785e25 100644 --- a/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java +++ b/api/src/main/java/javax/security/enterprise/authentication/mechanism/http/RememberMe.java @@ -25,7 +25,6 @@ import java.lang.annotation.Target; import javax.el.ELProcessor; -import javax.enterprise.util.AnnotationLiteral; import javax.enterprise.util.Nonbinding; import javax.interceptor.InterceptorBinding; import javax.security.enterprise.identitystore.IdentityStore; @@ -83,173 +82,6 @@ @Target(TYPE) public @interface RememberMe { - /** - * A default literal type for the {@link RememberMe} annotation. - * - * @since 1.1 - */ - @SuppressWarnings("all") - public final static class Literal extends AnnotationLiteral implements RememberMe { - - private static final long serialVersionUID = 1L; - - private final int cookieMaxAgeSeconds; - private final String cookieMaxAgeSecondsExpression; - private final boolean cookieSecureOnly; - private final String cookieSecureOnlyExpression; - private final boolean cookieHttpOnly; - private final String cookieHttpOnlyExpression; - private final String cookieName; - private final boolean isRememberMe; - private final String isRememberMeExpression; - - public static LiteralBuilder builder() { - return new LiteralBuilder(); - } - - public static class LiteralBuilder { - - private int cookieMaxAgeSeconds = 86400; // 1 day - private String cookieMaxAgeSecondsExpression; - private boolean cookieSecureOnly = true; - private String cookieSecureOnlyExpression; - private boolean cookieHttpOnly = true; - private String cookieHttpOnlyExpression; - private String cookieName = "JREMEMBERMEID"; - private boolean isRememberMe = true; - private String isRememberMeExpression; - - public LiteralBuilder cookieMaxAgeSeconds(int cookieMaxAgeSeconds) { - this.cookieMaxAgeSeconds = cookieMaxAgeSeconds; - return this; - } - - public LiteralBuilder cookieMaxAgeSecondsExpression (String cookieMaxAgeSecondsExpression) { - this.cookieMaxAgeSecondsExpression = cookieMaxAgeSecondsExpression; - return this; - } - - public LiteralBuilder cookieSecureOnly (boolean cookieSecureOnly) { - this.cookieSecureOnly = cookieSecureOnly; - return this; - - } - - public LiteralBuilder cookieSecureOnlyExpression (String cookieSecureOnlyExpression) { - this.cookieHttpOnlyExpression = cookieSecureOnlyExpression; - return this; - } - - public LiteralBuilder cookieHttpOnly (boolean cookieHttpOnly) { - this.cookieHttpOnly = cookieHttpOnly; - return this; - } - - public LiteralBuilder cookieHttpOnlyExpression (String cookieHttpOnlyExpression) { - this.cookieHttpOnlyExpression = cookieHttpOnlyExpression; - return this; - } - - public LiteralBuilder cookieName (String cookieName) { - this.cookieName = cookieName; - return this; - } - - public LiteralBuilder isRememberMe (boolean isRememberMe) { - this.isRememberMe = isRememberMe; - return this; - } - - public LiteralBuilder isRememberMeExpression (String isRememberMeExpression) { - this.isRememberMeExpression = isRememberMeExpression; - return this; - } - - public Literal build() { - return new Literal( - cookieMaxAgeSeconds, - cookieMaxAgeSecondsExpression, - cookieSecureOnly, - cookieSecureOnlyExpression, - cookieHttpOnly, - cookieHttpOnlyExpression, - cookieName, - isRememberMe, - isRememberMeExpression); - } - } - - public Literal( - - int cookieMaxAgeSeconds, - String cookieMaxAgeSecondsExpression, - boolean cookieSecureOnly, - String cookieSecureOnlyExpression, - boolean cookieHttpOnly, - String cookieHttpOnlyExpression, - String cookieName, - boolean isRememberMe, - String isRememberMeExpression - - ) { - - this.cookieMaxAgeSeconds = cookieMaxAgeSeconds; - this.cookieMaxAgeSecondsExpression = cookieMaxAgeSecondsExpression; - this.cookieSecureOnly = cookieSecureOnly; - this.cookieSecureOnlyExpression = cookieSecureOnlyExpression; - this.cookieHttpOnly = cookieHttpOnly; - this.cookieHttpOnlyExpression = cookieHttpOnlyExpression; - this.cookieName = cookieName; - this.isRememberMe = isRememberMe; - this.isRememberMeExpression = isRememberMeExpression; - } - - @Override - public boolean cookieHttpOnly() { - return cookieHttpOnly; - } - - @Override - public String cookieHttpOnlyExpression() { - return cookieHttpOnlyExpression; - } - - @Override - public int cookieMaxAgeSeconds() { - return cookieMaxAgeSeconds; - } - - @Override - public String cookieMaxAgeSecondsExpression() { - return cookieMaxAgeSecondsExpression; - } - - @Override - public boolean cookieSecureOnly() { - return cookieSecureOnly; - } - - @Override - public String cookieSecureOnlyExpression() { - return cookieSecureOnlyExpression; - } - - @Override - public String cookieName() { - return cookieName; - } - - @Override - public boolean isRememberMe() { - return isRememberMe; - } - - @Override - public String isRememberMeExpression() { - return isRememberMeExpression; - } - } - /** * Max age in seconds for the remember me cookie. * Defaults to one day. diff --git a/api/src/main/java/javax/security/enterprise/identitystore/IdentityStoreWrapper.java b/api/src/main/java/javax/security/enterprise/identitystore/IdentityStoreWrapper.java deleted file mode 100644 index 3880f76..0000000 --- a/api/src/main/java/javax/security/enterprise/identitystore/IdentityStoreWrapper.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2018 Payara Services Limited. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ -package javax.security.enterprise.identitystore; - -import java.util.Set; - -import javax.security.enterprise.credential.Credential; - -/** - * This class is an implementation of the IdentityStore interface that can be - * subclassed by developers wishing to provide extra or different functionality. - *

- * All methods default to calling the wrapped object. - * - */ -public class IdentityStoreWrapper implements IdentityStore { - - private final IdentityStore identityStore; - - public IdentityStoreWrapper(IdentityStore identityStore) { - this.identityStore = identityStore; - } - - public IdentityStore getWrapped() { - return identityStore; - } - - @Override - public CredentialValidationResult validate(Credential credential) { - return getWrapped().validate(credential); - } - - @Override - public Set getCallerGroups(CredentialValidationResult validationResult) { - return getWrapped().getCallerGroups(validationResult); - } - - @Override - public int priority() { - return getWrapped().priority(); - } - - @Override - public Set validationTypes() { - return getWrapped().validationTypes(); - } - -} \ No newline at end of file diff --git a/api/src/test/java/org/glassfish/security/AnnotationLiteralTest.java b/api/src/test/java/org/glassfish/security/AnnotationLiteralTest.java deleted file mode 100644 index 738673f..0000000 --- a/api/src/test/java/org/glassfish/security/AnnotationLiteralTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2018 Payara Services and/or its affiliates and others. - * All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ -package org.glassfish.security; - -import static org.junit.Assert.assertEquals; - -import javax.enterprise.util.AnnotationLiteral; -import javax.security.enterprise.authentication.mechanism.http.AutoApplySession; -import javax.security.enterprise.authentication.mechanism.http.LoginToContinue; -import javax.security.enterprise.authentication.mechanism.http.RememberMe; - -import org.junit.Test; - -public class AnnotationLiteralTest { - - - @Test - public void testAutoApplySession() { - AutoApplySession literal = AutoApplySession.Literal.INSTANCE; - - assertEquals(new AnnotationLiteral() { - private static final long serialVersionUID = 1L; - }, literal); - - } - - @Test - public void testRememberMeDefault() { - RememberMe literal = RememberMe.Literal.builder().build(); - - assertEquals(86400, literal.cookieMaxAgeSeconds()); - assertEquals("JREMEMBERMEID", literal.cookieName()); - } - - @Test - public void testRememberMe() { - RememberMe literal = RememberMe.Literal.builder() - .cookieMaxAgeSeconds(100) - .cookieSecureOnly(false) - .cookieHttpOnly(false) - .build(); - - assertEquals(100, literal.cookieMaxAgeSeconds()); - assertEquals(false, literal.cookieSecureOnly()); - assertEquals(false, literal.cookieHttpOnly()); - assertEquals("JREMEMBERMEID", literal.cookieName()); - } - - @Test - public void testLoginToContinueDefault() { - LoginToContinue literal = LoginToContinue.Literal.builder().build(); - - assertEquals("/login", literal.loginPage()); - assertEquals("/login-error", literal.errorPage()); - } - - @Test - public void testLoginToContinue() { - LoginToContinue literal = LoginToContinue.Literal.builder() - .loginPage("/mylogin") - .useForwardToLogin(false) - .useForwardToLoginExpression("#{bar.foo}") - .build(); - - assertEquals("/mylogin", literal.loginPage()); - assertEquals(false, literal.useForwardToLogin()); - assertEquals("#{bar.foo}", literal.useForwardToLoginExpression()); - assertEquals("/login-error", literal.errorPage()); - } - - - - -}