000022335 - How to make IUniqueIdentifier objects accessible to Web page

Document created by RSA Customer Support Employee on Jun 16, 2016Last modified by RSA Customer Support Employee on Apr 21, 2017
Version 2Show Document
  • View in full screen mode

Article Content

Article Number000022335
Applies ToRSA ClearTrust 5.0.1 Administrative Java API
IssueHow to make IUniqueIdentifier objects accessible to Web page
CauseClearTrust objects are referenced as IUniqueIdentifier objects rather than a Java primitive type such as an Integer key. Because IUniqueIdentifier objects cannot be directly displayed on a Web page or printed, an application task of pre-generating a list of items for a user to select, such that the selected item may be retrieved is not straight forward.

The following sequence will not work on keys that are objects, but will only work primitive types (e.g. integer, string, dword, etc.)

        Print list of possible items (keys)
        Let end-user select one item
        Retrieve all data from database based on select key

A common use might be is displaying a selection on an HTML page (perhaps a list of peoples UserID values)

Due to the nature of the data that must be stored in ClearTrust the IUniqueIdentifier (see Javadoc pages for more specific information) is used to guarantee uniqueness, this might be likened to simple front end to a database with multiple, combined, indexes.
ResolutionThe IUniqueIdentifier object is serializable. This means that it will allow itself to be stored and then retrieved later for some purpose.  

To allow a IUniqueIdentifier to be represented on an HTML page, you can serialize the object into a stream of Base64 characters. Then when deserialization takes place have the streaming object do the Base64 decode hence the binary object would be instantiated.

For example, to store the object:

        /*  sample code to obtain an object */
        ISparseData userlist = serverProxy.getUsers();
             IUser user=(IUser)userlist.getByName("jdoe");
             IUniqueIdentifier id=user.getUniqueIdentifier();

        /* Use a Java class that extends java.io.ByteArrayOutputStream to convert the streamed object to Base64 */
        /* note the Base64OutputStream needs to be written */

             Base64OutputStream stream = new Base64OutputStream();
             ObjectOutputStream output = new ObjectOutputStream(stream);
             output.writeObject(id);

The output streaming object could not be interrogated to obtain the Base64 representation which could be transmitted on an HTML page, for example:

        String bstring = stream.encoded();
             System.out.println(bstring);

Using this data to create an input stream allows the original binary object to be rebuilt where the Java class used would be a class extending java.io.ByteArrayInputStream
Legacy Article IDa19020

Attachments

    Outcomes