final int flag = (lastByte & 0xFF) >> 4;
final byte[] cookie = new byte[decoded.length - 1];
System.arraycopy(decoded, 0, cookie, 0, cookie.length);
switch(flag) {
case 0:
return new HSDescriptorCookie(CookieType.COOKIE_BASIC, cookie);
case 1:
return new HSDescriptorCookie(CookieType.COOKIE_STEALTH, cookie);
default:
throw new TorException("Illegal cookie descriptor with flag value: "+ flag);
}
}