How to use CertificateService class of com.testsigma.service package

Best Testsigma code snippet using com.testsigma.service.CertificateService

Source:ProvisioningProfileService.java Github

copy

Full Screen

...26@Service27@RequiredArgsConstructor(onConstructor = @__({@Autowired}))28public class ProvisioningProfileService {29 private final ProvisioningProfileRepository provisioningProfileRepository;30 private final CertificateService certificateService;31 private final ProvisioningProfileParserService profileParserService;32 private final ProvisioningProfileDeviceService provisioningProfileDeviceService;33 private final TestDeviceService testDeviceService;34 private final WebApplicationContext webApplicationContext;35 private final StorageServiceFactory storageServiceFactory;36 public Page<ProvisioningProfile> findAll(Specification<ProvisioningProfile> spec, Pageable pageable) {37 return this.provisioningProfileRepository.findAll(spec, pageable);38 }39 public List<ProvisioningProfile> findAll() {40 return this.provisioningProfileRepository.findAll();41 }42 public ProvisioningProfile find(Long id) throws ResourceNotFoundException {43 ProvisioningProfile provisioningProfile = this.provisioningProfileRepository.findById(id).orElseThrow(44 () -> new ResourceNotFoundException("Profile missing with id:" + id));45 certificateService.setPreSignedURLs(provisioningProfile);46 return provisioningProfile;47 }48 public ProvisioningProfile create(ProvisioningProfile provisioningProfile) {49 provisioningProfile.setStatus(ProvisioningProfileStatus.CSR_REQUESTED);50 provisioningProfile = this.provisioningProfileRepository.save(provisioningProfile);51 try {52 log.info(String.format("Generating CSR for provisioningProfile [%s] - [%s]", provisioningProfile.getId(),53 provisioningProfile.getName()));54 String csrPathPrefix = certificateService.s3Prefix(provisioningProfile.getId());55 String csrFileName = +provisioningProfile.getId() + CertificateService.CSR_FILE_SUFFIX;56 String privateKeyFileName = provisioningProfile.getId()57 + CertificateService.PRIVATE_KEY_FILE_SUFFIX;58 String csrS3FileName = csrPathPrefix + CertificateService.CSR_FILE_SUFFIX;59 String privateKeyS3FileName = csrPathPrefix + CertificateService.PRIVATE_KEY_FILE_SUFFIX;60 File csrFile = File.createTempFile(csrFileName, CertificateService.CSR_EXTENSION);61 File privateKeyFile = File.createTempFile(privateKeyFileName, CertificateService.PEM_EXTENSION);62 certificateService.writeCSR(csrFile, privateKeyFile);63 log.info(String.format("Uploading CSR for provisioningProfile [%s] - [%s]", provisioningProfile.getId(),64 provisioningProfile.getName()));65 storageServiceFactory.getStorageService().addFile(csrS3FileName + CertificateService.CSR_EXTENSION, csrFile);66 storageServiceFactory.getStorageService().addFile(privateKeyS3FileName + CertificateService.PEM_EXTENSION, privateKeyFile);67 provisioningProfile.setStatus(ProvisioningProfileStatus.AWAITING_FOR_CERTIFICATE);68 provisioningProfile = this.provisioningProfileRepository.save(provisioningProfile);69 certificateService.setPreSignedURLs(provisioningProfile);70 } catch (Exception e) {71 log.error(e.getMessage(), e);72 }73 return provisioningProfile;74 }75 public ProvisioningProfile update(ProvisioningProfile provisioningProfile) throws TestsigmaException {76 try {77 MultipartFile cer = provisioningProfile.getCer();78 MultipartFile provFile = provisioningProfile.getProvisioningProfile();79 if (cer != null) {80 log.info(String.format("Uploading Certificate files(cer, crt, pem) for provisioningProfile [%s] - [%s]",81 provisioningProfile.getId(), provisioningProfile.getName()));82 updateCRT(cer, provisioningProfile);83 provisioningProfile.setStatus(ProvisioningProfileStatus.AWAITING_FOR_PROVISIONING_PROFILE);84 provisioningProfile.setUpdatedDate(new Timestamp(System.currentTimeMillis()));85 provisioningProfile = this.provisioningProfileRepository.save(provisioningProfile);86 }87 if (provFile != null) {88 log.info(String.format("Uploading Certificate mobile provisioning file for provisioningProfile [%s] - [%s]",89 provisioningProfile.getId(), provisioningProfile.getName()));90 File tempProvFile = File.createTempFile(provisioningProfile.getId() + CertificateService.MOBILE_PROVISION_FILE_SUFFIX,91 CertificateService.MOBILE_PROVISION_EXTENSION);92 provFile.transferTo(tempProvFile.toPath());93 parseDeviceInfoFromProvisioningProfile(tempProvFile, provisioningProfile);94 updateProvisioningProfile(tempProvFile, provisioningProfile);95 provisioningProfile.setStatus(ProvisioningProfileStatus.READY);96 provisioningProfile.setUpdatedDate(new Timestamp(System.currentTimeMillis()));97 provisioningProfileRepository.save(provisioningProfile);98 certificateService.setPreSignedURLs(provisioningProfile);99 ReSignTask reSignTask = new ReSignTask(webApplicationContext, provisioningProfile, null);100 ReSignTaskFactory.getInstance().startTask(reSignTask);101 }102 } catch (IOException e) {103 throw new TestsigmaException(e.getMessage(), e);104 }105 return provisioningProfile;106 }107 private void checkIfDevicesIsAlreadyProvisioned(List<String> deviceUDIDs, ProvisioningProfile provisioningProfile)108 throws TestsigmaException {109 List<ProvisioningProfileDevice> conflictingDevices = provisioningProfileDeviceService110 .findAllByDeviceUDIdInAndProvisioningProfileIdNot(deviceUDIDs, provisioningProfile.getId());111 if (conflictingDevices.size() > 0) {112 List<String> conflictingDeviceUDIDs = conflictingDevices.stream()113 .map(ProvisioningProfileDevice::getDeviceUDId).collect(Collectors.toList());114 String errorMsg = "These devices are already provisioned through difference provisioning profile"115 + conflictingDeviceUDIDs + " Devices with multiple provisioning profiles are not allowed.";116 throw new TestsigmaException(errorMsg, errorMsg);117 }118 }119 private void removeProvisionedDevicesNotInProvisioningProfile(List<String> deviceUDIDs, ProvisioningProfile provisioningProfile)120 throws TestsigmaException {121 List<ProvisioningProfileDevice> existingDevices = provisioningProfileDeviceService122 .findAllByProvisioningProfileId(provisioningProfile.getId());123 if (existingDevices.size() > 0) {124 List<String> existingDeviceUDIDs = existingDevices.stream()125 .map(ProvisioningProfileDevice::getDeviceUDId).collect(Collectors.toList());126 existingDeviceUDIDs.removeAll(deviceUDIDs);127 if (existingDeviceUDIDs.size() > 0) {128 log.info("Removing existing device from provisioning profile devices - " + existingDeviceUDIDs);129 List<ProvisioningProfileDevice> removableDevices = provisioningProfileDeviceService130 .findAllByDeviceUDIdIn(existingDeviceUDIDs);131 List<Long> removedAgentDeviceIds = removableDevices.stream()132 .map(ProvisioningProfileDevice::getAgentDeviceId).collect(Collectors.toList());133 List<TestDevice> testDeviceServices = testDeviceService134 .findAllByAgentDeviceIds(removedAgentDeviceIds);135 if (testDeviceServices.size() > 0) {136 List<Long> existingExecutionIds = testDeviceServices.stream()137 .map(TestDevice::getTestPlanId).collect(Collectors.toList());138 throw new TestsigmaException("There are bellow devices removed from provision profile but have executions ::"139 + existingExecutionIds);140 }141 provisioningProfileDeviceService.deleteAllByDeviceUDIDIn(existingDeviceUDIDs);142 }143 log.info("Final list of device UUID's post cleanup - " + deviceUDIDs);144 }145 }146 private void parseDeviceInfoFromProvisioningProfile(File tempProvFile, ProvisioningProfile provisioningProfile)147 throws TestsigmaException, IOException {148 List<String> deviceUDIDs = profileParserService.parseDevices(tempProvFile);149 String teamId = profileParserService.getTeamId(tempProvFile);150 log.info("Identified devices from provisioning profile - " + deviceUDIDs);151 log.info("Identified team id from provisioning profile - " + teamId);152 provisioningProfile.setDeviceUDIDs(deviceUDIDs);153 provisioningProfile.setTeamId(teamId);154 checkIfDevicesIsAlreadyProvisioned(deviceUDIDs, provisioningProfile);155 removeProvisionedDevicesNotInProvisioningProfile(deviceUDIDs, provisioningProfile);156 provisioningProfileDeviceService.create(deviceUDIDs, provisioningProfile);157 }158 private void updateCRT(MultipartFile cer, ProvisioningProfile provisioningProfile) throws TestsigmaException {159 try {160 String profilePathPrefix = certificateService.s3Prefix(provisioningProfile.getId());161 String certificateLocalName = provisioningProfile.getId()162 + CertificateService.CERTIFICATE_FILE_SUFFIX;163 String certificateS3Name = profilePathPrefix + CertificateService.CERTIFICATE_FILE_SUFFIX;164 File cerFile = File.createTempFile(certificateLocalName, CertificateService.CERTIFICATE_CER_EXTENSION);165 File crt = File.createTempFile(certificateLocalName, CertificateService.CERTIFICATE_CRT_EXTENSION);166 File pem = File.createTempFile(certificateLocalName, CertificateService.PEM_EXTENSION);167 cer.transferTo(cerFile.toPath());168 log.info(String.format("Uploading certificate(cer) for provisioningProfile [%s] - [%s]", provisioningProfile.getId(),169 provisioningProfile.getName()));170 storageServiceFactory.getStorageService().addFile(certificateS3Name + CertificateService.CERTIFICATE_CER_EXTENSION, cerFile);171 log.info(String.format("Uploading certificate(crt) for provisioningProfile [%s] - [%s]", provisioningProfile.getId(),172 provisioningProfile.getName()));173 certificateService.writeCRT(cerFile, crt);174 storageServiceFactory.getStorageService().addFile(certificateS3Name + CertificateService.CERTIFICATE_CRT_EXTENSION, crt);175 log.info(String.format("Uploading certificate(pem) for provisioningProfile [%s] - [%s]", provisioningProfile.getId(),176 provisioningProfile.getName()));177 certificateService.writePem(crt, pem);178 storageServiceFactory.getStorageService().addFile(certificateS3Name + CertificateService.PEM_EXTENSION, pem);179 } catch (Exception e) {180 throw new TestsigmaException(e.getMessage(), e);181 }182 }183 private void updateProvisioningProfile(File provFile, ProvisioningProfile provisioningProfile) throws IOException {184 log.debug(String.format("Uploading ProvisioningProfile for provisioningProfile [%s] - [%s]",185 provisioningProfile.getId(), provisioningProfile.getName()));186 String profilePathPrefix = certificateService.s3Prefix(provisioningProfile.getId());187 storageServiceFactory.getStorageService().addFile(profilePathPrefix + CertificateService.MOBILE_PROVISION_FILE_SUFFIX188 + CertificateService.MOBILE_PROVISION_EXTENSION, provFile);189 }190 public void destroy(Long id) throws ResourceNotFoundException {191 ProvisioningProfile profile = find(id);192 this.provisioningProfileRepository.delete(profile);193 }194}...

