com.upek.android.ptapi
Class PtUtil

java.lang.Object
  extended by com.upek.android.ptapi.PtUtil

public class PtUtil
extends java.lang.Object

This class contains some utility functions for simplify some operations manipulating with structures stored in bytearray (original PT_DATA)


Constructor Summary
PtUtil()
           
 
Method Summary
static void clearAccessRightsBit(byte[] accessRights, int bit)
          Macro for clearing one of the access rights bit.
static byte decodeByte(byte[] x)
          Decodes number from byte array with byte number in little endien.
static int decodeInt(byte[] x)
          Decodes number from byte array with int number in little endien.
static long decodeLong(byte[] x)
          Decodes number from byte array with long number in little endien.
static short decodeShort(byte[] x)
          Decodes number from byte array with short number in little endien.
static byte[] decodeUseFingerResult(byte[] result)
          Decode result byte array from byte array returned by useFingerData().
static int decodeUseFingerResultDWORD(byte[] result)
          Decode DWORD (= int in JAVA) from byte array returned by useFingerData().
static byte[] encodeNumber(byte x)
          Encodes number in byte array in little endien order.
static byte[] encodeNumber(int x)
          Encodes number in byte array in little endien order.
static byte[] encodeNumber(long x)
          Encodes number in byte array in little endien order.
static byte[] encodeNumber(short x)
          Encodes number in byte array in little endien order.
static byte[] encodeUseFingerParams(byte[] prm1)
          Use this function for encoding of parameters for function PtConnectionAdvancedI.useFingerData().
static byte[] encodeUseFingerParams(byte[] prm1, byte[] prm2)
          Use this function for encoding of parameters for function PtConnectionAdvancedI.useFingerData().
static byte[] encodeUseFingerParams(byte[] prm1, byte[] prm2, byte[] prm3)
          Use this function for encoding of parameters for function PtConnectionAdvancedI.useFingerData().
static boolean getAccessRightsBit(byte[] accessRights, int bit)
          Macro for getting state of one of the access rights bit.
static byte[] getAuthKey(int type, byte[] key)
          Generate bytearray representing key of specified type (use PT_SECURECHANNEL_MECH_DES_CBC or PT_SECURECHANNEL_MECH_AES_CBC constants).
static void setAccessRightsBit(byte[] accessRights, int bit)
          Macro for setting one of the access rights bit.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PtUtil

public PtUtil()
Method Detail

clearAccessRightsBit

public static final void clearAccessRightsBit(byte[] accessRights,
                                              int bit)
Macro for clearing one of the access rights bit.

Parameters:
accessRights - Access rights byte array.
bit - The number of access right to be cleared.

decodeByte

public static final byte decodeByte(byte[] x)
Decodes number from byte array with byte number in little endien.

Parameters:
x - is byte array of length at least 1 with number in little endien.
Returns:
Decoded byte number.

decodeInt

public static final int decodeInt(byte[] x)
Decodes number from byte array with int number in little endien.

Parameters:
x - is byte array length at least 4 with number in little endien.
Returns:
Decoded int number.

decodeLong

public static final long decodeLong(byte[] x)
Decodes number from byte array with long number in little endien.

Parameters:
x - is byte array length at least 8 with number in little endien.
Returns:
Decoded long number.

decodeShort

public static final short decodeShort(byte[] x)
Decodes number from byte array with short number in little endien.

Parameters:
x - is byte array of length at least 2 with number in little endien.
Returns:
Decoded short number.

decodeUseFingerResult

public static final byte[] decodeUseFingerResult(byte[] result)
Decode result byte array from byte array returned by useFingerData().

Parameters:
result - Byte array returned by useFingerData().
Returns:
Result byte array.

decodeUseFingerResultDWORD

public static final int decodeUseFingerResultDWORD(byte[] result)
Decode DWORD (= int in JAVA) from byte array returned by useFingerData().

Parameters:
result - Byte array returned by useFingerData().
Returns:
Result DWORD

encodeNumber

public static final byte[] encodeNumber(byte x)
Encodes number in byte array in little endien order.

Parameters:
x - is number to encode.
Returns:
Byte array of length 1 with number in little endien order.

encodeNumber

public static final byte[] encodeNumber(int x)
Encodes number in byte array in little endien order.

Parameters:
x - is number to encode.
Returns:
Byte array of length 4 with number in little endien order.

encodeNumber

public static final byte[] encodeNumber(long x)
Encodes number in byte array in little endien order.

Parameters:
x - is number to encode.
Returns:
Byte array of length 8 with number in little endien order.

encodeNumber

public static final byte[] encodeNumber(short x)
Encodes number in byte array in little endien order.

Parameters:
x - is number to encode.
Returns:
Byte array of length 2 with number in little endien order.

encodeUseFingerParams

public static final byte[] encodeUseFingerParams(byte[] prm1)
Use this function for encoding of parameters for function PtConnectionAdvancedI.useFingerData(). It encalupsates byte array parameter(s) into one byte array with correct structure and headers.

Parameters:
prm1 - First parameter for operation useFingerData.
Returns:
Parameter to pass into useFingerData method.

encodeUseFingerParams

public static final byte[] encodeUseFingerParams(byte[] prm1,
                                                 byte[] prm2)
Use this function for encoding of parameters for function PtConnectionAdvancedI.useFingerData(). It encalupsates byte array parameter(s) into one byte array with correct structure and headers.

Parameters:
prm1 - First parameter for operation useFingerData.
prm2 - Second parameter for operation useFingerData.
Returns:
Parameter to pass into useFingerData method.

encodeUseFingerParams

public static final byte[] encodeUseFingerParams(byte[] prm1,
                                                 byte[] prm2,
                                                 byte[] prm3)
Use this function for encoding of parameters for function PtConnectionAdvancedI.useFingerData(). It encalupsates byte array parameter(s) into one byte array with correct structure and headers.

Parameters:
prm1 - First parameter for operation useFingerData.
prm2 - Second parameter for operation useFingerData.
prm3 - Third parameter for operation useFingerData.
Returns:
Parameter to pass into useFingerData method.

getAccessRightsBit

public static final boolean getAccessRightsBit(byte[] accessRights,
                                               int bit)
Macro for getting state of one of the access rights bit.

Parameters:
accessRights - Access rights byte array.
bit - Number of access right to be read.
Returns:
Value of asked bit.

getAuthKey

public static final byte[] getAuthKey(int type,
                                      byte[] key)
Generate bytearray representing key of specified type (use PT_SECURECHANNEL_MECH_DES_CBC or PT_SECURECHANNEL_MECH_AES_CBC constants). It doesn't check validity of key. It can be used for createProfileWrapped.

Parameters:
type - Type of key
key - Raw key data
Returns:
Key stored in bytearray, can

setAccessRightsBit

public static final void setAccessRightsBit(byte[] accessRights,
                                            int bit)
Macro for setting one of the access rights bit.

Parameters:
accessRights - Access rights byte array.
bit - The number of access right to be set.