AXL Software™

com.theorem.tacacs.util
Class Util

Object
  extended byUtil

public final class Util
extends Object

TACACS++ utilities class.


Constructor Summary
Util()
           
 
Method Summary
static boolean cmp(byte[] a, byte[] b)
          Compare two byte arrays.
static boolean cmp(byte[] a, int startA, byte[] b, int startB, int length)
          Compare two byte arrays over a region.
static boolean isPrintableASCII(byte[] b, int start, int length)
          Determine if a byte array is printable (eg ASCII-printable).
static String toASCII(byte[] b)
          Convert a byte array to a string using ASCII encoding.
static byte[] toASCII(String s)
          Convert a string to bytes encoded using ASCII, the TACACS+ protocol standard encoding.
static String toHexString(byte[] buf)
          Convert a byte buffer to a hex string.
static String toHexString(byte[] buf, int start, int length)
          Convert a byte buffer to a hex string.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

toASCII

public static byte[] toASCII(String s)
Convert a string to bytes encoded using ASCII, the TACACS+ protocol standard encoding. In the event that US-ASCII is unavailable (highly unlikely) the encoding will be the platform's default encoding.

Parameters:
s - String to convert to a ASCII byte array.
Returns:
ASCII byte array.

toASCII

public static String toASCII(byte[] b)
Convert a byte array to a string using ASCII encoding. In the event that US-ASCII is unavailable (highly unlikely) the encoding will be the platform's default encoding.

Parameters:
b - Byte array to convert.
Returns:
String.

toHexString

public static String toHexString(byte[] buf)
Convert a byte buffer to a hex string.

Parameters:
buf - Byte array.
Returns:
Hexadecimal representation.

toHexString

public static String toHexString(byte[] buf,
                                 int start,
                                 int length)
Convert a byte buffer to a hex string.

Parameters:
buf - Byte array.
start - Start position in array.
length - Number of bytes to display.
Returns:
Hexadecimal representation.

cmp

public static boolean cmp(byte[] a,
                          byte[] b)
Compare two byte arrays.

Parameters:
a - array a
b - array b
Returns:
true if they're the same.

cmp

public static boolean cmp(byte[] a,
                          int startA,
                          byte[] b,
                          int startB,
                          int length)
Compare two byte arrays over a region.

Parameters:
a - Array A.
startA - The start position for comparing A.
b - Array B.
startB - The start position for comparing B.
length - Length of region.
Returns:
true if the comparison succeeded.

isPrintableASCII

public static boolean isPrintableASCII(byte[] b,
                                       int start,
                                       int length)
Determine if a byte array is printable (eg ASCII-printable).

Parameters:
b - Bytes to test.
start - start position.
length - Length to test.
Returns:
true if printable.

AXL Software™

Submit a bug report or feature request

Copyright 1998-2002 AXL Software™ PO Box 97, Viola, Delaware 19979, U.S.A. All Rights Reserved.