TokenBindingValidator { public void validate(TokenBinding clientDataTokenBinding, byte[] serverTokenBindingId) { if (clientDataTokenBinding == null) { } else { byte[] clientDataTokenBindingId; if (clientDataTokenBinding.getId() == null) { clientDataTokenBindingId = null; } else { clientDataTokenBindingId = Base64UrlUtil.decode(clientDataTokenBinding.getId()); } switch (clientDataTokenBinding.getStatus()) { case NOT_SUPPORTED: break; case SUPPORTED: break; case PRESENT: if (!Arrays.equals(clientDataTokenBindingId, serverTokenBindingId)) { throw new TokenBindingException("TokenBinding id does not match"); } } } }  void validate(TokenBinding clientDataTokenBinding, byte[] serverTokenBindingId);  }
@Test void validate_test() { byte[] bindingId = new byte[]{0x01, 0x23, 0x45}; TokenBinding tokenBinding = new TokenBinding(TokenBindingStatus.PRESENT, bindingId); target.validate(tokenBinding, bindingId); }
@Test void validate_invalid_bindingId_test() { byte[] bindingId = new byte[]{0x01, 0x23, 0x45}; byte[] invalidBindingId = new byte[]{0x00, 0x00, 0x00}; TokenBinding tokenBinding = new TokenBinding(TokenBindingStatus.PRESENT, bindingId); assertThrows(TokenBindingException.class, () -> target.validate(tokenBinding, invalidBindingId) ); }
@Test void validate_TokenBinding_not_supported_test() { byte[] bindingId = null; TokenBinding tokenBinding = new TokenBinding(TokenBindingStatus.NOT_SUPPORTED, bindingId); target.validate(tokenBinding, bindingId); }
@Test void validate_TokenBinding_supported_test() { byte[] bindingId = null; TokenBinding tokenBinding = new TokenBinding(TokenBindingStatus.SUPPORTED, bindingId); target.validate(tokenBinding, bindingId); }