Skip to content

Package: CustomFormAuthenticationMechanismDefinition$List

CustomFormAuthenticationMechanismDefinition$List

Coverage

1: /*
2: * Copyright (c) 2024 Contributors to Eclipse Foundation.
3: * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved.
4: *
5: * This program and the accompanying materials are made available under the
6: * terms of the Eclipse Public License v. 2.0, which is available at
7: * http://www.eclipse.org/legal/epl-2.0.
8: *
9: * This Source Code may also be made available under the following Secondary
10: * Licenses when the conditions for such availability set forth in the
11: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
12: * version 2 with the GNU Classpath Exception, which is available at
13: * https://www.gnu.org/software/classpath/license.html.
14: *
15: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16: */
17:
18: package jakarta.security.enterprise.authentication.mechanism.http;
19:
20: import static java.lang.annotation.ElementType.FIELD;
21: import static java.lang.annotation.ElementType.METHOD;
22: import static java.lang.annotation.ElementType.PARAMETER;
23: import static java.lang.annotation.ElementType.TYPE;
24: import static java.lang.annotation.RetentionPolicy.RUNTIME;
25:
26: import jakarta.enterprise.util.AnnotationLiteral;
27: import jakarta.enterprise.util.Nonbinding;
28: import jakarta.inject.Qualifier;
29: import jakarta.security.enterprise.SecurityContext;
30: import java.lang.annotation.Repeatable;
31: import java.lang.annotation.Retention;
32: import java.lang.annotation.Target;
33:
34: /**
35: * Annotation used to define a container authentication mechanism that implements
36: * authentication resembling Servlet FORM authentication (Servlet spec 13.6.3).
37: * <p>
38: * Instead of posting back to a predefined action to continue the authentication dialog
39: * (Servlet spec 13.6.3 step 3), this variant depends on the application calling
40: * {@link SecurityContext#authenticate(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, jakarta.security.enterprise.authentication.mechanism.http.AuthenticationParameters)}
41: *
42: */
43: @Retention(RUNTIME)
44: @Target(TYPE)
45: @Repeatable(CustomFormAuthenticationMechanismDefinition.List.class)
46: public @interface CustomFormAuthenticationMechanismDefinition {
47:
48: @Nonbinding
49: LoginToContinue loginToContinue();
50:
51: /**
52: * List of {@link Qualifier qualifier annotations}.
53: *
54: * <p>
55: * An {@link HttpAuthenticationMechanism} injection point
56: * with these qualifier annotations injects a bean that is
57: * produced by this {@code CustomFormAuthenticationMechanismDefinition}.</p>
58: *
59: * <p>
60: * The default value is {@code CustomFormAuthenticationMechanism}, indicating that
61: * this {@code CustomFormAuthenticationMechanismDefinition} produces
62: * bean instances of type {@link HttpAuthenticationMechanism} qualified by
63: * {@code CustomFormAuthenticationMechanism}.
64: *
65: * @return list of qualifiers.
66: * @since 4.0
67: */
68: Class<?>[] qualifiers() default { CustomFormAuthenticationMechanism.class };
69:
70: /**
71: * Enables multiple <code>CustomFormAuthenticationMechanismDefinition</code>
72: * annotations on the same type.
73: */
74: @Retention(RUNTIME)
75: @Target(TYPE)
76: public @interface List {
77: CustomFormAuthenticationMechanismDefinition[] value();
78: }
79:
80: @Qualifier
81: @Retention(RUNTIME)
82: @Target({FIELD, METHOD, TYPE, PARAMETER})
83: public static @interface CustomFormAuthenticationMechanism {
84:
85: /**
86: * Supports inline instantiation of the {@link CustomFormAuthenticationMechanism} qualifier.
87: *
88: * @since 4.0
89: */
90: public static final class Literal extends AnnotationLiteral<CustomFormAuthenticationMechanism> implements CustomFormAuthenticationMechanism {
91: private static final long serialVersionUID = 1L;
92:
93: /**
94: * Instance of the {@link CustomFormAuthenticationMechanism} qualifier.
95: */
96: public static final Literal INSTANCE = new Literal();
97: }
98:
99: }
100:
101: }