class CertificateAuthoritiesApiController implements CertificateAuthoritiesApi {

    @Override
    @PreAuthorize("hasAuthority('VIEW_APPROVED_CERTIFICATE_AUTHORITIES')"
            + " or (hasAuthority('GENERATE_AUTH_CERT_REQ') and "
            + " (#keyUsageType == T(org.niis.xroad.restapi.openapi.model.KeyUsageType).AUTHENTICATION"
            + " or #keyUsageType == null))"
            + "or (hasAuthority('GENERATE_SIGN_CERT_REQ') and "
            + "#keyUsageType == T(org.niis.xroad.restapi.openapi.model.KeyUsageType).SIGNING)")
    public ResponseEntity<List<CertificateAuthority>> getApprovedCertificateAuthorities(KeyUsageType keyUsageType,
            Boolean includeIntermediateCas) {
        KeyUsageInfo keyUsageInfo = KeyUsageTypeMapping.map(keyUsageType).orElse(null);
        Collection<ApprovedCaDto> caDtos = null;
        try {
            caDtos = certificateAuthorityService.getCertificateAuthorities(keyUsageInfo, includeIntermediateCas);
        } catch (CertificateAuthorityService.InconsistentCaDataException e) {
            throw new InternalServerErrorException(e);
        }
        List<CertificateAuthority> cas = certificateAuthorityConverter.convert(caDtos);
        return new ResponseEntity<>(cas, HttpStatus.OK);
    }

    public  CertificateAuthoritiesApiController(CertificateAuthorityService certificateAuthorityService,
            CertificateAuthorityConverter certificateAuthorityConverter,
            KeyService keyService,
            ClientConverter clientConverter,
            CsrSubjectFieldDescriptionConverter subjectConverter);

}