lengthBytes[i];
//9. Copy the content bytes to the finalBytes array just after the length bytes.
byte tempString[] = generalStringContent.getBytes();
for (int j=lengthBytesCount+1; j<totalBytesCount; j++)
finalBytes[j] = tempString[j-(lengthBytesCount+1)];
//10. Return the finalBytes array.
return finalBytes;
}//getGeneralStringBytes
賠汽 5. getOctetStringBytes() 圭隈
public byte[] getOctetStringBytes (byte[] octetStringContents)
{
//1. Declare a byte array named finalBytes, which will
// hold all the bytes of the ASN.1 byte array representation.
byte finalBytes[];
//2. Calculate the number of bytes required to hold the
// contents part of the ASN.1 byte array representation.
int contentBytesCount = octetStringContents.length;
//3. Use the getLengthBytes() method of Listing 3 to author
// the length bytes. Store the length bytes in
// an array named lengthBytes.
byte lengthBytes[] = getLengthBytes(contentBytesCount );
//4. Get the number of bytes in the lengthBytes array.
int lengthBytesCount = lengthBytes.length;
//5. Calculate the number of bytes required to hold the complete
// ASN.1 byte array representation (the sum total of the number
// of tag bytes, length bytes, and content bytes).
// Store the number of bytes in a variable named totalBytesCount.
int totalBytesCount = 1 + lengthBytesCount + contentBytesCount ;
//6. Instantiate the finalBytes array to totalBytesCount size.
finalBytes = new byte[totalBytesCount];
//7. Copy the tag byte at the start of the finalBytes array.
finalBytes[0] = (byte)0x04;
//8. Copy the length bytes from the lengthBytes array to the
// finalBytes array just after the tag byte.
for (int i=0; i < lengthBytes.length; i++)
finalBytes[i+1] = lengthBytes[i];
//9. Copy the content bytes to the finalBytes array
// just after the length bytes.
for (int j=lengthBytesCount+1; j<totalBytesCount; j++)
finalBytes[j] = octetStringContents[j-(lengthBytesCount+1)];
//10. Return the finalBytes array.
return finalBytes;
}//getOctetStringBytes
喘Kerberos葎J2ME哘喘殻會貧迄?及2何蛍 - 伏撹匯倖Kerberos同象萩箔(6)
扮寂:2011-08-05 IBM Faheem Khan
賠汽 6. getBitStringBytes() 圭隈
public byte[] getBitStringBytes (byte[] content)
{
//1. Declare a byte array named finalBytes, which will
// hold all the bytes of the ASN.1 byte array representation.
byte finalBytes[];
|