Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Aladdin
Class Hasp

    java.lang.Object
      Aladdin.Hasp

    public class Hasp

extends java.lang.Object

Field Summary
`static long` | `HASP_DEFAULT_FID` HASP default Feature ID.
`static long` | `HASP_FEATURETYPE_MASK` AND-mask used to identify the Feature type.
`static long` | `HASP_FILEID_LICENSE` HASP4 FAS memory file: (Dummy) File ID for license data segment of memory contents.
`static int` | `HASP_FILEID_MAIN` HASP4 memory file: File ID for HASP4-compatible memory contents without FAS.
`static long` | `HASP_FILEID_RO` File ID for HASP secure read only memory.
`static long` | `HASP_FILEID_RW` File ID for HASP secure writable memory.
`static java.lang.String` | `HASP_KEYINFO` getSessionInfo() format to retrieve key/hardware info.
`static int` | `HASP_MIN_BLOCK_SIZE` Minimal block size for hasp_encrypt() and hasp_decrypt() functions.
`static long` | `HASP_MIN_BLOCK_SIZE_LEGACY` Minimal block size for legacy functions hasp_legacy_encrypt() and hasp_legacy_decrypt().
`static long` | `HASP_PROGNUM_DEFAULT_FID` "Prognum" default Feature ID.
`static long` | `HASP_PROGNUM_FEATURETYPE` After AND-ing with HASP_FEATURETYPE_MASK, the Feature type contains this value.
`static long` | `HASP_PROGNUM_MASK` AND-mask used to extract program number from Feature ID if program number Feature.
`static long` | `HASP_PROGNUM_OPT_CLASSIC` "Prognum" option: enables the API to access "classic" (HASP4 or earlier) keys.
`static long` | `HASP_PROGNUM_OPT_MASK` AND-mask used to identify "prognum" options.
`static long` | `HASP_PROGNUM_OPT_NO_LOCAL` "Prognum" option: disables local license search.
`static long` | `HASP_PROGNUM_OPT_NO_REMOTE` "Prognum" option: disables network license search.
`static long` | `HASP_PROGNUM_OPT_PROCESS` "Prognum" option: sets session count of network licenses to "per process".
`static long` | `HASP_PROGNUM_OPT_TS` "Prognum" option: ignores Terminal Services.
`static java.lang.String` | `HASP_SESSIONINFO` getSessionInfo() format to retrieve session info.
`static java.lang.String` | `HASP_UPDATEINFO` getSessionInfo() format to retrieve update info (C2V).

Constructor Summary
`Hasp(long feature_id)` Hasp constructor.

Method Summary
`boolean` | `decrypt(byte[] buffer, int length)` Decrypts a buffer.
`boolean` | `encrypt(byte[] buffer, int length)` Encrypts a buffer.
`java.lang.String` | `getInfo(java.lang.String scope, java.lang.String format, java.lang.String vendor_code)` Retrieves information about all system components.
`int` | `getLastError()` Returns the error that occurred in the last function call.
`HaspTime` | `getRealTimeClock()` Reads the current time from a HASP Time key.
`java.lang.String` | `getSessionInfo(java.lang.String format)` Retrieves information regarding a session context.
`int` | `getSize(long fileid)` Retrieves the byte size of a memory file from a HASP key.
`HaspApiVersion` | `getVersion(java.lang.String vendor_code)` Reads the HASP API Version.
`boolean` | `login(java.lang.String vendor_code)` Logs in to a Feature.
`boolean` | `loginScope(java.lang.String scope, java.lang.String vendor_code)` Logs in to a Feature according to customizable search parameters.
`boolean` | `logout()` Logs out from a session and frees all allocated resources for the session.
`boolean` | `read(long fileid, int offset, int length, byte[] buffer)` Reads from the HASP key memory.
`java.lang.String` | `update(java.lang.String update_data)` Writes update information to a HASP key.
`boolean` | `write(long fileid, int offset, int length, byte[] buffer)` Writes to the HASP key memory.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### HASP_UPDATEINFO

    public static final java.lang.String HASP_UPDATEINFO

  getSessionInfo() format to retrieve update info (C2V).

### HASP_SESSIONINFO

    public static final java.lang.String HASP_SESSIONINFO

  getSessionInfo() format to retrieve session info.

### HASP_KEYINFO

    public static final java.lang.String HASP_KEYINFO

  getSessionInfo() format to retrieve key/hardware info.

### HASP_FEATURETYPE_MASK

    public static final long HASP_FEATURETYPE_MASK

  AND-mask used to identify the Feature type.

  See Also:
    Constant Field Values

### HASP_PROGNUM_FEATURETYPE

    public static final long HASP_PROGNUM_FEATURETYPE

  After AND-ing with HASP_FEATURETYPE_MASK, the Feature type contains this value.

  See Also:
    Constant Field Values

