Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class DefaultBearerTokenResolver

  1. Object
  2. DefaultBearerTokenResolver

ImplementsBearerTokenResolver

Finds the token in the Authorization: Bearer header.

A token in the address – ?access_token=... – is read only when setAllowUriQueryParameter says so, and then on a GET alone. An address is what ends up in access logs, browser history and the Referer of the next page, which is no place for a credential; the switch exists for the client that cannot set a header, an EventSource or a download link.

A request with a token in both places is refused rather than guessed at.

Constructors

public DefaultBearerTokenResolver()

Methods

public void setAllowUriQueryParameter(boolean allowUriQueryParameter)Whether access_token in the query of a GET is read; not, unless set.
public void setBearerTokenHeaderName(String bearerTokenHeaderName)The header the token is read from; Authorization unless set.
public String resolve(HttpServer.Request request)The token, or null when the request carries none.

Inherited methods

Constructor details

DefaultBearerTokenResolver

public DefaultBearerTokenResolver()

Method details

setAllowUriQueryParameter

public void setAllowUriQueryParameter(boolean allowUriQueryParameter)
Whether access_token in the query of a GET is read; not, unless set.

setBearerTokenHeaderName

public void setBearerTokenHeaderName(String bearerTokenHeaderName)
The header the token is read from; Authorization unless set. For a server behind a proxy that keeps Authorization for itself.

resolve

public String resolve(HttpServer.Request request)

The token, or null when the request carries none.

  • OAuth2AuthenticationException: when the request carries one that is malformed, or more than one