void load(KeytabInputStream kis, int version, int entrySize) throws IOException { int bytesLeft = kis.available(); this.principal = kis.readPrincipal(version); this.timestamp = kis.readTime(); this.kvno = kis.readByte(); this.key = kis.readKey(); int entryBytesRead = bytesLeft - kis.available(); // Some implementations of Kerberos recognize a 32-bit key version at the end of an entry, if record length is // at least 4 bytes longer than the entry and the value of those 32 bits is not 0. If present, this key version // supersedes the 8-bit key version. if (entryBytesRead + 4 <= entrySize) { int tmp = kis.readInt(); if (tmp != 0) { this.kvno = tmp; } } else if (entryBytesRead != entrySize) { throw new IOException( String.format("Bad input stream with less data read [%d] than expected [%d] for keytab entry.", entryBytesRead, entrySize)); } }
void load(KeytabInputStream kis, int version, int entrySize) throws IOException { int bytesLeft = kis.available(); this.principal = kis.readPrincipal(version); this.timestamp = kis.readTime(); this.kvno = kis.readByte(); this.key = kis.readKey(); int entryBytesRead = bytesLeft - kis.available(); // Some implementations of Kerberos recognize a 32-bit key version at the end of an entry, if record length is // at least 4 bytes longer than the entry and the value of those 32 bits is not 0. If present, this key version // supersedes the 8-bit key version. if (entryBytesRead + 4 <= entrySize) { int tmp = kis.readInt(); if (tmp != 0) { this.kvno = tmp; } } else if (entryBytesRead != entrySize) { throw new IOException( String.format("Bad input stream with less data read [%d] than expected [%d] for keytab entry.", entryBytesRead, entrySize)); } }