// 1. parse stream
InputStream ins = new ByteArrayInputStream(input);
DerValue v = new DerValue(ins);
Asserts.assertEQ(new String(v.getOctetString()), "abcd");
if (indefinite) { // Trailing bytes might be consumed by the conversion but can // be found in DerValue "after end".
Field buffer = DerValue.class.getDeclaredField("buffer");
Field end = DerValue.class.getDeclaredField("end");
buffer.setAccessible(true);
end.setAccessible(true); int bufferLen = ((byte[])buffer.get(v)).length; int endPos = end.getInt(v); // Data "after end": bufferLen - endPos // Data remained in stream: ins.available()x`
Asserts.assertEQ(bufferLen - endPos + ins.available(), 8);
} else { // Trailing bytes remain in the stream for definite length
Asserts.assertEQ(ins.available(), 8);
}
// 3. Parse full byte array
Utils.runAndCheckException(() -> new DerValue(input),
e -> Asserts.assertTrue(e instanceof IOException
&& e.getMessage().equals("extra data at the end")));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.