public final class ObexHelper extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
computeAuthenticationChallenge(byte[] nonce,
String realm,
boolean access,
boolean userID)
Computes an authentication challenge header.
|
static byte[] |
computeMd5Hash(byte[] in)
Compute the MD5 hash of the byte array provided.
|
static byte[] |
convertToByteArray(long l)
Converts the long to a 4 byte array.
|
static long |
convertToLong(byte[] b)
Converts the byte array to a long.
|
static String |
convertToUnicode(byte[] b,
boolean includesNull)
Converts the byte array provided to a unicode string.
|
static byte[] |
convertToUnicodeByteArray(String s)
Converts the String to a UNICODE byte array.
|
static byte[] |
createHeader(HeaderSet head,
boolean nullOut)
Creates the header part of OBEX packet based on the header provided.
|
static int |
findHeaderEnd(byte[] headerArray,
int start,
int maxSize)
Determines where the maximum divide is between headers.
|
static int |
findTag(byte tag,
byte[] value)
Finds the index that starts the tag value pair in the byte array provide.
|
static int |
getMaxRxPacketSize(ObexTransport transport)
Return the maximum allowed OBEX packet to receive - used in OBEX connect.
|
static int |
getMaxTxPacketSize(ObexTransport transport)
Return the maximum allowed OBEX packet to transmit.
|
static byte[] |
getTagValue(byte tag,
byte[] triplet)
Retrieves the value from the byte array for the tag value specified.
|
static byte[] |
updateHeaderSet(HeaderSet header,
byte[] headerArray)
Updates the HeaderSet with the headers received in the byte array
provided.
|
public static final boolean VDBG
public static final int BASE_PACKET_LENGTH
public static final int MAX_PACKET_SIZE_INT
public static final int LOWER_LIMIT_MAX_PACKET_SIZE
public static final int MAX_CLIENT_PACKET_SIZE
public static final int OBEX_OPCODE_FINAL_BIT_MASK
public static final int OBEX_OPCODE_CONNECT
public static final int OBEX_OPCODE_DISCONNECT
public static final int OBEX_OPCODE_PUT
public static final int OBEX_OPCODE_PUT_FINAL
public static final int OBEX_OPCODE_GET
public static final int OBEX_OPCODE_GET_FINAL
public static final int OBEX_OPCODE_RESERVED
public static final int OBEX_OPCODE_RESERVED_FINAL
public static final int OBEX_OPCODE_SETPATH
public static final int OBEX_OPCODE_ABORT
public static final int OBEX_AUTH_REALM_CHARSET_ASCII
public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_1
public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_2
public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_3
public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_4
public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_5
public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_6
public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_7
public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_8
public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_9
public static final int OBEX_AUTH_REALM_CHARSET_UNICODE
public static final byte OBEX_SRM_ENABLE
public static final byte OBEX_SRM_DISABLE
public static final byte OBEX_SRM_SUPPORT
public static final byte OBEX_SRMP_WAIT
public static byte[] updateHeaderSet(HeaderSet header, byte[] headerArray) throws IOException
The first two bits of an OBEX Header specifies the type of object that is being sent. The table below specifies the meaning of the high bits.
Bits 8 and 7 | Value | Description |
---|---|---|
00 | 0x00 | Null Terminated Unicode text, prefixed with 2 byte unsigned integer |
01 | 0x40 | Byte Sequence, length prefixed with 2 byte unsigned integer |
10 | 0x80 | 1 byte quantity |
11 | 0xC0 | 4 byte quantity - transmitted in network byte order (high byte first |
header
- the HeaderSet to updateheaderArray
- the byte array containing headersIOException
- if an invalid header was foundpublic static byte[] createHeader(HeaderSet head, boolean nullOut)
head
- the header used to construct the byte arraynullOut
- true
if the header should be set to
null
once it is added to the array or
false
if it should not be nulled outpublic static int findHeaderEnd(byte[] headerArray, int start, int maxSize)
headerArray
- the headers to separatestart
- the starting index to searchmaxSize
- the maximum size of a packetpublic static long convertToLong(byte[] b)
b
- the byte array to convert to a longpublic static byte[] convertToByteArray(long l)
l
- the long to convertpublic static byte[] convertToUnicodeByteArray(String s)
s
- the string to convertpublic static byte[] getTagValue(byte tag, byte[] triplet)
tag
- the tag to retrieve from the byte arraytriplet
- the byte sequence containing the tag length value formpublic static int findTag(byte tag, byte[] value)
tag
- the tag to look forvalue
- the byte array to searchpublic static String convertToUnicode(byte[] b, boolean includesNull)
b
- the byte array to convert to a stringincludesNull
- determine if the byte string provided contains the
UNICODE null character at the end or not; if it does, it will be
removedIllegalArgumentException
- if the byte array has an odd lengthpublic static byte[] computeMd5Hash(byte[] in)
in
- the byte array to hashpublic static byte[] computeAuthenticationChallenge(byte[] nonce, String realm, boolean access, boolean userID) throws IOException
nonce
- the challenge that will be provided to the peer; the
challenge must be 16 bytes longrealm
- a short description that describes what password to useaccess
- if true
then full access will be granted if
successful; if false
then read only access will be
granted if successfuluserID
- if true
, a user ID is required in the reply;
if false
, no user ID is requiredIllegalArgumentException
- if the challenge is not 16 bytes long;
if the realm can not be encoded in less then 255 bytesIOException
- if the encoding scheme ISO 8859-1 is not supportedpublic static int getMaxTxPacketSize(ObexTransport transport)
transport
- Reference to the ObexTransport in use.public static int getMaxRxPacketSize(ObexTransport transport)
transport
-