Package org.apache.tomcat.websocket
Class Authenticator
- java.lang.Object
-
- org.apache.tomcat.websocket.Authenticator
-
- Direct Known Subclasses:
BasicAuthenticator,DigestAuthenticator
public abstract class Authenticator extends java.lang.ObjectBase class for the authentication methods used by the WebSocket client.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAuthenticator()Constructs an Authenticator instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.StringgetAuthorization(java.lang.String requestUri, java.lang.String authenticateHeader, java.lang.String userName, java.lang.String userPassword, java.lang.String userRealm)Deprecated.Unused.abstract java.lang.StringgetAuthorization(java.lang.String method, java.lang.String requestUri, java.lang.String authenticateHeader, java.lang.String userName, java.lang.String userPassword, java.lang.String userRealm)Generate the authorization header value that will be sent to the server.abstract java.lang.StringgetSchemeName()Get the authentication method.java.util.Map<java.lang.String,java.lang.String>parseAuthenticateHeader(java.lang.String authenticateHeader)Utility method to parse the authentication header.protected voidvalidatePassword(java.lang.String password)Validates that the password is notnull.protected voidvalidateRealm(java.lang.String userRealm, java.lang.String serverRealm)Validates that the configured user realm matches the server realm.protected voidvalidateUsername(java.lang.String userName)Validates that the user name is notnull.
-
-
-
Method Detail
-
getAuthorization
@Deprecated public java.lang.String getAuthorization(java.lang.String requestUri, java.lang.String authenticateHeader, java.lang.String userName, java.lang.String userPassword, java.lang.String userRealm) throws AuthenticationExceptionDeprecated.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 java.lang.String getAuthorization(java.lang.String method, java.lang.String requestUri, java.lang.String authenticateHeader, java.lang.String userName, java.lang.String userPassword, java.lang.String userRealm) throws AuthenticationExceptionGenerate 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
public abstract java.lang.String getSchemeName()
Get the authentication method.- Returns:
- the authentication scheme
-
parseAuthenticateHeader
public java.util.Map<java.lang.String,java.lang.String> parseAuthenticateHeader(java.lang.String authenticateHeader)
Utility method to parse the authentication header.- Parameters:
authenticateHeader- The server authenticate header received- Returns:
- a map of authentication parameter names and values
-
validateUsername
protected void validateUsername(java.lang.String userName) throws AuthenticationExceptionValidates that the user name is notnull.- Parameters:
userName- the user name to validate- Throws:
AuthenticationException- if the user name isnull
-
validatePassword
protected void validatePassword(java.lang.String password) throws AuthenticationExceptionValidates that the password is notnull.- Parameters:
password- the password to validate- Throws:
AuthenticationException- if the password isnull
-
validateRealm
protected void validateRealm(java.lang.String userRealm, java.lang.String serverRealm) throws AuthenticationExceptionValidates 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
-
-