How to use setPreSignedURLs method of com.testsigma.service.CertificateService class

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

Source:ProvisioningProfileService.java Github

copy

Full Screen

...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()...

Full Screen

Full Screen

Source:ResignService.java Github

copy

Full Screen

...58 storageServiceFactory.getStorageService().addFile("wda/"59 + profile.getId() + "/wda.ipa", new File(filePath));60 log.info(String.format("Resigning wda.ipa file for provisioning profile [%s] - [%s]", profile.getId(),61 profile.getName()));62 certificateService.setPreSignedURLs(profile);63 String ipaName = profile.getId() + "_wda";64 String resignedPathPrefix = "wda/" + profile.getId() + "/wda.ipa";65 if (storageServiceFactory.getStorageService().getStorageType() == StorageType.ON_PREMISE) {66 File resignedIpa = resignUsingFiles(profile, ipaName, commonWdaRealDeviceS3Path());67 storageServiceFactory.getStorageService().addFile(resignedPathPrefix, resignedIpa);68 } else {69 resignUsingUrls(profile, ipaName, commonWdaRealDeviceS3Path(),70 storageServiceFactory.getStorageService().generatePreSignedURL(resignedPathPrefix, StorageAccessLevel.WRITE, 60));71 }72 }73 public void reSignUpload(ProvisioningProfile profile, UploadVersion uploadVersion) throws TestsigmaException {74 log.info(String.format("Resigning Upload [%s] - [%s] file for provisioning profile [%s] - [%s]",75 uploadVersion.getId(), uploadVersion.getName(), profile.getId(), profile.getName()));76 certificateService.setPreSignedURLs(profile);77 String ipaName = profile.getId() + "_" + uploadVersion.getId();78 String resignedPathPrefix = uploadVersion.getResignedAppS3PathSuffix(profile.getId());79 try {80 if (storageServiceFactory.getStorageService().getStorageType() == StorageType.ON_PREMISE) {81 File resignedIpa = resignUsingFiles(profile, ipaName, new URL(uploadVersionService.getPreSignedURL(uploadVersion)));82 storageServiceFactory.getStorageService().addFile(resignedPathPrefix, resignedIpa);83 } else {84 resignUsingUrls(profile, ipaName, new URL(uploadVersionService.getPreSignedURL(uploadVersion)),85 storageServiceFactory.getStorageService().generatePreSignedURL(resignedPathPrefix, StorageAccessLevel.WRITE, 60));86 }87 } catch (MalformedURLException e) {88 log.error(e.getMessage(), e);89 throw new TestsigmaException(e.getMessage(), e);90 }91 }92 public void resignPublicUrlApp(ProvisioningProfile profile, String presignedAppUrl, String resignedPathSuffix)93 throws TestsigmaException {94 log.info(String.format("Resigning App [%s] - [%s] file for provisioning profile [%s] - [%s]",95 presignedAppUrl, resignedPathSuffix, profile.getId(), profile.getName()));96 try {97 certificateService.setPreSignedURLs(profile);98 String ipaName = profile.getId() + "_" + FilenameUtils.getBaseName(new URL(presignedAppUrl).getPath());99 File resignedIpa = resignUsingFiles(profile, ipaName, new URL(presignedAppUrl));100 storageServiceFactory.getStorageService().addFile(resignedPathSuffix, resignedIpa);101 } catch (Exception e) {102 throw new TestsigmaException(e.getMessage(), e);103 }104 }105 public void reSignForAllProfiles(UploadVersion upload, List<ProvisioningProfile> profiles) throws TestsigmaException {106 provisioningProfileUploadService.removeEntitiesForUpload(upload);107 for (ProvisioningProfile profile : profiles) {108 reSignUpload(profile, upload);109 provisioningProfileUploadService.create(profile, upload);110 }111 }112 public void reSignAllUploads(ProvisioningProfile profile, List<UploadVersion> uploadVersions)113 throws TestsigmaException {114 provisioningProfileUploadService.removeEntitiesForProfile(profile);115 for (UploadVersion uploadVersion : uploadVersions) {116 try {117 reSignUpload(profile, uploadVersion);118 provisioningProfileUploadService.create(profile, uploadVersion);119 } catch (Exception e) {120 log.error(e.getMessage(), e);121 }122 }123 }124 public URL commonWdaRealDeviceS3Path() throws TestsigmaException {125 ArrayList<Header> headers = new ArrayList<>();126 headers.add(new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json"));127 HttpResponse<String> response = httpClient.get(testsigmaOSConfigService.getUrl() +128 URLConstants.TESTSIGMA_OS_PUBLIC_WDA_REAL_DEVICE_URL, headers, new TypeReference<>() {129 });130 try {131 return new URL(response.getResponseEntity());132 } catch (MalformedURLException e) {133 throw new TestsigmaException(e.getMessage(), e);134 }135 }136 private List<Header> getResignHeaders() {137 Header authorization = new BasicHeader(org.apache.http.HttpHeaders.AUTHORIZATION, "Bearer " + testsigmaOSConfigService.find().getAccessKey());138 Header accept = new BasicHeader(HttpHeaders.ACCEPT, "*/*");139 return Lists.newArrayList(authorization, accept);140 }141 public File resignUsingFiles(ProvisioningProfile profile, String name, URL ipaUrl)142 throws TestsigmaException {143 File ipa = new File(ThreadContext.get("X-Request-Id") + "_" + name + ".ipa");144 try {145 certificateService.setPreSignedURLs(profile);146 CloseableHttpClient httpClient = HttpClients.custom().build();147 List<Header> headers = getResignHeaders();148 String url = testsigmaOSConfigService.getUrl() + ISIGN_USING_FILES_URL;149 log.info(String.format("Sending a resign request for file %s to server url %s", name, url));150 HttpPut putRequest = new HttpPut(url);151 putRequest.setHeaders(headers.toArray(Header[]::new));152 MultipartEntityBuilder builder = MultipartEntityBuilder.create();153 builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);154 builder.addPart("certificate", copyUrlToFile(profile.getCertificateCrtPresignedUrl()));155 builder.addPart("privateKey", copyUrlToFile(profile.getPrivateKeyPresignedUrl()));156 builder.addPart("provisioningProfile", copyUrlToFile(profile.getProvisioningProfilePresignedUrl()));157 builder.addPart("ipa", copyUrlToFile(ipaUrl));158 builder.addPart("name", new StringBody(name, ContentType.MULTIPART_FORM_DATA));159 putRequest.setEntity(builder.build());160 org.apache.http.HttpResponse res = httpClient.execute(putRequest);161 Integer status = res.getStatusLine().getStatusCode();162 log.info("Resign Using Files Service Response - " + status);163 if (status.equals(HttpStatus.OK.value())) {164 BufferedInputStream bis = new BufferedInputStream(res.getEntity().getContent());165 BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(ipa));166 int inByte;167 while ((inByte = bis.read()) != -1) bos.write(inByte);168 bis.close();169 bos.close();170 }171 } catch (Exception e) {172 log.error(e.getMessage(), e);173 throw new TestsigmaException(e);174 }175 return ipa;176 }177 public void resignUsingUrls(ProvisioningProfile profile, String name, URL ipaUrl, URL resignedIpaUrl)178 throws TestsigmaException {179 certificateService.setPreSignedURLs(profile);180 ResignRequestUsingUrlsDTO resignRequestUsingUrlsDTO = new ResignRequestUsingUrlsDTO();181 resignRequestUsingUrlsDTO.setCertificate(profile.getCertificateCrtPresignedUrl());182 resignRequestUsingUrlsDTO.setPrivateKey(profile.getPrivateKeyPresignedUrl());183 resignRequestUsingUrlsDTO.setProvisioningProfile(profile.getProvisioningProfilePresignedUrl());184 resignRequestUsingUrlsDTO.setIpa(ipaUrl);185 resignRequestUsingUrlsDTO.setResignedIpa(resignedIpaUrl);186 resignRequestUsingUrlsDTO.setName(name);187 HttpResponse<String> response = httpClient.put(testsigmaOSConfigService.getUrl()188 + ISIGN_USING_URLS_URL,189 getResignHeaders(),190 resignRequestUsingUrlsDTO, new TypeReference<>() {191 });192 log.info("Resign Service Response - " + response);193 if (response.getStatusCode() >= 300) {...

Full Screen

Full Screen

setPreSignedURLs

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.CertificateService;2import com.testsigma.service.CertificateServiceService;3import com.testsigma.service.CertificateServiceServiceLocator;4import com.testsigma.service.SetPreSignedURLsRequest;5import com.testsigma.service.SetPreSignedURLsResponse;6import com.testsigma.service.CertificateServiceException;7import java.util.*;8import java.io.*;9import java.net.*;10public class 2 {11 public static void main(String[] args) {12 try {13 CertificateServiceService service = new CertificateServiceServiceLocator();14 CertificateService port = service.getCertificateService();15 SetPreSignedURLsRequest request = new SetPreSignedURLsRequest();

Full Screen

Full Screen

setPreSignedURLs

Using AI Code Generation

copy

Full Screen

1package com.testsigma.service;2import com.testsigma.service.CertificateService;3public class CertificateService_setPreSignedURLs_2{4public static void main(String args[]){5CertificateService obj = new CertificateService();6}7}

Full Screen

Full Screen

setPreSignedURLs

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.CertificateService;2import com.testsigma.service.CertificateServiceClient;3import com.testsigma.service.CertificateServiceException;4import com.testsigma.service.PresignedURL;5import com.testsigma.service.PresignedURLList;6import java.util.List;7import java.util.ArrayList;8import java.util.Arrays;9import java.util.Date;10import java.util.HashMap;11import java.util.Map;12import java.util.concurrent.TimeUnit;13import java.util.logging.Level;14import java.util.logging.Logger;15import org.apache.commons.lang3.time.StopWatch;16public class 2 {17 public static void main(String[] args) {18 try {

Full Screen

Full Screen

setPreSignedURLs

Using AI Code Generation

copy

Full Screen

1package com.testsigma.service;2import java.util.List;3import java.util.ArrayList;4import com.testsigma.service.CertificateService;5public class CertificateService_setPreSignedURLs {6 public static void main(String args[]) {7 CertificateService obj = new CertificateService();8 List<String> preSignedURLs = new ArrayList<String>();9 preSignedURLs.add("preSignedURLs1");10 preSignedURLs.add("preSignedURLs2");11 preSignedURLs.add("preSignedURLs3");12 preSignedURLs.add("preSignedURLs4");13 preSignedURLs.add("preSignedURLs5");14 obj.setPreSignedURLs(preSignedURLs);15 }16}17package com.testsigma.service;18import java.util.List;19import java.util.ArrayList;20import com.testsigma.service.CertificateService;21public class CertificateService_getPreSignedURLs {22 public static void main(String args[]) {23 CertificateService obj = new CertificateService();24 List<String> preSignedURLs = obj.getPreSignedURLs();25 for (String preSignedURL : preSignedURLs) {26 System.out.println(preSignedURL);27 }28 }29}30package com.testsigma.service;31import com.testsigma.service.CertificateService;32public class CertificateService_setCertificate {33 public static void main(String args[]) {34 CertificateService obj = new CertificateService();35 obj.setCertificate("certificate");36 }37}38package com.testsigma.service;39import com.testsigma.service.CertificateService;40public class CertificateService_getCertificate {41 public static void main(String args[]) {42 CertificateService obj = new CertificateService();43 String certificate = obj.getCertificate();44 System.out.println(certificate);45 }46}47package com.testsigma.service;48import com.testsigma.service.CertificateService;49public class CertificateService_setCertificateChain {50 public static void main(String args[]) {51 CertificateService obj = new CertificateService();52 obj.setCertificateChain("certificate

Full Screen

Full Screen

setPreSignedURLs

Using AI Code Generation

copy

Full Screen

1package com.testsigma.service;2import com.testsigma.service.CertificateService;3import com.testsigma.service.CertificateServiceService;4import com.testsigma.service.PreSignedURL;5import com.testsigma.service.PreSignedURLs;6import java.util.List;7public class CertificateServiceTest {8 public static void main(String[] args) {9 CertificateServiceService certificateServiceService = new CertificateServiceService();10 CertificateService certificateService = certificateServiceService.getCertificateServicePort();11 PreSignedURLs preSignedURLs = new PreSignedURLs();12 List<PreSignedURL> list = preSignedURLs.getPreSignedURL();13 PreSignedURL preSignedURL = new PreSignedURL();14 preSignedURL.setUrlType("web");15 list.add(preSignedURL);16 String result = certificateService.setPreSignedURLs(preSignedURLs);17 System.out.println("Result : " + result);18 }19}20package com.testsigma.service;21import com.testsigma.service.CertificateService;22import com.testsigma.service.CertificateServiceService;23import com.testsigma.service.PreSignedURL;24import com.testsigma.service.PreSignedURLs;25import java.util.List;26public class CertificateServiceTest {27 public static void main(String[] args) {28 CertificateServiceService certificateServiceService = new CertificateServiceService();29 CertificateService certificateService = certificateServiceService.getCertificateServicePort();30 PreSignedURLs preSignedURLs = new PreSignedURLs();31 List<PreSignedURL> list = preSignedURLs.getPreSignedURL();32 PreSignedURL preSignedURL = new PreSignedURL();33 preSignedURL.setUrlType("web");34 list.add(preSignedURL);35 String result = certificateService.setPreSignedURLs(preSignedURLs);36 System.out.println("Result : " + result);37 }38}39package com.testsigma.service;40import com.testsigma.service.CertificateService;41import com.testsigma.service.CertificateServiceService;42import com.testsigma.service.PreSignedURL;43import com.testsigma.service.PreSignedURLs;

Full Screen

Full Screen

setPreSignedURLs

Using AI Code Generation

copy

Full Screen

1package com.testsigma.service;2import com.testsigma.sdk.CertificateService;3import com.testsigma.sdk.CertificateServiceBuilder;4import com.testsigma.sdk.CertificateServiceBuilder.CertificateServiceBuilderException;5import com.testsigma.sdk.model.Certificate;6import com.testsigma.sdk.model.CertificateStatus;7import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder;8import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder.CertificateStatusBuilderException;9import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder.CertificateStatusBuilderException.CertificateStatusBuilderExceptionType;10import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder.CertificateStatusBuilderException.CertificateStatusBuilderExceptionType.CertificateStatusBuilderExceptionTypeType;11import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder.CertificateStatusBuilderException.CertificateStatusBuilderExceptionType.CertificateStatusBuilderExceptionTypeType.CertificateStatusBuilderExceptionTypeTypeType;12import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder.CertificateStatusBuilderException.CertificateStatusBuilderExceptionType.CertificateStatusBuilderExceptionTypeType.CertificateStatusBuilderExceptionTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeType;13import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder.CertificateStatusBuilderException.CertificateStatusBuilderExceptionType.CertificateStatusBuilderExceptionTypeType.CertificateStatusBuilderExceptionTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeTypeType;14import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder.CertificateStatusBuilderException.CertificateStatusBuilderExceptionType.CertificateStatusBuilderExceptionTypeType.CertificateStatusBuilderExceptionTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeTypeTypeType;15import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder.CertificateStatusBuilderException.CertificateStatusBuilderExceptionType.CertificateStatusBuilderExceptionTypeType.CertificateStatusBuilderExceptionTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeTypeTypeType;16import com.testsigma.sdk.model.CertificateStatus.CertificateStatusBuilder.CertificateStatusBuilderException.CertificateStatusBuilderExceptionType.CertificateStatusBuilderExceptionTypeType.CertificateStatusBuilderExceptionTypeTypeType.CertificateStatusBuilderExceptionTypeTypeTypeType.CertificateStatus

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful