Skip to content

Package: BasicAuthenticationMechanismDefinition

BasicAuthenticationMechanismDefinition

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.inject.Qualifier;
28: import java.lang.annotation.Repeatable;
29: import java.lang.annotation.Retention;
30: import java.lang.annotation.Target;
31:
32:
33: /**
34: * Annotation used to define a container authentication mechanism that implements
35: * the HTTP basic access authentication protocol as defined by the Servlet spec (13.6.1)
36: * and make that implementation available as an enabled CDI bean.
37: *
38: */
39: @Retention(RUNTIME)
40: @Target(TYPE)
41: @Repeatable(BasicAuthenticationMechanismDefinition.List.class)
42: public @interface BasicAuthenticationMechanismDefinition {
43:
44: /**
45: * Name of realm that will be sent via the <code>WWW-Authenticate</code> header.
46: * <p>
47: * Note that this realm name <b>does not</b> couple a named identity store
48: * configuration to the authentication mechanism.
49: *
50: * @return Name of realm
51: */
52: String realmName() default "";
53:
54: /**
55: * List of {@link Qualifier qualifier annotations}.
56: *
57: * <p>
58: * An {@link HttpAuthenticationMechanism} injection point
59: * with these qualifier annotations injects a bean that is
60: * produced by this {@code BasicAuthenticationMechanismDefinition}.</p>
61: *
62: * <p>
63: * The default value is {@code BasicAuthenticationMechanism}, indicating that
64: * this {@code BasicAuthenticationMechanismDefinition} produces
65: * bean instances of type {@link HttpAuthenticationMechanism} qualified by
66: * {@code BasicAuthenticationMechanism}.
67: *
68: * @return list of qualifiers.
69: * @since 4.0
70: */
71: Class<?>[] qualifiers() default { BasicAuthenticationMechanism.class };
72:
73: /**
74: * Enables multiple <code>BasicAuthenticationMechanismDefinition</code>
75: * annotations on the same type.
76: */
77: @Retention(RUNTIME)
78: @Target(TYPE)
79: public @interface List {
80: BasicAuthenticationMechanismDefinition[] value();
81: }
82:
83: @Qualifier
84: @Retention(RUNTIME)
85: @Target({FIELD, METHOD, TYPE, PARAMETER})
86: public static @interface BasicAuthenticationMechanism {
87:
88: /**
89: * Supports inline instantiation of the {@link BasicAuthenticationMechanism} qualifier.
90: *
91: * @since 4.0
92: */
93: public static final class Literal extends AnnotationLiteral<BasicAuthenticationMechanism> implements BasicAuthenticationMechanism {
94: private static final long serialVersionUID = 1L;
95:
96: /**
97: * Instance of the {@link BasicAuthenticationMechanism} qualifier.
98: */
99: public static final Literal INSTANCE = new Literal();
100: }
101:
102: }
103: }