All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.webauthn4j.verifier.internal.BEFlagVerifier Maven / Gradle / Ivy

There is a newer version: 0.9.2.RELEASE
Show newest version
package com.webauthn4j.verifier.internal;

import com.webauthn4j.authenticator.Authenticator;
import com.webauthn4j.credential.CoreCredentialRecord;
import com.webauthn4j.data.attestation.authenticator.AuthenticatorData;
import com.webauthn4j.data.extension.authenticator.AuthenticationExtensionAuthenticatorOutput;
import com.webauthn4j.verifier.exception.BadBackupEligibleFlagException;

public class BEFlagVerifier {

    private BEFlagVerifier(){}

    public static void verify(Authenticator authenticator, AuthenticatorData authenticatorData) {
        if(authenticator instanceof CoreCredentialRecord){
            CoreCredentialRecord coreCredentialRecord = (CoreCredentialRecord) authenticator;
            Boolean backEligibleRecordValue = coreCredentialRecord.isBackupEligible();
            //noinspection StatementWithEmptyBody
            if(backEligibleRecordValue == null){
                //no-op
            }
            else if(backEligibleRecordValue) {
                if(!authenticatorData.isFlagBE()){
                    throw new BadBackupEligibleFlagException("Although credential record BE flag is set, current BE flag is not set");
                }
            }
            else{
                if(authenticatorData.isFlagBE()){
                    throw new BadBackupEligibleFlagException("Although credential record BE flag is not set, current BE flag is set");
                }
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy