1
1
/*
2
- * Copyright (c) 2016, 2019 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2016, 2021 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
52
52
import java .util .ArrayList ;
53
53
import java .util .Arrays ;
54
54
import java .util .Base64 ;
55
+ import java .util .HexFormat ;
55
56
import java .util .List ;
56
57
import java .util .Objects ;
57
58
import java .util .Random ;
@@ -582,11 +583,6 @@ String getQoP(String defval) {
582
583
583
584
// Code stolen from DigestAuthentication:
584
585
585
- private static final char charArray [] = {
586
- '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' ,
587
- '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f'
588
- };
589
-
590
586
private static String encode (String src , char [] passwd , MessageDigest md ) {
591
587
try {
592
588
md .update (src .getBytes ("ISO-8859-1" ));
@@ -601,15 +597,7 @@ private static String encode(String src, char[] passwd, MessageDigest md) {
601
597
Arrays .fill (passwdBytes , (byte )0x00 );
602
598
}
603
599
byte [] digest = md .digest ();
604
-
605
- StringBuilder res = new StringBuilder (digest .length * 2 );
606
- for (int i = 0 ; i < digest .length ; i ++) {
607
- int hashchar = ((digest [i ] >>> 4 ) & 0xf );
608
- res .append (charArray [hashchar ]);
609
- hashchar = (digest [i ] & 0xf );
610
- res .append (charArray [hashchar ]);
611
- }
612
- return res .toString ();
600
+ return HexFormat .of ().formatHex (digest );
613
601
}
614
602
615
603
public static String computeDigest (boolean isRequest ,
0 commit comments