@Test void verifyRpIdHash_test_with_relyingParty_rpId_null() { String rpIdA = "example.com"; String rpIdB = "example.com"; byte[] rpIdBytesA = rpIdA.getBytes(StandardCharsets.UTF_8); byte[] rpIdHashA = MessageDigestUtil.createSHA256().digest(rpIdBytesA); ServerProperty serverProperty = new ServerProperty(origin, null, null, null); assertThrows(IllegalArgumentException.class, () -> target.validate(rpIdHashA, serverProperty) ); }
public void validate(byte[] rpIdHash, CoreServerProperty serverProperty) { AssertUtil.notNull(serverProperty, "serverProperty must not be null"); String rpId = serverProperty.getRpId(); AssertUtil.notNull(rpId, "rpId must not be null"); MessageDigest messageDigest = MessageDigestUtil.createSHA256(); byte[] relyingPartyRpIdBytes = rpId.getBytes(StandardCharsets.UTF_8); byte[] relyingPartyRpIdHash = messageDigest.digest(relyingPartyRpIdBytes); if (!Arrays.equals(rpIdHash, relyingPartyRpIdHash)) { throw new BadRpIdException("rpIdHash doesn't match the hash of preconfigured rpId."); } }
RpIdHashValidator { public void validate(byte[] rpIdHash, CoreServerProperty serverProperty) { AssertUtil.notNull(serverProperty, "serverProperty must not be null"); String rpId = serverProperty.getRpId(); AssertUtil.notNull(rpId, "rpId must not be null"); MessageDigest messageDigest = MessageDigestUtil.createSHA256(); byte[] relyingPartyRpIdBytes = rpId.getBytes(StandardCharsets.UTF_8); byte[] relyingPartyRpIdHash = messageDigest.digest(relyingPartyRpIdBytes); if (!Arrays.equals(rpIdHash, relyingPartyRpIdHash)) { throw new BadRpIdException("rpIdHash doesn't match the hash of preconfigured rpId."); } } }
RpIdHashValidator { public void validate(byte[] rpIdHash, CoreServerProperty serverProperty) { AssertUtil.notNull(serverProperty, "serverProperty must not be null"); String rpId = serverProperty.getRpId(); AssertUtil.notNull(rpId, "rpId must not be null"); MessageDigest messageDigest = MessageDigestUtil.createSHA256(); byte[] relyingPartyRpIdBytes = rpId.getBytes(StandardCharsets.UTF_8); byte[] relyingPartyRpIdHash = messageDigest.digest(relyingPartyRpIdBytes); if (!Arrays.equals(rpIdHash, relyingPartyRpIdHash)) { throw new BadRpIdException("rpIdHash doesn't match the hash of preconfigured rpId."); } }  }
RpIdHashValidator { public void validate(byte[] rpIdHash, CoreServerProperty serverProperty) { AssertUtil.notNull(serverProperty, "serverProperty must not be null"); String rpId = serverProperty.getRpId(); AssertUtil.notNull(rpId, "rpId must not be null"); MessageDigest messageDigest = MessageDigestUtil.createSHA256(); byte[] relyingPartyRpIdBytes = rpId.getBytes(StandardCharsets.UTF_8); byte[] relyingPartyRpIdHash = messageDigest.digest(relyingPartyRpIdBytes); if (!Arrays.equals(rpIdHash, relyingPartyRpIdHash)) { throw new BadRpIdException("rpIdHash doesn't match the hash of preconfigured rpId."); } }  void validate(byte[] rpIdHash, CoreServerProperty serverProperty); }
RpIdHashValidator { public void validate(byte[] rpIdHash, CoreServerProperty serverProperty) { AssertUtil.notNull(serverProperty, "serverProperty must not be null"); String rpId = serverProperty.getRpId(); AssertUtil.notNull(rpId, "rpId must not be null"); MessageDigest messageDigest = MessageDigestUtil.createSHA256(); byte[] relyingPartyRpIdBytes = rpId.getBytes(StandardCharsets.UTF_8); byte[] relyingPartyRpIdHash = messageDigest.digest(relyingPartyRpIdBytes); if (!Arrays.equals(rpIdHash, relyingPartyRpIdHash)) { throw new BadRpIdException("rpIdHash doesn't match the hash of preconfigured rpId."); } }  void validate(byte[] rpIdHash, CoreServerProperty serverProperty);  }