### HASP_PROGNUM_MASK

    public static final long HASP_PROGNUM_MASK

  AND-mask used to extract program number from Feature ID if program number Feature.

  See Also:
    Constant Field Values

### HASP_PROGNUM_OPT_MASK

    public static final long HASP_PROGNUM_OPT_MASK

  AND-mask used to identify "prognum" options. The following "prognum" options can be identified:
  - HASP_PROGNUM_OPT_NO_LOCAL
  - HASP_PROGNUM_OPT_NO_REMOTE
  - HASP_PROGNUM_OPT_PROCESS
  - HASP_PROGNUM_OPT_CLASSIC
  - HASP_PROGNUM_OPT_TS
  3 bits of the mask are reserved for future extensions and currently unused. Initialize them to zero.

  See Also:
    Constant Field Values

### HASP_PROGNUM_OPT_NO_LOCAL

    public static final long HASP_PROGNUM_OPT_NO_LOCAL

  "Prognum" option: disables local license search.

  See Also:
    Constant Field Values

### HASP_PROGNUM_OPT_NO_REMOTE

    public static final long HASP_PROGNUM_OPT_NO_REMOTE

  "Prognum" option: disables network license search.

  See Also:
    Constant Field Values

### HASP_PROGNUM_OPT_PROCESS

    public static final long HASP_PROGNUM_OPT_PROCESS

  "Prognum" option: sets session count of network licenses to "per process".

  See Also:
    Constant Field Values

### HASP_PROGNUM_OPT_CLASSIC

    public static final long HASP_PROGNUM_OPT_CLASSIC

  "Prognum" option: enables the API to access "classic" (HASP4 or earlier) keys.

  See Also:
    Constant Field Values

### HASP_PROGNUM_OPT_TS

    public static final long HASP_PROGNUM_OPT_TS

  "Prognum" option: ignores Terminal Services.

  See Also:
    Constant Field Values

### HASP_DEFAULT_FID

    public static final long HASP_DEFAULT_FID

  HASP default Feature ID. Present in every hardware key.

  See Also:
    Constant Field Values

### HASP_PROGNUM_DEFAULT_FID

    public static final long HASP_PROGNUM_DEFAULT_FID

  "Prognum" default Feature ID. Present in every HASP key.

  See Also:
    Constant Field Values

### HASP_MIN_BLOCK_SIZE

    public static final int HASP_MIN_BLOCK_SIZE

  Minimal block size for hasp_encrypt() and hasp_decrypt() functions.

  See Also:
    Constant Field Values

### HASP_MIN_BLOCK_SIZE_LEGACY

    public static final long HASP_MIN_BLOCK_SIZE_LEGACY

  Minimal block size for legacy functions hasp_legacy_encrypt() and hasp_legacy_decrypt().

  See Also:
    Constant Field Values

### HASP_FILEID_MAIN

    public static final int HASP_FILEID_MAIN

  HASP4 memory file: File ID for HASP4-compatible memory contents without FAS.

  See Also:
    Constant Field Values

### HASP_FILEID_LICENSE

    public static final long HASP_FILEID_LICENSE

  HASP4 FAS memory file: (Dummy) File ID for license data segment of memory contents.

  See Also:
    Constant Field Values

### HASP_FILEID_RW

    public static final long HASP_FILEID_RW

  File ID for HASP secure writable memory.

  See Also:
    Constant Field Values

### HASP_FILEID_RO

    public static final long HASP_FILEID_RO

  File ID for HASP secure read only memory.

  See Also:
    Constant Field Values

Constructor Detail

### Hasp

    public Hasp(long feature_id)

  Hasp constructor. For local "prognum" Features, concurrency is not handled and each login performs a decrement if it is a counting license.

  Network "prognum" Features only use the old HASP LM login logic, with all its limitations.

  Only concurrent usage of one server is supported (global server address).

  Parameters:
    `feature_id` - Unique identifier of the Feature. With "prognum" Features (see HASP_FEATURETYPE_MASK), 8 bits are reserved for legacy options (see HASP_PROGNUM_OPT_MASK, currently 5 bits are used):
    - only local
    - only remote
    - login is counted per process ID
    - disable terminal server check
    - enable access to old (HASP3/HASP4) keys

Method Detail

### getLastError

    public int getLastError()

  Returns the error that occurred in the last function call.

### login

    public boolean login(java.lang.String vendor_code)

  Logs in to a Feature. Establishes a session context.

  Parameters:
    `vendor_code` - The Vendor Code.
  Returns:
    true/false - indicates success or failure.
  See Also:
    `loginScope(java.lang.String, java.lang.String)`, `logout()`, `getLastError()`

### loginScope

    public boolean loginScope(java.lang.String scope,
                              java.lang.String vendor_code)

  Logs in to a Feature according to customizable search parameters. This function is an extended login function, where the search for the Feature can be restricted.

  Parameters:
    `scope` - The hasp_scope of the Feature search.
    `vendor_code` - The Vendor Code.
  Returns:
    true/false - indicates success or failure.
  See Also:
    `login(java.lang.String)`, `logout()`, `getLastError()`

