tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
public ResponseEntity<String> saveAllAppDetailsForOldCerts(String token, UserDetails userDetails)
				 {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, SSLCertificateConstants.GET_ALL_PENDING_CERT_MSG)
					.put(LogMessage.MESSAGE, "Trying to get all certificates to save the application path")
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));

			if (ObjectUtils.isEmpty(userDetails) || (!userDetails.isAdmin() && !userDetails.isCertAdmin())) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, SSLCertificateConstants.GET_ALL_PENDING_CERT_MSG)
						.put(LogMessage.MESSAGE, "Access denied: No permission to get the certificates details")
						.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));

				return ResponseEntity.status(HttpStatus.BAD_REQUEST)
						.body("{\"errors\":[\"Access denied: No permission to get the certificates details\"]}");
			}
			
			List<CertificateData> certificatesList = new ArrayList<>();
			String internalMetaDataPath = SSLCertificateConstants.SSL_CERT_PATH;
			String externalMetaDataPath = SSLCertificateConstants.SSL_EXTERNAL_CERT_PATH;
	       	Response internalResponse;
	       	Response externalResponse;
	       	String certListStr = "";
	       	JsonParser jsonParser = new JsonParser();

	        internalResponse = getMetadata(token, internalMetaDataPath);

	        if (HttpStatus.OK.equals(internalResponse.getHttpstatus())) {
	        JsonObject jsonObject = (JsonObject) jsonParser.parse(internalResponse.getResponse());
	   		JsonArray jsonArray = jsonObject.getAsJsonObject("data").getAsJsonArray("keys");
	   		List<String> internalCertNames = geMatchCertificates(jsonArray,"");
	   		
	   		boolean isInternalSaved = saveApplicationDetailsForOldCerts(internalCertNames,"internal", token);
	        }
             // External certificate disabled check
             if (isExternalCertEnabled){
                 externalResponse = getMetadata(token, externalMetaDataPath);
                 if (HttpStatus.OK.equals(externalResponse.getHttpstatus())) {
                     JsonObject jsonObjectExt = (JsonObject) jsonParser.parse(externalResponse.getResponse());
                     JsonArray jsonArrayExt = jsonObjectExt.getAsJsonObject("data").getAsJsonArray("keys");
                     List<String> externalCertNames = geMatchCertificates(jsonArrayExt,"");
                     boolean isExternalSaved = saveApplicationDetailsForOldCerts(externalCertNames,"external", token);
                 }
             }
			return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"Application details updation is successfully completed.\"]}");

	 }
/**
	  * Method to save application details for older certificates
	  * @param token
	  * @param userDetails
	  * @return
	  * @throws Exception
	  */
Method to save application details for older certificates
@param token
@param userDetails
@return
@throws Exception
Method to save application details for older certificates @param token @param userDetails @return @throws Exception
public ResponseEntity<String> saveAllAppDetailsForOldCerts(String token, UserDetails userDetails)
				 {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, SSLCertificateConstants.GET_ALL_PENDING_CERT_MSG)
					.put(LogMessage.MESSAGE, "Trying to get all certificates to save the application path")
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
			if (ObjectUtils.isEmpty(userDetails) || (!userDetails.isAdmin() && !userDetails.isCertAdmin())) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, SSLCertificateConstants.GET_ALL_PENDING_CERT_MSG)
						.put(LogMessage.MESSAGE, "Access denied: No permission to get the certificates details")
						.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
				return ResponseEntity.status(HttpStatus.BAD_REQUEST)
						.body("{\"errors\":[\"Access denied: No permission to get the certificates details\"]}");
			}
			List<CertificateData> certificatesList = new ArrayList<>();
			String internalMetaDataPath = SSLCertificateConstants.SSL_CERT_PATH;
			String externalMetaDataPath = SSLCertificateConstants.SSL_EXTERNAL_CERT_PATH;
	       	Response internalResponse;
	       	Response externalResponse;
	       	String certListStr = "";
	       	JsonParser jsonParser = new JsonParser();
	        internalResponse = getMetadata(token, internalMetaDataPath);
	        if (HttpStatus.OK.equals(internalResponse.getHttpstatus())) {
	        JsonObject jsonObject = (JsonObject) jsonParser.parse(internalResponse.getResponse());
	   		JsonArray jsonArray = jsonObject.getAsJsonObject("data").getAsJsonArray("keys");
	   		List<String> internalCertNames = geMatchCertificates(jsonArray,"");
	   		boolean isInternalSaved = saveApplicationDetailsForOldCerts(internalCertNames,"internal", token);
	        }
             if (isExternalCertEnabled){
                 externalResponse = getMetadata(token, externalMetaDataPath);
                 if (HttpStatus.OK.equals(externalResponse.getHttpstatus())) {
                     JsonObject jsonObjectExt = (JsonObject) jsonParser.parse(externalResponse.getResponse());
                     JsonArray jsonArrayExt = jsonObjectExt.getAsJsonObject("data").getAsJsonArray("keys");
                     List<String> externalCertNames = geMatchCertificates(jsonArrayExt,"");
                     boolean isExternalSaved = saveApplicationDetailsForOldCerts(externalCertNames,"external", token);
                 }
             }
			return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"Application details updation is successfully completed.\"]}");
	 }
