@Test(expected = IllegalArgumentException.class) public void testEncodeLengthNegative() throws Exception { SecurityTokenUtils.encodeLength(-1); }
static byte[] encodeLength(int len) { if (len < 0) { throw new IllegalArgumentException("length is negative"); } else if (len >= 16777216) { throw new IllegalArgumentException("length is too big: " + len); } byte[] res; if (len < 128) { res = new byte[1]; res[0] = (byte) len; } else if (len < 256) { res = new byte[2]; res[0] = -127; res[1] = (byte) len; } else if (len < 65536) { res = new byte[3]; res[0] = -126; res[1] = (byte) (len / 256); res[2] = (byte) (len % 256); } else { res = new byte[4]; res[0] = -125; res[1] = (byte) (len / 65536); res[2] = (byte) (len / 256); res[3] = (byte) (len % 256); } return res; }
SecurityTokenUtils { static byte[] encodeLength(int len) { if (len < 0) { throw new IllegalArgumentException("length is negative"); } else if (len >= 16777216) { throw new IllegalArgumentException("length is too big: " + len); } byte[] res; if (len < 128) { res = new byte[1]; res[0] = (byte) len; } else if (len < 256) { res = new byte[2]; res[0] = -127; res[1] = (byte) len; } else if (len < 65536) { res = new byte[3]; res[0] = -126; res[1] = (byte) (len / 256); res[2] = (byte) (len % 256); } else { res = new byte[4]; res[0] = -125; res[1] = (byte) (len / 65536); res[2] = (byte) (len / 256); res[3] = (byte) (len % 256); } return res; } }
SecurityTokenUtils { static byte[] encodeLength(int len) { if (len < 0) { throw new IllegalArgumentException("length is negative"); } else if (len >= 16777216) { throw new IllegalArgumentException("length is too big: " + len); } byte[] res; if (len < 128) { res = new byte[1]; res[0] = (byte) len; } else if (len < 256) { res = new byte[2]; res[0] = -127; res[1] = (byte) len; } else if (len < 65536) { res = new byte[3]; res[0] = -126; res[1] = (byte) (len / 256); res[2] = (byte) (len % 256); } else { res = new byte[4]; res[0] = -125; res[1] = (byte) (len / 65536); res[2] = (byte) (len / 256); res[3] = (byte) (len % 256); } return res; }  }
SecurityTokenUtils { static byte[] encodeLength(int len) { if (len < 0) { throw new IllegalArgumentException("length is negative"); } else if (len >= 16777216) { throw new IllegalArgumentException("length is too big: " + len); } byte[] res; if (len < 128) { res = new byte[1]; res[0] = (byte) len; } else if (len < 256) { res = new byte[2]; res[0] = -127; res[1] = (byte) len; } else if (len < 65536) { res = new byte[3]; res[0] = -126; res[1] = (byte) (len / 256); res[2] = (byte) (len % 256); } else { res = new byte[4]; res[0] = -125; res[1] = (byte) (len / 65536); res[2] = (byte) (len / 256); res[3] = (byte) (len % 256); } return res; }  static byte[] attributesFromSecretKey(KeyType slot, CanonicalizedSecretKey secretKey,
            KeyFormat formatForKeyType); static byte[] createRSAPrivKeyTemplate(RSAPrivateCrtKey secretKey, KeyType slot,
            RSAKeyFormat format); static byte[] createECPrivKeyTemplate(ECPrivateKey secretKey, ECPublicKey publicKey, KeyType slot,
            ECKeyFormat format); }
SecurityTokenUtils { static byte[] encodeLength(int len) { if (len < 0) { throw new IllegalArgumentException("length is negative"); } else if (len >= 16777216) { throw new IllegalArgumentException("length is too big: " + len); } byte[] res; if (len < 128) { res = new byte[1]; res[0] = (byte) len; } else if (len < 256) { res = new byte[2]; res[0] = -127; res[1] = (byte) len; } else if (len < 65536) { res = new byte[3]; res[0] = -126; res[1] = (byte) (len / 256); res[2] = (byte) (len % 256); } else { res = new byte[4]; res[0] = -125; res[1] = (byte) (len / 65536); res[2] = (byte) (len / 256); res[3] = (byte) (len % 256); } return res; }  static byte[] attributesFromSecretKey(KeyType slot, CanonicalizedSecretKey secretKey,
            KeyFormat formatForKeyType); static byte[] createRSAPrivKeyTemplate(RSAPrivateCrtKey secretKey, KeyType slot,
            RSAKeyFormat format); static byte[] createECPrivKeyTemplate(ECPrivateKey secretKey, ECPublicKey publicKey, KeyType slot,
            ECKeyFormat format);  }