This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
/
AuthenticationHandler.java
56 lines (50 loc) · 2.11 KB
/
AuthenticationHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*******************************************************************************
* Copyright (c) 2013 Bryan Hunt and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bryan Hunt - initial API and implementation
* Holger Staudacher - API finalization
******************************************************************************/
package com.eclipsesource.jaxrs.provider.security;
import java.security.Principal;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.SecurityContext;
/**
* <p>
* The {@link AuthenticationHandler} is part of the security provider and needs to be registered as an OSGi servide.
* Client may implement this interface to perform user authentication and to define an authentication scheme.
* These values will be used later on in a {@link SecurityContext} that is used by the framework to verify
* authentication.
* </p>
* <p>
* An {@link AuthenticationHandler} may be used together with an {@link AuthorizationHandler}.
* </p>
*
* @see SecurityContext
* @see AuthorizationHandler
*/
public interface AuthenticationHandler {
/**
* <p>
* Authenticates the user initiating the request. Implementations must return null if the
* user could not be authenticated.
* </p>
*
* @param requestContext the request context supplied by the underlying JAX-RS implementation.
* @return a principal representing the authenticated user initiating the request or {@code null} if
* the user could not be authenticated.
*/
Principal authenticate( ContainerRequestContext requestContext );
/**
* @return the authentication scheme. Must be one of {@link SecurityContext.BASIC_AUTH},
* {@link SecurityContext.CLIENT_CERT_AUTH,} {@link SecurityContext.DIGEST_AUTH},
* {@link SecurityContext.FORM_AUTH} or {@code null}.
*
* @see SecurityContext
*/
String getAuthenticationScheme();
}