# Class Authenticator

java.lang.Object
org.apache.tomcat.websocket.Authenticator

Direct Known Subclasses:
  `BasicAuthenticator, DigestAuthenticator`

public abstract class Authenticator extends Object
Base class for the authentication methods used by the WebSocket client.

## Constructor Summary

Constructors
Constructor
Description
`Authenticator()`

## Method Summary

Modifier and Type
Method
Description
`String`
`getAuthorization(String requestUri, String authenticateHeader, String userName, String userPassword, String userRealm)`
Deprecated.
Unused.
`abstract String`
`getAuthorization(String method, String requestUri, String authenticateHeader, String userName, String userPassword, String userRealm)`
Generate the authorization header value that will be sent to the server.
`String`
`getAuthorization(String requestUri, String authenticateHeader, Map<String,Object> userProperties)`
Deprecated.
Use `getAuthorization(String, String, String, String, String)`.
`abstract String`
`getSchemeName()`
Get the authentication method.
`Map<String,String>`
`parseAuthenticateHeader(String authenticateHeader)`
Utility method to parse the authentication header.
`Map<String,String>`
`parseWWWAuthenticateHeader(String authenticateHeader)`
Deprecated.
Use `parseAuthenticateHeader(String)`.
`protected void`
`validatePassword(String password)`
`protected void`
`validateRealm(String userRealm, String serverRealm)`
`protected void`
`validateUsername(String userName)`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Authenticator

public Authenticator()

## Method Details

### getAuthorization

@Deprecated public String getAuthorization(String requestUri, String authenticateHeader, Map<String,Object> userProperties) throws AuthenticationException
Deprecated.
Use `getAuthorization(String, String, String, String, String)`. Will be removed in Tomcat 10.1.x
Generate the authorization header value that will be sent to the server.

Parameters:
  `requestUri` - The request URI
  `authenticateHeader` - The server authentication header received
  `userProperties` - The user information
Returns:
  The generated authorization header value
Throws:
  `AuthenticationException` - When an error occurs

### 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. Use `getAuthorization(String, String, String, String, String, String)`
Generate the authorization header value that will be sent to the server.

Parameters:
  `requestUri` - The request URI
  `authenticateHeader` - The server authentication header received
  `userName` - The user name
  `userPassword` - The user password
  `userRealm` - The realm for which the provided username and password are valid. `null` to 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 method
  `requestUri` - The request URI
  `authenticateHeader` - The server authentication header received
  `userName` - The username
  `userPassword` - The user password
  `userRealm` - The realm for which the provided username and password are valid. `null` to indicate all realms.
Returns:
  The generated authorization header value
Throws:
  `AuthenticationException` - When an error occurs

### getSchemeName

public abstract String getSchemeName()
Get the authentication method.

Returns:
  the authentication scheme

### parseWWWAuthenticateHeader

@Deprecated public Map<String,String> parseWWWAuthenticateHeader(String authenticateHeader)
Deprecated.
Use `parseAuthenticateHeader(String)`. Will be removed in Tomcat 10.1.x onwards
Utility method to parse the authentication header.

Parameters:
  `authenticateHeader` - The server authenticate header received
Returns:
  a map of authentication parameter names and values

### parseAuthenticateHeader

public Map<String,String> parseAuthenticateHeader(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(String userName) throws AuthenticationException

Throws:
  `AuthenticationException`

### validatePassword

protected void validatePassword(String password) throws AuthenticationException

Throws:
  `AuthenticationException`

### validateRealm

protected void validateRealm(String userRealm, String serverRealm) throws AuthenticationException

Throws:
  `AuthenticationException`