com.sap.security.api.ticket
Class InfoUnit

java.lang.Object
  |
  +--com.sap.security.api.ticket.InfoUnit

public class InfoUnit
extends java.lang.Object

An InfoUnit is the basic data type for storing information in SAP logon tickets. You need to use it if you want to retrieve information from the ticket other than the those available by API calls like TicketVerifier.getUser(), TicketVerifier.isValid().

Format of InfoUnits on Disk:
LengthTypeName
1INT1ID of InfoUnit (see ID_xxxx)
2INT2Length n of Content in bytes
<INT2 bytes>see belowContent (Type depends on ID)

Types of InfoUnits used in SAP Logon Ticket:
IDTypeName
ID_USERCHARUser name
ID_CREATE_CLIENTCHARSystemID of issuing System
ID_CREATE_NAMECHARSystemID of issuing System
ID_CREATE_TIMECHARCreation time of Ticket as String "yyyymmddhhmm"
ID_VALID_TIMEINT4Valid time (hours)
ID_VALID_TIME_MININT4Valid time (minutes)
ID_RFCCHARRFC Ticket
ID_FLAGSRAWFlags
ID_SIGNATURERAWPKCS#7 Signature
ID_LANGUAGECHARdefault language of the user
ID_USER_UTFUTF8user name (utf-8 encoded)
ID_AUTH_TYPECHARone letter indicating how the user was authenticated (e.g. NT domain authentication)
ID_AUTHSCHEMEUTF8Specifies which autscheme has been satisfied during logon

The values from 0x20 to 0x40 are reserved for additional user id. Currently, only 0x20 is used (by a portal user id which might differ from the SAP system user id). For the above identifiers the data types are as follows. INT4 denotes a 4-byte integer. RAW denotes a byte array, UTF8 denotes UTF-8 encoding. CHAR means that the infounit's content is a string value, encoded using an SAP codepage that you can get from the ticket. In order to get a java.lang.String object, please use one of the following methods:

By default, the tickets are created with SAP codepage 1100 (this is the equivalent of ISO 8859-1). However, you might get a ticket that has been created with a different codepage. For this case, here's a list of the most commonly used codepages:
SAP codepage numbercorresponding non-SAP codepage
4110UTF8
1100ISO8859_1
1140ISO8859_1
1401ISO8859_2
1500ISO8859_5
1610ISO8859_9
1700ISO8859_7
1800ISO8859_8
1900ISO8859_4
8200ISO2022JP
8700ISO8859_4
0120Cp500
1103Cp850
1160windows-1252
1404Cp1250
1504Cp1251
1614Cp1254
1704Cp1253
1804Cp1255
1904Cp1257
8604Cp874
8704Cp1256
8000SJIS
8100EUC_JP
8300Big5
8600TIS620


Field Summary
static java.util.HashMap codepageEncoding
          Map used to convert an SAP codepage into a ISO or window codepage.
static int ID_AUTH_TYPE
          see here for details.
static int ID_AUTHSCHEME
          see here for details.
static int ID_CREATE_CLIENT
          see here for details.
static int ID_CREATE_CLIENT_UTF
          see here for details.
static int ID_CREATE_NAME
          see here for details.
static int ID_CREATE_NAME_UTF
          see here for details.
static int ID_CREATE_TIME
          see here for details.
static int ID_CREATE_TIME_UTF
          see here for details.
static int ID_FLAGS
          see here for details.
static int ID_LANGUAGE
          see here for details.
static int ID_LANGUAGE_UTF
          see here for details.
static int ID_RFC
          see here for details.
static int ID_SIGNATURE
          see here for details.
static int ID_USER
          see here for details.
static int ID_USER_UTF
          see here for details.
static int ID_VALID_TIME
          see here for details.
static int ID_VALID_TIME_MIN
          see here for details.
 
Constructor Summary
InfoUnit(java.io.InputStream in, int id, int len)
          Utility method.
InfoUnit(int id, byte[] data)
          Utility method.
 
Method Summary
static int bytesToInt(byte[] buffer)
          Transform a byte array into an int.
static int bytesToInt(byte[] buffer, int offset, int length)
          Transform part of a byte array to an integer.
static java.lang.String bytesToString(byte[] buffer, int offset, int length, java.lang.String encoding)
          Converts a byte array into a string.
static java.lang.String bytesToString(byte[] buffer, java.lang.String encoding)
          Converts a byte array into a string.
 byte[] getContent()
          Gets the content of an info unit.
 int getID()
          Get the ID of this InfoUnit.
 int getInt()
          Gets the content of an info unit as integer.
 java.lang.String getString(java.lang.String encoding)
          Get the Content of this InfoUnit as String.
static byte[] IntToBytes(int i)
          Transforms an integer into a byte array.
static byte[] jcharToSAPCP(java.lang.String source, java.lang.String SAPCodepage)
          Converts a java String to a byte array.
static byte[] jcharToUTF8(java.lang.String source)
          Converts a java String to a byte array.
static InfoUnit readInfoUnit(java.io.InputStream in)
          Utility method.
static byte[] readRaw(java.io.InputStream in, int n)
          Utility method.
 void writeTo(java.io.OutputStream out)
          Utility method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_USER

