public static byte[] intToTwoBytes(int i) throws SAML2Exception {
  if (i < 0 || i > 65535) {
    debug.error("SAML2Utils.intToTwoBytes: wrong index value range.");
    throw new SAML2Exception(bundle.getString("wrongInput"));
  }
  String hexStr=Integer.toHexString(i);
  int len=hexStr.length();
  String norm=null;
  if (len > 4) {
    norm=hexStr.substring(0,4);
  }
 else {
switch (len) {
case 1:
      norm="000" + hexStr;
    break;
case 2:
  norm="00" + hexStr;
break;
case 3:
norm="0" + hexStr;
break;
default :
norm=hexStr;
}
}
byte[] bytes=hexStringToByteArray(norm);
return bytes;
}

public static byte [ ] intToTwoBytes ( int i ) throws SAML2Exception { if ( i < 0 || i > 65535 ) { debug . error ( "SAML2Utils.intToTwoBytes: wrong index value range." ) ; throw new SAML2Exception ( bundle . getString ( "wrongInput" ) ) ; } String hexStr = Integer . toHexString ( i ) ; int len = hexStr . length ( ) ; String norm = null ; if ( len > 4 ) { norm = hexStr . substring ( 0 , 4 ) ; } else { switch ( len ) { case 1 : norm = "000" + hexStr ; break ; case 2 : norm = "00" + hexStr ; break ; case 3 : norm = "0" + hexStr ; break ; default : norm = hexStr ; } } byte [ ] bytes = hexStringToByteArray ( norm ) ; return bytes ; }
converts integer to byte array .