### logout

    public boolean logout()

  Logs out from a session and frees all allocated resources for the session.

  Returns:
    true/false - indicates success or failure.
  See Also:
    `login(java.lang.String)`, `getLastError()`

### encrypt

    public boolean encrypt(byte[] buffer,
                           int length)

  Encrypts a buffer. This is the reverse operation of the decrypt() function.

  If the encryption fails (e.g. key removed during the process) the data buffer is unmodified.

  Parameters:
    `buffer` - The buffer to be encrypted.
    `length` - Size in bytes of the buffer to be encrypted (16 bytes minimum).
  Returns:
    true/false - indicates success or failure.
  See Also:
    `decrypt(byte[], int)`, `getLastError()`

### decrypt

    public boolean decrypt(byte[] buffer,
                           int length)

  Decrypts a buffer. This is the reverse operation of the encrypt() function.

  If the decryption fails (e.g. key removed during the process) the data buffer is unmodified.

  Parameters:
    `buffer` - The buffer to be decrypted.
    `length` - Size in bytes of the buffer to be decrypted (16 bytes minimum).
  Returns:
    true/false - indicates success or failure.
  See Also:
    `encrypt(byte[], int)`, `getLastError()`

### getInfo

    public java.lang.String getInfo(java.lang.String scope,
                                    java.lang.String format,
                                    java.lang.String vendor_code)

  Retrieves information about all system components. Acquires information about all system components. The programmer can choose the scope and output structure of the data. The function has a "scope" parameter that defines the scope using XML syntax.

  This function is not used in a login context, so it can be used in a generic "Monitor" application.

  Parameters:
    `scope` - XML definition of the information scope.
    `format` - XML definition of the output data structure.
    `vendor_code` - The Vendor Code.
  Returns:
    info The returned information (XML list).
  See Also:
    `getSessionInfo(java.lang.String)`, `getLastError()`

### getSessionInfo

    public java.lang.String getSessionInfo(java.lang.String format)

  Retrieves information regarding a session context.

  Parameters:
    `format` - XML definition of the output data structure.
  Returns:
    info The returned information (XML list).
  See Also:
    `getLastError()`

### read

    public boolean read(long fileid,
                        int offset,
                        int length,
                        byte[] buffer)

  Reads from the HASP key memory.

  Parameters:
    `fileid` - ID of the file to read (memory descriptor).
    `offset` - Position in the file.
    `length` - Number of bytes to be read from the file.
    `buffer` - The retrieved data.
  Returns:
    true/false - indicates success or failure.
  See Also:
    `getLastError()`, `write(long, int, int, byte[])`, `getSize(long)`

### write

    public boolean write(long fileid,
                         int offset,
                         int length,
                         byte[] buffer)

  Writes to the HASP key memory. Depending on the provided session handle (either logged into the default Feature or any other Feature), write access to the FAS memory (HASP_FILEID_LICENSE) is not permitted.

  Parameters:
    `fileid` - ID of the file to write (memory descriptor).
    `offset` - Position in the file.
    `length` - Number of bytes to write to the file.
    `buffer` - The data to write.
  Returns:
    true/false - indicates success or failure.
  See Also:
    `getLastError()`, `read(long, int, int, byte[])`, `getSize(long)`

### getSize

    public int getSize(long fileid)

  Retrieves the byte size of a memory file from a HASP key.

  Parameters:
    `fileid` - ID of the file to be queried.
  Returns:
    Size of the file.
  See Also:
    `getLastError()`, `read(long, int, int, byte[])`, `write(long, int, int, byte[])`

### update

    public java.lang.String update(java.lang.String update_data)

  Writes update information to a HASP key. The update BLOB contains all necessary data to perform the update: Where to write (to which HASP key), the necessary access data (Vendor Code) and the update itself.

  If requested by the update BLOB, the function returns an Acknowledge BLOB, which is signed/encrypted by the updated instance and contains proof that this update was successfully installed.

  Parameters:
    `update_data` - The complete update data.
  Returns:
    ack_data The acknowledged data (if requested).
  See Also:
    `getLastError()`

### getRealTimeClock

    public HaspTime getRealTimeClock()

  Reads the current time from a HASP Time key. Time values are returned as the number of seconds that have elapsed since Jan-01-1970 0:00:00 UTC.

  The general purpose of this function is to obtain reliable timestamps that are independent from the system clock.

  Returns:
    A HaspTime object.

### getVersion

    public HaspApiVersion getVersion(java.lang.String vendor_code)

  Reads the HASP API Version.

  Parameters:
    `vendor_code` - The Vendor Code.
  Returns:
    A HaspApiVersion object.
  See Also:
    `getLastError()`

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD