Skip to content

Commit

Permalink
Merge pull request #653 from KostasTsiounis/krb_debug
Browse files Browse the repository at this point in the history
Get byte array from DerValue without using InputStream
  • Loading branch information
keithc-ca committed May 8, 2023
2 parents 2071ecc + d388137 commit b8f0eb7
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,23 @@ protected void init(DerValue encoding, int req_type)
" req type is " + req_type);

System.out.println(">>> KDCRep: Message in bytes is =>");
byte[] dataBytes = encoding.getDataBytes();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < dataBytes.length; i++) {
if ((i % 16) == 0) {
sb.append(String.format("%06X", i));
byte[] dataBytes = encoding.getData().toByteArray();
if (dataBytes != null) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < dataBytes.length; i++) {
if ((i % 16) == 0) {
sb.append(String.format("%06X", i));
}
sb.append(String.format(" %02X", dataBytes[i] & 0xFF));
if ((i % 16) == 15) {
System.out.println(sb.toString());
sb.setLength(0);
}
}
sb.append(String.format(" %02X", dataBytes[i] & 0xFF));
if ((i % 16) == 15) {
if (sb.length() > 0) {
System.out.println(sb.toString());
sb.setLength(0);
}
}
if (sb.length() > 0) {
System.out.println(sb.toString());
}
}
throw new Asn1Exception(Krb5.ASN1_BAD_ID);
}
Expand Down

0 comments on commit b8f0eb7

Please sign in to comment.