Full Screen

Full Screen

Source:ProvisioningProfilesController.java Github

copy

Full Screen

...12import com.testsigma.exception.TestsigmaException;13import com.testsigma.mapper.ProvisioningProfileMapper;14import com.testsigma.model.ProvisioningProfile;15import com.testsigma.model.ProvisioningProfileDevice;16import com.testsigma.service.CertificateService;17import com.testsigma.service.ProvisioningProfileDeviceService;18import com.testsigma.service.ProvisioningProfileService;19import com.testsigma.specification.ProvisioningProfilesBuilder;20import com.testsigma.web.request.ProvisioningProfileRequest;21import lombok.RequiredArgsConstructor;22import lombok.extern.log4j.Log4j2;23import org.springframework.beans.factory.annotation.Autowired;24import org.springframework.data.domain.Page;25import org.springframework.data.domain.PageImpl;26import org.springframework.data.domain.Pageable;27import org.springframework.data.jpa.domain.Specification;28import org.springframework.http.HttpStatus;29import org.springframework.web.bind.annotation.*;30import java.sql.Timestamp;31import java.util.List;32import java.util.stream.Collectors;33@Log4j234@RestController35@RequestMapping(path = "/settings/provisioning_profiles")36@RequiredArgsConstructor(onConstructor = @__(@Autowired))37public class ProvisioningProfilesController {38 private final ProvisioningProfileService service;39 private final ProvisioningProfileMapper mapper;40 private final CertificateService certificateService;41 private final ProvisioningProfileDeviceService provisioningProfileDeviceService;42 @GetMapping43 public Page<ProvisioningProfileDTO> index(ProvisioningProfilesBuilder builder, Pageable pageable) {44 log.info("Get request /settings/provisioning_profiles");45 Specification<ProvisioningProfile> spec = builder.build();46 Page<ProvisioningProfile> profiles = this.service.findAll(spec, pageable);47 for (ProvisioningProfile profile : profiles) {48 certificateService.setPreSignedURLs(profile);49 setDeviceUuids(profile);50 }51 List<ProvisioningProfileDTO> dtos = mapper.map(profiles.getContent());52 return new PageImpl<>(dtos, pageable, profiles.getTotalElements());53 }54 @GetMapping(value = "/{id}")...

Full Screen

Full Screen

CertificateService

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.CertificateService;2public class TestCertificateService {3public static void main(String[] args) {4CertificateService certificateService = new CertificateService();5String certificate = certificateService.getCertificate("Sachin");6System.out.println(certificate);7}8}9at java.net.URLClassLoader$1.run(Unknown Source)10at java.net.URLClassLoader$1.run(Unknown Source)11at java.security.AccessController.doPrivileged(Native Method)12at java.net.URLClassLoader.findClass(Unknown Source)13at java.lang.ClassLoader.loadClass(Unknown Source)14at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)15at java.lang.ClassLoader.loadClass(Unknown Source)16C:\>java -cp CertificateService.jar;TestCertificateService.jar TestCertificateService17C:\>java -cp CertificateService.jar;TestCertificateService.jar TestCertificateService

