org.jSyncManager.API.Protocol.Util

Class DLPUserInfo

Implemented Interfaces:
Serializable

public class DLPUserInfo
extends java.lang.Object
implements Serializable

The DLP User Information class. This class holds the user information for the handheld.

Constructor Summary

DLPUserInfo(int uid, int vid, int hostID, String userName)
Construct a new DLP User Info object using the specified information.
DLPUserInfo(userBlock[] )
Create a new DLP User Info object based on the data queried from the handheld.

Method Summary

static byte[]
encodePasswordV1(String passwd)
Encodes a pasword using the pre-OS4 encoding mechanism.
static byte[]
encryptPasswordV4(String passwd)
Method to encrypt a password String.
byte[]
getEncryptedPassword()
Retreives the encrypted password for this user.
int
getLastHostID()
Retreives the last sync host ID.
Calendar
getLastSuccessfulSyncDate()
Retreives the last successful sync date.
Calendar
getLastSyncDate()
Retreives the last sync date.
int
getUserID()
Retreives the user ID for this user object.
String
getUserName()
Retreives the user name for this user object.
int
getViewerID()
Retreives the viewer ID for this user object.
static void
main(args[] )
byte[]
object2Bytes()
Convert this object to a byte array suitable for writing to the handheld.
void
setLastHostID(int i)
Set the last sync host ID.
void
setLastSyncDate(Calendar date)
Set the last sync date.
void
setUserID(int i)
Set the user ID.
void
setUserName(String s)
Set the user name.
void
setViewerID(int i)
Set the viewer ID.
String
toString()
Create a human-readable String representation of this object.
boolean
validatePassword(String passwd)
Validates the specified password.
boolean
verifyPasswordV1(String passwd)
This method is called to test to see if the supplied password matches the password stored within this DLPUserInfo object.
boolean
verifyPasswordV4(String passwd)
This method is called to test to see if the supplied password matches the password stored within this DLPUserInfo object.

Constructor Details

DLPUserInfo

public DLPUserInfo(int uid,
                   int vid,
                   int hostID,
                   String userName)
Construct a new DLP User Info object using the specified information.
Parameters:
uid - the user ID.
vid - the viewer ID.
hostID - the host PC ID.
userName - the user name to create.

DLPUserInfo

public DLPUserInfo(userBlock[] )
            throws DLPFunctionCallException
Create a new DLP User Info object based on the data queried from the handheld.
Parameters:
Throws:
DLPFunctionCallException - thrown if any parsing errors occur.

Method Details

encodePasswordV1

public static byte[] encodePasswordV1(String passwd)
Encodes a pasword using the pre-OS4 encoding mechanism.
Parameters:
passwd - the password to be encoded.
Returns:
an arrray of bytes containing the encoded password.

encryptPasswordV4

public static byte[] encryptPasswordV4(String passwd)
            throws EncryptionNotSupportedException
Method to encrypt a password String. This method will encrypt a password in the manner used by the PalmOS v4.
Parameters:
passwd - the plain-text password to encrypt.
Returns:
an array of bytes containing the encrypted password.

getEncryptedPassword

public byte[] getEncryptedPassword()
Retreives the encrypted password for this user.
Returns:
the encrypted password for this user, as a byte array.

getLastHostID

public int getLastHostID()
Retreives the last sync host ID.
Returns:
the last sync host ID.

getLastSuccessfulSyncDate

public Calendar getLastSuccessfulSyncDate()
Retreives the last successful sync date.
Returns:
the last successful sync date.

getLastSyncDate

public Calendar getLastSyncDate()
Retreives the last sync date.
Returns:
the last sync date.

getUserID

public int getUserID()
Retreives the user ID for this user object.
Returns:
the user ID for this user object.

getUserName

public String getUserName()
Retreives the user name for this user object.
Returns:
the user name for this user object.

getViewerID

public int getViewerID()
Retreives the viewer ID for this user object.
Returns:
the viewer ID for this user object.

main

public static final void main(args[] )
            throws EncryptionNotSupportedException

object2Bytes

public byte[] object2Bytes()
Convert this object to a byte array suitable for writing to the handheld.
Returns:
a byte array representing the data in this object.

setLastHostID

public void setLastHostID(int i)
Set the last sync host ID.
Parameters:
i - the last sync host ID.

setLastSyncDate

public void setLastSyncDate(Calendar date)
Set the last sync date.
Parameters:
date - the last sync date.

setUserID

public void setUserID(int i)
Set the user ID.
Parameters:
i - the user ID.

setUserName

public void setUserName(String s)
            throws DLPFunctionCallException
Set the user name.
Parameters:
s - the user name to set.
Throws:
DLPFunctionCallException - thrown if the user name is too long.

setViewerID

public void setViewerID(int i)
Set the viewer ID.
Parameters:
i - the viewer ID.

toString

public String toString()
Create a human-readable String representation of this object.
Returns:
a human-readable String representation of this object.

validatePassword

public boolean validatePassword(String passwd)
            throws EncryptionNotSupportedException
Validates the specified password. This method currently works by attempting to validate the supplied password against the stored password using both the v1 and v4 encoding mechanisms. If either encoding mechanism matches, we'll return true. In some future release, this behaviour will probably be changed to testing against only the mechanism in use by the handheld.
Parameters:
passwd - the clear-text pasword to be tested.
Returns:
true if one of the encoding mechanisms validates, false otherwise.
Throws:
EncryptionNotSupportedException - if we attempt V4 verification, and your JVM doesn't support MD5 digests.

verifyPasswordV1

public boolean verifyPasswordV1(String passwd)
This method is called to test to see if the supplied password matches the password stored within this DLPUserInfo object. Note that method uses pre-PalmOS v4 password encryption.
Parameters:
passwd - the clear-text password to test against the encrypted password.
Returns:
true if the password is correct, false otherwise.

verifyPasswordV4

public boolean verifyPasswordV4(String passwd)
            throws EncryptionNotSupportedException
This method is called to test to see if the supplied password matches the password stored within this DLPUserInfo object. Note that this method uses PalmOS v4 password encryption.
Parameters:
passwd - the clear-text password to test against the encrypted password.
Returns:
true if the password is correct, false otherwise.
Throws:
EncryptionNotSupportedException - if MD5 encryption isn't supported by your JVM.