private boolean isValidKeyUsage(final X509Certificate certificate) {
        LOGGER.debug("Checking certificate keyUsage extension");
        val keyUsage = certificate.getKeyUsage();
        if (keyUsage == null) {
            LOGGER.warn("Configuration specifies checkKeyUsage but keyUsage extension not found in certificate.");
            return !this.requireKeyUsage;
        }

        val func = FunctionUtils.doIf(c -> isCritical(certificate, KEY_USAGE_OID) || requireKeyUsage,
            t -> {
                LOGGER.debug("KeyUsage extension is marked critical or required by configuration.");
                return keyUsage[0];
            },
            f -> {
                LOGGER.debug("KeyUsage digitalSignature=%s, Returning true since keyUsage validation not required by configuration.");
                return Boolean.TRUE;
            });
        return func.apply(certificate);
    }
private boolean isValidKeyUsage ( final X509Certificate certificate ) { LOGGER . debug ( "Checking certificate keyUsage extension" ) ; val keyUsage = certificate . getKeyUsage ( ) ; if ( keyUsage == null ) { LOGGER . warn ( "Configuration specifies checkKeyUsage but keyUsage extension not found in certificate." ) ; return ! this . requireKeyUsage ; } val func = FunctionUtils . doIf ( c -> isCritical ( certificate , KEY_USAGE_OID ) || requireKeyUsage , t -> { LOGGER . debug ( "KeyUsage extension is marked critical or required by configuration." ) ; return keyUsage [ 0 ] ; } , f -> { LOGGER . debug ( "KeyUsage digitalSignature=%s, Returning true since keyUsage validation not required by configuration." ) ; return Boolean . TRUE ; } ) ; return func . apply ( certificate ) ; }
Checks if is valid key usage. <p>
KeyUsage ::= BIT STRING { digitalSignature (0), nonRepudiation (1),
keyEncipherment (2), dataEncipherment (3), keyAgreement (4),
keyCertSign (5), cRLSign (6), encipherOnly (7), decipherOnly (8) }

@param certificate the certificate
@return true, if  valid key usage