public PreparePcaResponse preparePcaRequestRestService(NikApduResponsesRequest request) {
        PreparePcaResponse response = new PreparePcaResponse();
        EidSession session = initSession(request, null, response);
        if (session == null) return response;

        // 1.28 validate
        ApduService apduService = new ApduService(session, request.getCounter());
        ResponseAPDU responseAPDU = apduService.verify(request.getApdu());
        byte[] challenge = responseAPDU.getData();

        // 1.29 signData
        byte[] toSign = KeyUtils.calcDataToSign(challenge, session.getEphemeralKey().getQ(), session.getIdpicc().data);
        byte[] signature = signatureService.sign(toSign, session.getAtReference(), true);

        // 1.30 APDU > external authenticate
        ImmutableList.Builder<CommandAPDU> chain = ImmutableList.builder();
        chain.add(apduService.getExternalAuthenticate(signature));
        chain.addAll(apduService.createSecureNikPcaApdus(session.getUserConsentType().getTag80()));
        response.setApdus(chain.build());

        sessionRepo.save(session);
        return response;
    }
@Test
    void preparePcaRequestRestServiceTest() {
        EidSession session = new EidSession();
        session.setEphemeralKey(ephemeralKey);
        session.setIdpicc(ByteArray.fromBase64("PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"));
        session.setUserConsentType(PolymorphType.PIP);
        session.setAtReference("SSSSSSSSSSSSSSSS");
        session.setkEnc(kEnc);
        session.setkMac(kMac);
        NikApduResponsesRequest request = new NikApduResponsesRequest();
        request.setHeader(createRequestHeader());
        request.setCounter(7);
        request.setApdu(new ResponseAPDU(Base64.decode("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS")));

        doReturn(session).when(nikService).initSession(any(AppRequest.class), isNull(), any(AppResponse.class));

        PreparePcaResponse result = nikService.preparePcaRequestRestService(request);

        assertEquals("OK", result.getStatus());
        assertEquals(3, result.getApdus().size());
        verify(signatureService, times(1)).sign(any(byte[].class), eq("SSSSSSSSSSSSSSSS"), eq(true));
    }