/** * Converts byte[] to String by Base64 encoding. * * @param random raw bytes * @return a converted String */ @Override protected String convertBytesToString(final byte[] random) { return EncodingUtils.encodeUrlSafeBase64(random); }
private static String calculateCodeVerifierHash(final String method, final String codeVerifier) { if ("plain".equalsIgnoreCase(method)) { return codeVerifier; } if ("S256".equalsIgnoreCase(method)) { val sha256 = DigestUtils.sha256(codeVerifier); return EncodingUtils.encodeUrlSafeBase64(sha256.getBytes(StandardCharsets.UTF_8)); } throw new CredentialsException("Code verification method is unrecognized: " + method); } }