public static int twoBytesToInt(byte[] bytes) throws SAML2Exception {
  if (bytes == null || bytes.length != 2) {
    debug.error("SAML2Utils.twoBytesToInt: input is null or length is " + "not 2.");
    throw new SAML2Exception(bundle.getString("wrontInput"));
  }
  String str0=Integer.toHexString(bytes[0]);
  int len0=str0.length();
  String norm0=null;
  if (len0 > 2) {
    norm0=str0.substring(len0 - 2,len0);
  }
 else {
    norm0=str0;
  }
  String str1=Integer.toHexString(bytes[1]);
  int len1=str1.length();
  String norm1=null;
  if (len1 > 2) {
    norm1=str1.substring(len1 - 2,len1);
  }
 else   if (len1 == 1) {
    norm1="0" + str1;
  }
 else {
    norm1=str1;
  }
  String wholeHexStr=norm0 + norm1;
  int i=Integer.parseInt(wholeHexStr,16);
  return i;
}

public static int twoBytesToInt ( byte [ ] bytes ) throws SAML2Exception { if ( bytes == null || bytes . length != 2 ) { debug . error ( "SAML2Utils.twoBytesToInt: input is null or length is " + "not 2." ) ; throw new SAML2Exception ( bundle . getString ( "wrontInput" ) ) ; } String str0 = Integer . toHexString ( bytes [ 0 ] ) ; int len0 = str0 . length ( ) ; String norm0 = null ; if ( len0 > 2 ) { norm0 = str0 . substring ( len0 - 2 , len0 ) ; } else { norm0 = str0 ; } String str1 = Integer . toHexString ( bytes [ 1 ] ) ; int len1 = str1 . length ( ) ; String norm1 = null ; if ( len1 > 2 ) { norm1 = str1 . substring ( len1 - 2 , len1 ) ; } else if ( len1 == 1 ) { norm1 = "0" + str1 ; } else { norm1 = str1 ; } String wholeHexStr = norm0 + norm1 ; int i = Integer . parseInt ( wholeHexStr , 16 ) ; return i ; }
converts two bytes to an integer .
