@Test public void registerAuthCertificate() throws Exception { doAnswer(answer -> authCert).when(signerProxyFacade).getCertForHash(any()); try { tokenCertificateService.registerAuthCert(MOCK_AUTH_CERTIFICATE_HASH, GOOD_ADDRESS); } catch (Exception e) { fail(); } }
public void registerAuthCert(String hash, String securityServerAddress) throws CertificateNotFoundException, GlobalConfOutdatedException, InvalidCertificateException, SignCertificateNotSupportedException, KeyNotFoundException, ActionNotPossibleException { CertificateInfo certificateInfo = getCertificateInfo(hash); auditLogTokenKeyAndCert(hash, certificateInfo, false); verifyAuthCert(certificateInfo); verifyCertAction(PossibleActionEnum.REGISTER, certificateInfo, hash); try { Integer requestId = managementRequestSenderService.sendAuthCertRegisterRequest(securityServerAddress, certificateInfo.getCertificateBytes()); auditDataHelper.put(ADDRESS, securityServerAddress); auditDataHelper.putManagementRequestId(requestId); auditDataHelper.put(CERT_STATUS, CertificateInfo.STATUS_REGINPROG); signerProxyFacade.setCertStatus(certificateInfo.getId(), CertificateInfo.STATUS_REGINPROG); } catch (GlobalConfOutdatedException | CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Could not register auth cert", e); } }
TokenCertificateService { public void registerAuthCert(String hash, String securityServerAddress) throws CertificateNotFoundException, GlobalConfOutdatedException, InvalidCertificateException, SignCertificateNotSupportedException, KeyNotFoundException, ActionNotPossibleException { CertificateInfo certificateInfo = getCertificateInfo(hash); auditLogTokenKeyAndCert(hash, certificateInfo, false); verifyAuthCert(certificateInfo); verifyCertAction(PossibleActionEnum.REGISTER, certificateInfo, hash); try { Integer requestId = managementRequestSenderService.sendAuthCertRegisterRequest(securityServerAddress, certificateInfo.getCertificateBytes()); auditDataHelper.put(ADDRESS, securityServerAddress); auditDataHelper.putManagementRequestId(requestId); auditDataHelper.put(CERT_STATUS, CertificateInfo.STATUS_REGINPROG); signerProxyFacade.setCertStatus(certificateInfo.getId(), CertificateInfo.STATUS_REGINPROG); } catch (GlobalConfOutdatedException | CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Could not register auth cert", e); } } }
TokenCertificateService { public void registerAuthCert(String hash, String securityServerAddress) throws CertificateNotFoundException, GlobalConfOutdatedException, InvalidCertificateException, SignCertificateNotSupportedException, KeyNotFoundException, ActionNotPossibleException { CertificateInfo certificateInfo = getCertificateInfo(hash); auditLogTokenKeyAndCert(hash, certificateInfo, false); verifyAuthCert(certificateInfo); verifyCertAction(PossibleActionEnum.REGISTER, certificateInfo, hash); try { Integer requestId = managementRequestSenderService.sendAuthCertRegisterRequest(securityServerAddress, certificateInfo.getCertificateBytes()); auditDataHelper.put(ADDRESS, securityServerAddress); auditDataHelper.putManagementRequestId(requestId); auditDataHelper.put(CERT_STATUS, CertificateInfo.STATUS_REGINPROG); signerProxyFacade.setCertStatus(certificateInfo.getId(), CertificateInfo.STATUS_REGINPROG); } catch (GlobalConfOutdatedException | CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Could not register auth cert", e); } } @Autowired @SuppressWarnings("checkstyle:ParameterNumber")  TokenCertificateService(SignerProxyFacade signerProxyFacade, ClientService clientService,
            CertificateAuthorityService certificateAuthorityService, KeyService keyService, DnFieldHelper dnFieldHelper,
            GlobalConfService globalConfService, GlobalConfFacade globalConfFacade, ClientRepository clientRepository,
            ManagementRequestSenderService managementRequestSenderService, ServerConfService serverConfService,
            PossibleActionsRuleEngine possibleActionsRuleEngine, TokenService tokenService,
            SecurityHelper securityHelper, AuditDataHelper auditDataHelper,
            AuditEventHelper auditEventHelper); }
TokenCertificateService { public void registerAuthCert(String hash, String securityServerAddress) throws CertificateNotFoundException, GlobalConfOutdatedException, InvalidCertificateException, SignCertificateNotSupportedException, KeyNotFoundException, ActionNotPossibleException { CertificateInfo certificateInfo = getCertificateInfo(hash); auditLogTokenKeyAndCert(hash, certificateInfo, false); verifyAuthCert(certificateInfo); verifyCertAction(PossibleActionEnum.REGISTER, certificateInfo, hash); try { Integer requestId = managementRequestSenderService.sendAuthCertRegisterRequest(securityServerAddress, certificateInfo.getCertificateBytes()); auditDataHelper.put(ADDRESS, securityServerAddress); auditDataHelper.putManagementRequestId(requestId); auditDataHelper.put(CERT_STATUS, CertificateInfo.STATUS_REGINPROG); signerProxyFacade.setCertStatus(certificateInfo.getId(), CertificateInfo.STATUS_REGINPROG); } catch (GlobalConfOutdatedException | CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Could not register auth cert", e); } } @Autowired @SuppressWarnings("checkstyle:ParameterNumber")  TokenCertificateService(SignerProxyFacade signerProxyFacade, ClientService clientService,
            CertificateAuthorityService certificateAuthorityService, KeyService keyService, DnFieldHelper dnFieldHelper,
            GlobalConfService globalConfService, GlobalConfFacade globalConfFacade, ClientRepository clientRepository,
            ManagementRequestSenderService managementRequestSenderService, ServerConfService serverConfService,
            PossibleActionsRuleEngine possibleActionsRuleEngine, TokenService tokenService,
            SecurityHelper securityHelper, AuditDataHelper auditDataHelper,
            AuditEventHelper auditEventHelper); GeneratedCertRequestInfo generateCertRequest(String keyId, ClientId memberId, KeyUsageInfo keyUsage,
            String caName, Map<String, String> subjectFieldValues, CertificateRequestFormat format); GeneratedCertRequestInfo regenerateCertRequest(String keyId, String csrId, CertificateRequestFormat format); CertificateInfo getCertificateInfo(String hash); CertificateInfo importCertificateFromToken(String hash); void activateCertificate(String hash); void deactivateCertificate(String hash); CertificateInfo importCertificate(byte[] certificateBytes); boolean isAuthCertBytes(byte[] certificateBytes); void registerAuthCert(String hash, String securityServerAddress); void unregisterAuthCert(String hash); void markAuthCertForDeletion(String hash); EnumSet<PossibleActionEnum> getPossibleActionsForCertificate(String hash); EnumSet<PossibleActionEnum> getPossibleActionsForCsr(
            String csrId); void deleteCertificates(List<CertificateInfo> certificateInfos); void deleteCertificate(String hash); String getKeyIdForCertificateHash(String hash); void deleteCsr(String csrId); }
TokenCertificateService { public void registerAuthCert(String hash, String securityServerAddress) throws CertificateNotFoundException, GlobalConfOutdatedException, InvalidCertificateException, SignCertificateNotSupportedException, KeyNotFoundException, ActionNotPossibleException { CertificateInfo certificateInfo = getCertificateInfo(hash); auditLogTokenKeyAndCert(hash, certificateInfo, false); verifyAuthCert(certificateInfo); verifyCertAction(PossibleActionEnum.REGISTER, certificateInfo, hash); try { Integer requestId = managementRequestSenderService.sendAuthCertRegisterRequest(securityServerAddress, certificateInfo.getCertificateBytes()); auditDataHelper.put(ADDRESS, securityServerAddress); auditDataHelper.putManagementRequestId(requestId); auditDataHelper.put(CERT_STATUS, CertificateInfo.STATUS_REGINPROG); signerProxyFacade.setCertStatus(certificateInfo.getId(), CertificateInfo.STATUS_REGINPROG); } catch (GlobalConfOutdatedException | CodedException e) { throw e; } catch (Exception e) { throw new SignerNotReachableException("Could not register auth cert", e); } } @Autowired @SuppressWarnings("checkstyle:ParameterNumber")  TokenCertificateService(SignerProxyFacade signerProxyFacade, ClientService clientService,
            CertificateAuthorityService certificateAuthorityService, KeyService keyService, DnFieldHelper dnFieldHelper,
            GlobalConfService globalConfService, GlobalConfFacade globalConfFacade, ClientRepository clientRepository,
            ManagementRequestSenderService managementRequestSenderService, ServerConfService serverConfService,
            PossibleActionsRuleEngine possibleActionsRuleEngine, TokenService tokenService,
            SecurityHelper securityHelper, AuditDataHelper auditDataHelper,
            AuditEventHelper auditEventHelper); GeneratedCertRequestInfo generateCertRequest(String keyId, ClientId memberId, KeyUsageInfo keyUsage,
            String caName, Map<String, String> subjectFieldValues, CertificateRequestFormat format); GeneratedCertRequestInfo regenerateCertRequest(String keyId, String csrId, CertificateRequestFormat format); CertificateInfo getCertificateInfo(String hash); CertificateInfo importCertificateFromToken(String hash); void activateCertificate(String hash); void deactivateCertificate(String hash); CertificateInfo importCertificate(byte[] certificateBytes); boolean isAuthCertBytes(byte[] certificateBytes); void registerAuthCert(String hash, String securityServerAddress); void unregisterAuthCert(String hash); void markAuthCertForDeletion(String hash); EnumSet<PossibleActionEnum> getPossibleActionsForCertificate(String hash); EnumSet<PossibleActionEnum> getPossibleActionsForCsr(
            String csrId); void deleteCertificates(List<CertificateInfo> certificateInfos); void deleteCertificate(String hash); String getKeyIdForCertificateHash(String hash); void deleteCsr(String csrId);  }