APIdia Launch Partner
Top Description Inners Constructors Methods
com.sun.net.httpserver

public abstract Class Authenticator

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.net.httpserver.BasicAuthenticator

Authenticator represents an implementation of an HTTP authentication mechanism. Sub-classes provide implementations of specific mechanisms such as Digest or Basic auth. Instances are invoked to provide verification of the authentication information provided in all incoming requests. Note. This implies that any caching of credentials or other authentication information must be done outside of this class.
Since
1.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Authenticator.Failure

Indicates an authentication failure.

public abstract static class
Authenticator.Result

Base class for return type from authenticate(HttpExchange) method.

public static class
Authenticator.Retry

Indicates an authentication must be retried.

public static class
Authenticator.Success

Indicates an authentication has succeeded and the authenticated user principal can be acquired by calling getPrincipal().

Constructor Summary

AccessConstructor and Description
protected
Authenticator()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract Authenticator.Result

Returns:

the result
authenticate
(HttpExchange
the HttpExchange upon which authenticate is called
exch
)

Called to authenticate each incoming request.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Authenticatorback to summary
protected Authenticator()

Constructor for subclasses to call.

Method Detail

authenticateback to summary
public abstract Authenticator.Result authenticate(HttpExchange exch)

Called to authenticate each incoming request. The implementation must return a Failure, Success or Retry object as appropriate:

  • Failure means the authentication has completed, but has failed due to invalid credentials.
  • Success means that the authentication has succeeded, and a Principal object representing the user can be retrieved by calling Success#getPrincipal().
  • Retry means that another HTTP exchange is required. Any response headers needing to be sent back to the client are set in the given HttpExchange. The response code to be returned must be provided in the Retry object. Retry may occur multiple times.
Parameters
exch:HttpExchange

the HttpExchange upon which authenticate is called

Returns:Authenticator.Result

the result

com.sun.net.httpserver back to summary

public Class Authenticator.Failure

extends Result
Class Inheritance

Indicates an authentication failure. The authentication attempt has completed.

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
public
Failure(int
the response code to associate with this Failure instance
responseCode
)

Creates a Failure instance with given response code.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the response code associated with this Failure instance
getResponseCode
()

Returns the response code to send to the client.

Field Detail

responseCodeback to summary
private int responseCode

Constructor Detail

Failureback to summary
public Failure(int responseCode)

Creates a Failure instance with given response code.

Parameters
responseCode:int

the response code to associate with this Failure instance

Method Detail

getResponseCodeback to summary
public int getResponseCode()

Returns the response code to send to the client.

Returns:int

the response code associated with this Failure instance

com.sun.net.httpserver back to summary

public abstract Class Authenticator.Result

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.net.httpserver.Authenticator.Failure, com.sun.net.httpserver.Authenticator.Success, com.sun.net.httpserver.Authenticator.Retry

Base class for return type from authenticate(HttpExchange) method.

Constructor Summary

AccessConstructor and Description
protected
Result()

Constructor for subclasses to call.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Resultback to summary
protected Result()

Constructor for subclasses to call.

com.sun.net.httpserver back to summary

public Class Authenticator.Retry

extends Result
Class Inheritance

Indicates an authentication must be retried. The response code to be sent back is as returned from getResponseCode(). The Authenticator must also have set any necessary response headers in the given HttpExchange before returning this Retry object.

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
public
Retry(int
the response code to associate with this Retry instance
responseCode
)

Creates a Retry instance with given response code.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the response code associated with this Retry instance
getResponseCode
()

Returns the response code to send to the client.

Field Detail

responseCodeback to summary
private int responseCode

Constructor Detail

Retryback to summary
public Retry(int responseCode)

Creates a Retry instance with given response code.

Parameters
responseCode:int

the response code to associate with this Retry instance

Method Detail

getResponseCodeback to summary
public int getResponseCode()

Returns the response code to send to the client.

Returns:int

the response code associated with this Retry instance

com.sun.net.httpserver back to summary

public Class Authenticator.Success

extends Result
Class Inheritance

Indicates an authentication has succeeded and the authenticated user principal can be acquired by calling getPrincipal().

Field Summary

Modifier and TypeField and Description
private HttpPrincipal

Constructor Summary

AccessConstructor and Description
public
Success(HttpPrincipal
the authenticated user you wish to set as Principal
p
)

Creates a Success instance with given Principal.

Method Summary

Modifier and TypeMethod and Description
public HttpPrincipal

Returns:

the Principal instance associated with the authenticated user
getPrincipal
()

Returns the authenticated user Principal.

Field Detail

principalback to summary
private HttpPrincipal principal

Constructor Detail

Successback to summary
public Success(HttpPrincipal p)

Creates a Success instance with given Principal.

Parameters
p:HttpPrincipal

the authenticated user you wish to set as Principal

Method Detail

getPrincipalback to summary
public HttpPrincipal getPrincipal()

Returns the authenticated user Principal.

Returns:HttpPrincipal

the Principal instance associated with the authenticated user