Class Authenticator
java.lang.Object
org.apache.tomcat.websocket.Authenticator
- Direct Known Subclasses:
BasicAuthenticator, DigestAuthenticator
Base class for the authentication methods used by the WebSocket client.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAuthorization(String requestUri, String authenticateHeader, String userName, String userPassword, String userRealm) Deprecated.Unused.abstract StringgetAuthorization(String method, String requestUri, String authenticateHeader, String userName, String userPassword, String userRealm) Generate the authorization header value that will be sent to the server.abstract StringGet the authentication method.parseAuthenticateHeader(String authenticateHeader) Utility method to parse the authentication header.protected voidvalidatePassword(String password) Validates that the password is notnull.protected voidvalidateRealm(String userRealm, String serverRealm) Validates that the configured user realm matches the server realm.protected voidvalidateUsername(String userName) Validates that the user name is notnull.
-
Constructor Details
-
Authenticator
protected Authenticator()Constructs an Authenticator instance.
-
-
Method Details
-
getAuthorization
@Deprecated public String getAuthorization(String requestUri, String authenticateHeader, String userName, String userPassword, String userRealm) throws AuthenticationException Deprecated.Unused. Will be remove in Tomcat 12. UsegetAuthorization(String, String, String, String, String, String)Generate the authorization header value that will be sent to the server.- Parameters:
requestUri- The request URIauthenticateHeader- The server authentication header receiveduserName- The usernameuserPassword- The user passworduserRealm- The realm for which the provided username and password are valid.nullto indicate all realms.- Returns:
- The generated authorization header value
- Throws:
AuthenticationException- When an error occurs
-
getAuthorization
public abstract String getAuthorization(String method, String requestUri, String authenticateHeader, String userName, String userPassword, String userRealm) throws AuthenticationException Generate the authorization header value that will be sent to the server.- Parameters:
method- The request methodrequestUri- The request URIauthenticateHeader- The server authentication header receiveduserName- The usernameuserPassword- The user passworduserRealm- The realm for which the provided username and password are valid.nullto indicate all realms.- Returns:
- The generated authorization header value
- Throws:
AuthenticationException- When an error occurs
-
getSchemeName
Get the authentication method.- Returns:
- the authentication scheme
-
parseAuthenticateHeader
-
validateUsername
Validates that the user name is notnull.- Parameters:
userName- the user name to validate- Throws:
AuthenticationException- if the user name isnull
-
validatePassword
Validates that the password is notnull.- Parameters:
password- the password to validate- Throws:
AuthenticationException- if the password isnull
-
validateRealm
Validates that the configured user realm matches the server realm.- Parameters:
userRealm- the user-configured realm, ornullto accept any realmserverRealm- the realm from the server's authentication challenge- Throws:
AuthenticationException- if the realms do not match
-