AccessToken extends OAuth2Token { String getX509CertificateHash(X509Certificate cert) { try { byte[] encCert = Crypto.sha256(cert.getEncoded()); return Base64.getUrlEncoder().withoutPadding().encodeToString(encCert); } catch (CryptoException | CertificateEncodingException ex) { LOG.error("Unable to get X.509 certificate hash", ex); return null; } } AccessToken();  AccessToken(final String token, JwtsSigningKeyResolver keyResolver);  AccessToken(final String token, PublicKey publicKey);  AccessToken(final String token, JwtsSigningKeyResolver keyResolver,
                       X509Certificate x509Cert);  AccessToken(final String token, JwtsSigningKeyResolver keyResolver,
                       X509Certificate x509Cert, final String x509CertHash); static void setAccessTokenCertOffset(long offset); static void setAccessTokenProxyPrincipals(Set<String> proxyPrincipals); String getClientId(); void setClientId(String clientId); String getProxyPrincipal(); void setProxyPrincipal(String proxyPrincipal); String getUserId(); void setUserId(String userId); List<String> getScope(); void setScope(List<String> scope); LinkedHashMap<String, Object> getConfirm(); void setConfirm(LinkedHashMap<String, Object> confirm); void setConfirmEntry(final String key, final Object value); void setConfirmX509CertHash(X509Certificate cert); boolean confirmMTLSBoundToken(X509Certificate x509Cert, final String x509CertHash); Object getConfirmEntry(final String key); String getSignedToken(final PrivateKey key, final String keyId,
            final SignatureAlgorithm keyAlg); static final String HDR_TOKEN_TYPE; static final String HDR_TOKEN_JWT; static final String CLAIM_SCOPE; static final String CLAIM_UID; static final String CLAIM_CLIENT_ID; static final String CLAIM_CONFIRM; static final String CLAIM_PROXY; static final String CLAIM_CONFIRM_X509_HASH; }
@Test public void testGetX509CertificateHash() throws CertificateEncodingException { X509Certificate mockCert = Mockito.mock(X509Certificate.class); Mockito.when(mockCert.getEncoded()).thenThrow(new CryptoException()); AccessToken accessToken = new AccessToken(); assertNull(accessToken.getX509CertificateHash(mockCert)); }