public class AuthMetadataFlyweight extends Object
| Modifier and Type | Method and Description |
|---|---|
static char[] |
decodeBearerTokenAsCharArray(ByteBuf bearerAuthMetadata)
Read all the remaining
bytes from the given ByteBuf where the first byte is
username length and the subsequent number of bytes equal to decoded length |
static CharSequence |
decodeCustomAuthType(ByteBuf metadata)
Read up to 129 bytes from the given metadata in order to get the custom Auth Type
|
static ByteBuf |
decodePassword(ByteBuf simpleAuthMetadata)
Read all the remaining
bytes from the given ByteBuf which represents user's
password |
static char[] |
decodePasswordAsCharArray(ByteBuf simpleAuthMetadata)
Read all the remaining
bytes from the given ByteBuf which represents user's
password |
static ByteBuf |
decodePayload(ByteBuf metadata)
Read all remaining
bytes from the given ByteBuf and return sliced
representation of a payload |
static ByteBuf |
decodeUsername(ByteBuf simpleAuthMetadata)
Read up to 257
bytes from the given ByteBuf where the first byte is username
length and the subsequent number of bytes equal to decoded length |
static char[] |
decodeUsernameAsCharArray(ByteBuf simpleAuthMetadata)
Read up to 257
bytes from the given ByteBuf where the first byte is username
length and the subsequent number of bytes equal to decoded length |
static WellKnownAuthType |
decodeWellKnownAuthType(ByteBuf metadata)
Read first byte from the given
metadata and tries to convert it's value to WellKnownAuthType. |
static ByteBuf |
encodeBearerMetadata(ByteBufAllocator allocator,
char[] token)
Encode a Authentication CompositeMetadata payload using Bearer Authentication format
|
static ByteBuf |
encodeMetadata(ByteBufAllocator allocator,
String customAuthType,
ByteBuf metadata)
Encode a Authentication CompositeMetadata payload using custom authentication type
|
static ByteBuf |
encodeMetadata(ByteBufAllocator allocator,
WellKnownAuthType authType,
ByteBuf metadata)
Encode a Authentication CompositeMetadata payload using custom authentication type
|
static ByteBuf |
encodeMetadataWithCompression(ByteBufAllocator allocator,
String authType,
ByteBuf metadata)
Encode a new Authentication Metadata payload information, first verifying if the passed
String matches a WellKnownAuthType (in which case it will be encoded in a compressed
fashion using the mime id of that type). |
static ByteBuf |
encodeSimpleMetadata(ByteBufAllocator allocator,
char[] username,
char[] password)
Encode a Authentication CompositeMetadata payload using Simple Authentication format
|
static boolean |
isWellKnownAuthType(ByteBuf metadata)
|
public static ByteBuf encodeMetadata(ByteBufAllocator allocator, String customAuthType, ByteBuf metadata)
allocator - the ByteBufAllocator to use to create intermediate buffers as needed.customAuthType - the custom mime type to encode.metadata - the metadata value to encode.IllegalArgumentException - in case of customAuthType is non US_ASCII string or
empty string or its length is greater than 128 bytespublic static ByteBuf encodeMetadata(ByteBufAllocator allocator, WellKnownAuthType authType, ByteBuf metadata)
allocator - the ByteBufAllocator to create intermediate buffers as needed.authType - the well-known mime type to encode.metadata - the metadata value to encode.IllegalArgumentException - in case of authType is WellKnownAuthType.UNPARSEABLE_AUTH_TYPE or WellKnownAuthType.UNKNOWN_RESERVED_AUTH_TYPEpublic static ByteBuf encodeSimpleMetadata(ByteBufAllocator allocator, char[] username, char[] password)
allocator - the ByteBufAllocator to use to create intermediate buffers as needed.username - the char sequence which represents user name.password - the char sequence which represents user password.IllegalArgumentException - if the username length is greater than 255public static ByteBuf encodeBearerMetadata(ByteBufAllocator allocator, char[] token)
allocator - the ByteBufAllocator to use to create intermediate buffers as needed.token - the char sequence which represents BEARER token.public static ByteBuf encodeMetadataWithCompression(ByteBufAllocator allocator, String authType, ByteBuf metadata)
String matches a WellKnownAuthType (in which case it will be encoded in a compressed
fashion using the mime id of that type).
Prefer using encodeMetadata(ByteBufAllocator, String, ByteBuf) if you already know
that the mime type is not a WellKnownAuthType.
allocator - the ByteBufAllocator to use to create intermediate buffers as needed.authType - the mime type to encode, as a String. well known mime types are
compressed.metadata - the metadata value to encode.encodeMetadata(ByteBufAllocator, WellKnownAuthType, ByteBuf),
encodeMetadata(ByteBufAllocator, String, ByteBuf)public static boolean isWellKnownAuthType(ByteBuf metadata)
byte from a ByteBuf and check whether it is length or WellKnownAuthType. Assuming said buffer properly contains such a bytemetadata - byteBuf used to get information frompublic static WellKnownAuthType decodeWellKnownAuthType(ByteBuf metadata)
metadata and tries to convert it's value to WellKnownAuthType.metadata - given metadata buffer to read fromWellKnownAuthType.UNPARSEABLE_AUTH_TYPE if
field's value is length or unknown auth typeIllegalStateException - if not enough readable bytes in the given ByteBufpublic static CharSequence decodeCustomAuthType(ByteBuf metadata)
metadata - public static ByteBuf decodePayload(ByteBuf metadata)
bytes from the given ByteBuf and return sliced
representation of a payloadmetadata - metadata to get payload from. Please note, the metadata#readIndex
should be set to the beginning of the payload bytesByteBuf or Unpooled.EMPTY_BUFFER if no bytes readable in the
given onepublic static ByteBuf decodeUsername(ByteBuf simpleAuthMetadata)
bytes from the given ByteBuf where the first byte is username
length and the subsequent number of bytes equal to decoded lengthsimpleAuthMetadata - the given metadata to read username from. Please note, the simpleAuthMetadata#readIndex should be set to the username length byteByteBuf or Unpooled.EMPTY_BUFFER if username length is zeropublic static ByteBuf decodePassword(ByteBuf simpleAuthMetadata)
bytes from the given ByteBuf which represents user's
passwordsimpleAuthMetadata - the given metadata to read password from. Please note, the simpleAuthMetadata#readIndex should be set to the beginning of the password bytesByteBuf or Unpooled.EMPTY_BUFFER if password length is zeropublic static char[] decodeUsernameAsCharArray(ByteBuf simpleAuthMetadata)
bytes from the given ByteBuf where the first byte is username
length and the subsequent number of bytes equal to decoded lengthsimpleAuthMetadata - the given metadata to read username from. Please note, the simpleAuthMetadata#readIndex should be set to the username length bytechar[] which represents UTF-8 usernamepublic static char[] decodePasswordAsCharArray(ByteBuf simpleAuthMetadata)
bytes from the given ByteBuf which represents user's
passwordsimpleAuthMetadata - the given metadata to read username from. Please note, the simpleAuthMetadata#readIndex should be set to the beginning of the password byteschar[] which represents UTF-8 passwordpublic static char[] decodeBearerTokenAsCharArray(ByteBuf bearerAuthMetadata)
bytes from the given ByteBuf where the first byte is
username length and the subsequent number of bytes equal to decoded lengthbearerAuthMetadata - the given metadata to read username from. Please note, the simpleAuthMetadata#readIndex should be set to the beginning of the password byteschar[] which represents UTF-8 password