DefaultOAuthJwtAccessTokenValidator implements OAuthJwtAccessTokenValidator { @Override public void validateCertificateBinding(OAuthJwtAccessToken jwt, String certificateThumbprint) throws OAuthJwtAccessTokenException { this.verifyCertificateThumbprint(jwt, certificateThumbprint); } DefaultOAuthJwtAccessTokenValidator(String trustedIssuer, Set<String> requiredAudiences, Set<String> requiredScopes, Map<String, Set<String>> authorizedClientIds); @Override void validate(OAuthJwtAccessToken jwt); @Override void validateClientId(OAuthJwtAccessToken jwt, String clientId); @Override void validateCertificateBinding(OAuthJwtAccessToken jwt, String certificateThumbprint);  }
@Test public void testValidateCertificateBinding() { final DefaultOAuthJwtAccessTokenValidator validator = this.baseValidator; final OAuthJwtAccessToken mock = Mockito.spy(baseJwt); Mockito.doReturn(null).when(mock).getCertificateThumbprint(); assertDoesNotThrow.accept(new ThrowingRunnable() { public void run() throws Throwable { validator.validateCertificateBinding(mock, (String) null); } }); assertThrowable.accept(new ThrowingRunnable() { public void run() throws Throwable { validator.validateCertificateBinding(mock, "certificate_thumbprint"); } }, "client certificate thumbprint (certificate_thumbprint) not match: got=null"); Mockito.doReturn("certificate_thumbprint").when(mock).getCertificateThumbprint(); assertThrowable.accept(new ThrowingRunnable() { public void run() throws Throwable { validator.validateCertificateBinding(mock, (String) null); } }, "client certificate thumbprint (null) not match: got=certificate_thumbprint"); assertThrowable.accept(new ThrowingRunnable() { public void run() throws Throwable { validator.validateCertificateBinding(mock, "not_match"); } }, "client certificate thumbprint (not_match) not match: got=certificate_thumbprint"); assertDoesNotThrow.accept(new ThrowingRunnable() { public void run() throws Throwable { validator.validateCertificateBinding(mock, new String("certificate_thumbprint")); } }); }