class X509ExternalMapper extends X509AbstractMapper {

    @Override
    public String mapCertificateToMainframeUserId(X509Certificate certificate) {
        if (isClientAuthCertificate(certificate)) {
            try {
                String jwtToken = tokenCreationService.createJwtTokenWithoutCredentials(externalMapperUser);

                HttpPost httpPost = new HttpPost(new URI(externalMapperUrl));
                HttpEntity httpEntity = new ByteArrayEntity(certificate.getEncoded());
                httpPost.setEntity(httpEntity);

                httpPost.setHeader(new BasicHeader("Cookie", "apimlAuthenticationToken=" + jwtToken));

                HttpResponse httpResponse = httpClientProxy.execute(httpPost);
                String response = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8);
                if (response == null || response.isEmpty()) {
                    return null;
                }
                ObjectMapper objectMapper = new ObjectMapper();
                CertMapperResponse certMapperResponse = objectMapper.readValue(response, CertMapperResponse.class);
                return certMapperResponse.getUserId().trim();
            } catch (URISyntaxException e) {
                log.error("Wrong service URI provided", e);
            } catch (CertificateEncodingException e) {
                log.error("Can`t get encoded data from certificate", e);
            } catch (IOException e) {
                log.error("Not able to send certificate to mapper", e);
            }
            return null;
        }
        return null;
    }

}