15
15
*/
16
16
package com .couchbase .mock .security .sasl ;
17
17
18
- import com .couchbase .mock .util .Base64 ;
19
-
20
18
import javax .crypto .Mac ;
21
19
import javax .crypto .SecretKey ;
22
20
import javax .crypto .spec .SecretKeySpec ;
33
31
import java .security .MessageDigest ;
34
32
import java .security .NoSuchAlgorithmException ;
35
33
import java .security .SecureRandom ;
34
+ import java .util .Base64 ;
36
35
import java .util .HashMap ;
37
36
import java .util .Map ;
38
37
@@ -89,7 +88,7 @@ public ShaSaslServer(CallbackHandler cbh, int sha) throws NoSuchAlgorithmExcepti
89
88
byte [] randomNonce = new byte [21 ];
90
89
SecureRandom random = new SecureRandom ();
91
90
random .nextBytes (randomNonce );
92
- serverNonce = Base64 .encode (randomNonce );
91
+ serverNonce = new String ( Base64 .getEncoder (). encode (randomNonce ) );
93
92
iterationCount = 4096 ;
94
93
}
95
94
@@ -154,10 +153,10 @@ private byte[] evaluateClientFinalMessage(byte[] response) {
154
153
155
154
StringWriter writer = new StringWriter ();
156
155
writer .append ("v=" );
157
- writer .append (Base64 .encode (serverSignature ));
156
+ writer .append (new String ( Base64 .getEncoder (). encode (serverSignature ) ));
158
157
159
158
// validate the client proof to see if we're getting the same value...
160
- String myClientProof = Base64 .encode (getClientProof ());
159
+ String myClientProof = new String ( Base64 .getEncoder (). encode (getClientProof () ));
161
160
if (!myClientProof .equals (attributes .get ("p" ))) {
162
161
writer .append (",e=failed" );
163
162
}
@@ -206,7 +205,7 @@ private byte[] evaluateClientFirstMessage(byte[] response) throws SaslException
206
205
throw new IllegalArgumentException ("username and client nonce is mandatory in clientFirstMessageBare" );
207
206
}
208
207
209
- salt = Base64 .decode ("QSXCR+Q6sek8bf92" ). getBytes ( );
208
+ salt = Base64 .getDecoder (). decode ("QSXCR+Q6sek8bf92" );
210
209
generateSaltedPassword ();
211
210
212
211
String nonce = clientNonce + serverNonce ;
@@ -216,7 +215,7 @@ private byte[] evaluateClientFirstMessage(byte[] response) throws SaslException
216
215
writer .append ("r=" );
217
216
writer .append (nonce );
218
217
writer .append (",s=" );
219
- writer .append (Base64 .encode (salt ));
218
+ writer .append (new String ( Base64 .getEncoder (). encode (salt ) ));
220
219
writer .append (",i=" );
221
220
writer .append (Integer .toString (iterationCount ));
222
221
0 commit comments