for (int i = 0; i < numBytes; i++) {
inMsgTmp.write(inStream.read());
}
} catch (IOException e) {
throw new GSSException(GSSException.FAILURE);
}
inMsg = inMsgTmp.toByteArray();
/* copy input message to gss_buffer_desc for native unwrap() */
if (inMsg != null) {
gsswrapper.setDescArray(inputMsg, inMsg);
inputMsg.setLength(inMsg.length);
}
maj_status = gsswrapper.gss_unwrap(min_status, this.internGSSCtx,
inputMsg, outputMsg, conf_state, qop_state);
if (maj_status != gsswrapper.GSS_S_COMPLETE) {
throw new GSSExceptionImpl((int) maj_status, (int) min_status[0]);
} else {
/* set supplementary info */
if ((maj_status & gsswrapper.GSS_S_DUPLICATE_TOKEN) != 0)
tokDup = true;
if ((maj_status & gsswrapper.GSS_S_OLD_TOKEN) != 0)
tokOld = true;
if ((maj_status & gsswrapper.GSS_S_UNSEQ_TOKEN) != 0)
tokUnseq = true;
if ((maj_status & gsswrapper.GSS_S_GAP_TOKEN) != 0)
tokGap = true;
msgProp.setSupplementaryStates(tokDup, tokOld, tokUnseq, tokGap,
(int)min_status[0], "");
}
/* set the actual privacy and conf state applied for caller to use */
if (conf_state[0] == 0) {
msgProp.setPrivacy(false);
} else {
msgProp.setPrivacy(true);
}
msgProp.setQOP((int) qop_state[0]);
/* get the byte[] from our outputMsg, copy back to OutputStream */
if (outputMsg.getLength() > 0) {
byte[] temp_msg = new byte[(int) outputMsg.getLength()];
temp_msg = gsswrapper.getDescArray(outputMsg);
gsswrapper.gss_release_buffer(min_status, outputMsg);
try {
outStream.write(temp_msg);
} catch (IOException e) {
throw new GSSException(GSSException.FAILURE);
}
}
/* release native structures */
gsswrapper.gss_release_buffer(min_status, outputMsg);