public abstract class BasicAuthorizationBuffer extends Object
When creating, one must specify the boundaries of the portion of the buffer to analyze, and what this portion contains (all the HTTP headers, only the Authorization header, or only its value).
| Modifier and Type | Class and Description |
|---|---|
static class |
BasicAuthorizationBuffer.Scope
The scope of the lookup.
|
| Constructor and Description |
|---|
BasicAuthorizationBuffer(BasicAuthorizationBuffer.Scope scope,
int position,
int limit)
Create a buffer.
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
debug(String msg)
Log informations for debugging.
|
boolean |
findCredentialsBoundaries()
Find the boundaries of the base64 credentials in the buffer.
|
abstract byte |
get(int i)
Get the byte at the index specified.
|
Credentials |
replace(PasswordManager passwordManager)
Replace the raw password in the buffer with '*'
and reencode the credentials in Base64.
|
abstract void |
set(int i,
byte b)
Set a byte at the index specified.
|
public BasicAuthorizationBuffer(BasicAuthorizationBuffer.Scope scope, int position, int limit)
scope - Indicates what is delimited in the buffer :
all the headers, just the Authorization header,
or simply its value.position - The start offset of the bytes.limit - The end offset of the bytes.public abstract byte get(int i)
i - The actual index.public abstract void set(int i,
byte b)
i - The actual index.b - The byte to set.public abstract void debug(String msg)
msg - The debug message.public boolean findCredentialsBoundaries()
String to find in the buffer : "Authorization: Basic [base64Credential]" (or just "Basic [base64Credential]" according to the scope)
header-field = field-name ":" OWS field-value OWS
OWS means "optional whitespace" and header fields are delimited using CRLF.
true if the credentials have been found,
false otherwise.public Credentials replace(PasswordManager passwordManager)
This method have to be called if findCredentialsBoundaries()
has returned true.
passwordManager - Allow to create a secure password.Copyright © 2018 Alternet. All rights reserved.