private void reconstructTokenHeader()

in kerby-kerb/kerb-gssapi/src/main/java/org/apache/kerby/kerberos/kerb/gss/impl/GssTokenV1.java [269:291]


    private void reconstructTokenHeader(InputStream is, MessageProp prop) throws GSSException {
        try {
            if (is.read(commHeader) != commHeader.length
                    || is.read(encryptedSequenceNumber) != encryptedSequenceNumber.length
                    || is.read(checkSum) != checkSum.length) {
                throw new GSSException(GSSException.FAILURE, -1,
                        "Insufficient in reconstruct token header");
            }
            initTokenHeader(commHeader, prop);

            plainSequenceBytes = encryptor.encryptSequenceNumber(encryptedSequenceNumber, checkSum, false);
            byte dirc = isInitiator ? (byte) 0xFF : 0;
            // Hex 0 - sender is the context initiator, Hex FF - sender is the context acceptor
            if (!(plainSequenceBytes[4] == dirc && plainSequenceBytes[5] == dirc
                    && plainSequenceBytes[6] == dirc && plainSequenceBytes[7] == dirc)) {
                throw new GSSException(GSSException.BAD_MIC, -1,
                        "Corrupt token sequence for " + (tokenType == TOKEN_MIC_V1 ? "Mic" : "Wrap") + "TokenV1");
            }
        } catch (IOException e) {
            throw new GSSException(GSSException.FAILURE, -1,
                    "Error in reconstruct token header:" + e.getMessage());
        }
    }