我们正在运行一个使用护照进行身份验证的Node / Express应用程序,我们希望在用户登录时进行记录。这是我们可以放入@Override
public byte[] deserialize(InputStream inputStream) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("Available to read:" + inputStream.available());
}
byte[] header = new byte[2];
header[0] = (byte) inputStream.read();
if (header[0] < 0) {
throw new SoftEndOfStreamException("Stream closed between payloads");
}
header[1] = (byte) inputStream.read();
if (header[1] < 0) {
checkClosure(-1);
}
ByteBuffer headerBB = ByteBuffer.wrap(header);
int val = headerBB.getShort();
byte[] length = new byte[val];
for (int i = 0; i < val; i++) {
length[i] = (byte) inputStream.read();
}
headerBB = ByteBuffer.wrap(length);
int messageLength;
if (val == 2) {
messageLength = headerBB.getShort();
}
else if (val == 4) {
messageLength = headerBB.getInt();
}
else {
throw new IOException("Unexpected count of bytes that holds message length");
}
byte[] answer = new byte[messageLength];
for (int i = 0; i < messageLength; i++) {
int bite = inputStream.read();
if (bite < 0) {
checkClosure(-1);
}
answer[i] = (byte) bite;
}
ByteBuffer b = ByteBuffer.allocate(2 + val + messageLength);
b.put(header);
b.put(length);
b.put(answer);
return b.array();
}
的内容吗?它必须进入我们的回调吗?有没有办法从Strategy
获得它?