public ResponseEntity < String > saveAllAppDetailsForOldCerts ( String token , UserDetails userDetails ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . GET_ALL_PENDING_CERT_MSG ) . put ( LogMessage . MESSAGE , "Trying to get all certificates to save the application path" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; if ( ObjectUtils . isEmpty ( userDetails ) || ( ! userDetails . isAdmin ( ) && ! userDetails . isCertAdmin ( ) ) ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . GET_ALL_PENDING_CERT_MSG ) . put ( LogMessage . MESSAGE , "Access denied: No permission to get the certificates details" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Access denied: No permission to get the certificates details\"]}" ) ; } List < CertificateData > certificatesList = new ArrayList < > ( ) ; String internalMetaDataPath = SSLCertificateConstants . SSL_CERT_PATH ; String externalMetaDataPath = SSLCertificateConstants . SSL_EXTERNAL_CERT_PATH ; Response internalResponse ; Response externalResponse ; String certListStr = "" ; JsonParser jsonParser = new JsonParser ( ) ; internalResponse = getMetadata ( token , internalMetaDataPath ) ; if ( HttpStatus . OK . equals ( internalResponse . getHttpstatus ( ) ) ) { JsonObject jsonObject = ( JsonObject ) jsonParser . parse ( internalResponse . getResponse ( ) ) ; JsonArray jsonArray = jsonObject . getAsJsonObject ( "data" ) . getAsJsonArray ( "keys" ) ; List < String > internalCertNames = geMatchCertificates ( jsonArray , "" ) ; boolean isInternalSaved = saveApplicationDetailsForOldCerts ( internalCertNames , "internal" , token ) ; } if ( isExternalCertEnabled ) { externalResponse = getMetadata ( token , externalMetaDataPath ) ; if ( HttpStatus . OK . equals ( externalResponse . getHttpstatus ( ) ) ) { JsonObject jsonObjectExt = ( JsonObject ) jsonParser . parse ( externalResponse . getResponse ( ) ) ; JsonArray jsonArrayExt = jsonObjectExt . getAsJsonObject ( "data" ) . getAsJsonArray ( "keys" ) ; List < String > externalCertNames = geMatchCertificates ( jsonArrayExt , "" ) ; boolean isExternalSaved = saveApplicationDetailsForOldCerts ( externalCertNames , "external" , token ) ; } } return ResponseEntity . status ( HttpStatus . OK ) . body ( "{\"messages\":[\"Application details updation is successfully completed.\"]}" ) ; }
Method to save application details for older certificates
 @param token
 @param userDetails
 @return
 @throws Exception
Method to save application details for older certificates @param token @param userDetails @return @throws Exception
// External certificate disabled check