Full Screen

Full Screen

CertificateService

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.CertificateService;2import java.util.Scanner;3public class 2{4 public static void main(String[] args) {5 Scanner sc = new Scanner(System.in);6 System.out.print("Enter the number of students: ");7 int n = sc.nextInt();8 System.out.println("Enter the student details in the format: <rollno> <name> <mark1> <mark2> <mark3>");9 CertificateService cs = new CertificateService();10 for(int i = 0; i < n; i++){11 cs.addStudent(sc.nextInt(), sc.next(), sc.nextInt(), sc.nextInt(), sc.nextInt());12 }13 System.out.print("Enter the student roll number: ");14 int rollno = sc.nextInt();15 System.out.println(cs.generateCertificate(rollno));16 }17}18import java.time.LocalDate;19import java.time.Month;20public class 1{21 public static void main(String[] args) {22 LocalDate ld = LocalDate.now();23 System.out.println("Today's date: " + ld);24 LocalDate ld1 = LocalDate.of(2020, Month.FEBRUARY, 29);25 System.out.println("Date of 29th February 2020: " + ld1);26 LocalDate ld2 = LocalDate.of(2020,

Full Screen

Full Screen

CertificateService

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.CertificateService;2import java.security.cert.X509Certificate;3{4public static void main(String[] args)5{6CertificateService cs = new CertificateService();7X509Certificate cert = cs.getCertificate("C:\\Users\\testsigma\\Desktop\\test.cer");8System.out.println("Subject: " + cert.getSubjectDN());9System.out.println("Issuer: " + cert.getIssuerDN());10System.out.println("Version: " + cert.getVersion());11System.out.println("Serial Number: " + cert.getSerialNumber());12System.out.println("Not valid before: " + cert.getNotBefore());13System.out.println("Not valid after: " + cert.getNotAfter());14System.out.println("Signature Algorithm: " + cert.getSigAlgName());15}16}

Full Screen

Full Screen

CertificateService

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.CertificateService;2{3 public static void main(String[] args)4 {5 CertificateService cs = new CertificateService();6 cs.generateCertificate("John", "Doe");7 }8}

Full Screen

Full Screen

CertificateService

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.CertificateService;2import java.util.Scanner;3public class CertificateApp{4 public static void main(String[] args){5 Scanner sc = new Scanner(System.in);6 System.out.println("Enter the no. of certificates to be printed");7 int n = sc.nextInt();8 CertificateService service = new CertificateService();9 System.out.println("Certificate generated");10 service.generateCertificate(n);11 }12}13import com.testsigma.service.CertificateService;14import java.util.Scanner;15public class CertificateApp{16 public static void main(String[] args){17 Scanner sc = new Scanner(System.in);18 System.out.println("Enter the no. of certificates to be printed");19 int n = sc.nextInt();20 CertificateService service = new CertificateService();21 System.out.println("Certificate generated");22 service.generateCertificate(n);23 }24}25import com.testsigma.service.CertificateService;26import java.util.Scanner;27public class CertificateApp{28 public static void main(String[] args){29 Scanner sc = new Scanner(System.in);30 System.out.println("Enter the no. of certificates to be printed");31 int n = sc.nextInt();32 CertificateService service = new CertificateService();33 System.out.println("Certificate generated");34 service.generateCertificate(n);35 }36}37import com.testsigma.service.CertificateService;38import java.util.Scanner;39public class CertificateApp{40 public static void main(String[] args){41 Scanner sc = new Scanner(System.in);42 System.out.println("Enter the no. of certificates to be printed");43 int n = sc.nextInt();44 CertificateService service = new CertificateService();45 System.out.println("Certificate generated");46 service.generateCertificate(n);47 }48}49import com.testsigma.service.CertificateService;50import java.util.Scanner;51public class CertificateApp{52 public static void main(String[] args){53 Scanner sc = new Scanner(System.in);54 System.out.println("Enter the no. of certificates to be printed");55 int n = sc.nextInt();56 CertificateService service = new CertificateService();57 System.out.println("Certificate

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testsigma automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful