Java Code Examples for com.webauthn4j.server.ServerProperty#getRpId()

The following examples show how to use com.webauthn4j.server.ServerProperty#getRpId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanAssertUtil.java    From webauthn4j with Apache License 2.0 5 votes vote down vote up
public static void validate(ServerProperty serverProperty) {
    if (serverProperty == null) {
        throw new ConstraintViolationException("serverProperty must not be null");
    }
    if (serverProperty.getRpId() == null) {
        throw new ConstraintViolationException("rpId must not be null");
    }
    if (serverProperty.getChallenge() == null) {
        throw new ConstraintViolationException("challenge must not be null");
    }
    if (serverProperty.getOrigin() == null) {
        throw new ConstraintViolationException("origin must not be null");
    }
}
 
Example 2
Source File: RpIdHashValidator.java    From webauthn4j with Apache License 2.0 5 votes vote down vote up
public void validate(byte[] rpIdHash, ServerProperty 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.");
    }
}