public static final int ID_USER
see here for details.

ID_CREATE_CLIENT

public static final int ID_CREATE_CLIENT
see here for details.

ID_CREATE_NAME

public static final int ID_CREATE_NAME
see here for details.

ID_CREATE_TIME

public static final int ID_CREATE_TIME
see here for details.

ID_VALID_TIME

public static final int ID_VALID_TIME
see here for details.

ID_RFC

public static final int ID_RFC
see here for details.

ID_VALID_TIME_MIN

public static final int ID_VALID_TIME_MIN
see here for details.

ID_FLAGS

public static final int ID_FLAGS
see here for details.

ID_SIGNATURE

public static final int ID_SIGNATURE
see here for details.

ID_LANGUAGE

public static final int ID_LANGUAGE
see here for details.

ID_USER_UTF

public static final int ID_USER_UTF
see here for details.

ID_CREATE_CLIENT_UTF

public static final int ID_CREATE_CLIENT_UTF
see here for details.

ID_CREATE_NAME_UTF

public static final int ID_CREATE_NAME_UTF
see here for details.

ID_CREATE_TIME_UTF

public static final int ID_CREATE_TIME_UTF
see here for details.

ID_LANGUAGE_UTF

public static final int ID_LANGUAGE_UTF
see here for details.

ID_AUTHSCHEME

public static final int ID_AUTHSCHEME
see here for details.

ID_AUTH_TYPE

public static final int ID_AUTH_TYPE
see here for details.

codepageEncoding

public static java.util.HashMap codepageEncoding
Map used to convert an SAP codepage into a ISO or window codepage. For use by the java method String.getBytes(java.lang.String)
Constructor Detail

InfoUnit

public InfoUnit(java.io.InputStream in,
                int id,
                int len)
         throws java.io.IOException
Utility method.

InfoUnit

public InfoUnit(int id,
                byte[] data)
Utility method.
Method Detail

getID

public int getID()
Get the ID of this InfoUnit. See identifiers
Returns:
the identifier of the info unit.

getContent

public byte[] getContent()
Gets the content of an info unit. The contents are returned as a byte array.
Returns:
content as byte array.

getString

public java.lang.String getString(java.lang.String encoding)
                           throws java.io.UnsupportedEncodingException
Get the Content of this InfoUnit as String.
Parameters:
encoding - java codepage for encoding
Throws:
java.io.UnsupportedEncodingException - if the encoding is unknown

getInt

public int getInt()
Gets the content of an info unit as integer. This call makes only sense for those info units whose type is INT4 (see table).
Returns:
info unit's integer value

writeTo

public void writeTo(java.io.OutputStream out)
             throws java.io.IOException
Utility method.

readInfoUnit

public static InfoUnit readInfoUnit(java.io.InputStream in)
                             throws java.io.IOException
Utility method.

bytesToInt

public static int bytesToInt(byte[] buffer)
Transform a byte array into an int. Makes only sense for units of type INT4.
Parameters:
buffer - byte array of length 4 from an info unit

bytesToInt

public static int bytesToInt(byte[] buffer,
                             int offset,
                             int length)
Transform part of a byte array to an integer. Same as bytesToInt(byte[]) but with a byte array region instead of an entire byte array.
Parameters:
buffer - byte array
offset - offset into the array
length - should be equal to 4

IntToBytes

public static byte[] IntToBytes(int i)
Transforms an integer into a byte array. The int is encoded as an platform independant byte array. This function is the counterpart of bytesToInt(byte[])
Parameters:
i - int to convert to
Returns:
byte array

bytesToString

public static java.lang.String bytesToString(byte[] buffer,
                                             java.lang.String encoding)
                                      throws java.io.UnsupportedEncodingException
Converts a byte array into a string. The specified encoding is used.
Parameters:
buffer - encoded string
encoding - used encoding This parameter will be passed to the InputStreamReader#InputStreamReader(InputStream,String) constructor. See also TicketVerifier.getCodepage() and encodings.
Throws:
java.io.UnsupportedEncodingException - if the encoding is unknown

bytesToString

public static java.lang.String bytesToString(byte[] buffer,
                                             int offset,
                                             int length,
                                             java.lang.String encoding)
                                      throws java.io.UnsupportedEncodingException
Converts a byte array into a string. Same as bytesToString(byte[], String) but with a byte array region instead of an entire byte array.
Throws:
java.io.UnsupportedEncodingException - if the encoding is unknown

readRaw

public static byte[] readRaw(java.io.InputStream in,
                             int n)
                      throws java.io.IOException
Utility method.

jcharToSAPCP

public static byte[] jcharToSAPCP(java.lang.String source,
                                  java.lang.String SAPCodepage)
                           throws java.io.UnsupportedEncodingException,
                                  java.io.IOException
Converts a java String to a byte array. The specified SAP codepage is used as encoding. (This is the counter part of bytesToString(byte[], String)).

jcharToUTF8

public static byte[] jcharToUTF8(java.lang.String source)
                          throws java.io.UnsupportedEncodingException,
                                 java.io.IOException
Converts a java String to a byte array. Simply calls return jcharToSAPCP (source, "4110"); see jcharToSAPCP(String, String).


Copyright © 2002 SAP AG All Rights Reserved.