tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
public ResponseEntity<String> validateApprovalStatusAndGetCertificateDetails(String certName, String certType,
			UserDetails userDetails) {
		if (!isValidInputs(certName, certType)) {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
					.put(LogMessage.MESSAGE, SSLCertificateConstants.INVALID_INPUT_MSG)
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ERRORINVALID);
		}
		if (!certType.equalsIgnoreCase("external")) {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
					.put(LogMessage.MESSAGE, SSLCertificateConstants.INVALID_INPUT_MSG)
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ERRORINVALID);
		}
        // External certificate disabled check
        if (!isExternalCertEnabled){
            log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
                    .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
                    .put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
                    .put(LogMessage.MESSAGE,
                            "Failed to validate approval status for external SSL certificate. Operation not allowed.")
                    .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
            return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(
                    "{\"errors\":[\"Failed to validate approval status for external SSL certificate. Operation not allowed.\"]}");
        }

		String metaDataPath = (certType.equalsIgnoreCase(SSLCertificateConstants.INTERNAL)) ? SSLCertificateConstants.SSL_CERT_PATH
				: SSLCertificateConstants.SSL_EXTERNAL_CERT_PATH;
		String certificatePath = metaDataPath + '/' + certName;
		String authToken = null;
		if (!ObjectUtils.isEmpty(userDetails)) {
			if (userDetails.isAdmin()) {
				authToken = userDetails.getClientToken();
			} else {
				authToken = userDetails.getSelfSupportToken();
			}
			SSLCertificateMetadataDetails certificateMetaData = certificateUtils.getCertificateMetaData(authToken,
					certName, certType);
			if (ObjectUtils.isEmpty(certificateMetaData)) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
						.put(LogMessage.MESSAGE, "No certificate available")
						.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
				return ResponseEntity.status(HttpStatus.BAD_REQUEST)
						.body("{\"errors\":[\"No certificate available\"]}");
			} else {

				if (certificateMetaData.getRequestStatus()!=null && certificateMetaData.getRequestStatus().equalsIgnoreCase(SSLCertificateConstants.APPROVED)) {
					return ResponseEntity.status(HttpStatus.BAD_REQUEST)
							.body("{\"errors\":[\"Certificate already approved\"]}");
				}

				if ((!userDetails.isAdmin() && !userDetails.isCertAdmin()) && (userDetails.getUsername() != null)
						&& (!userDetails.getUsername().equalsIgnoreCase(certificateMetaData.getCertOwnerNtid()))) {
					log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
							.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
							.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
							.put(LogMessage.MESSAGE, "Access denied: No permission to access this certificate")
							.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
							.build()));
					return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
							.body("{\"errors\":[\"Access denied: No permission to access this certificate\"]}");
				}
				return getCertificateDetailsAndProcessMetadata(certificatePath, authToken, certificateMetaData, userDetails);
			}
		} else {
			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
					.put(LogMessage.MESSAGE, "Access denied: No permission to access this certificate")
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
			return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
					.body("{\"errors\":[\"Access denied: No permission to access this certificate\"]}");
		}
	}
/**
	 * Method to validate certificate approval status in nclm and get the latest
	 * certificate details
	 * @param certName
	 * @param certType
	 * @param userDetails
	 * @return
	 */
Method to validate certificate approval status in nclm and get the latest
certificate details
@param certName
@param certType
@param userDetails
@return
Method to validate certificate approval status in nclm and get the latest certificate details @param certName @param certType @param userDetails @return
public ResponseEntity<String> validateApprovalStatusAndGetCertificateDetails(String certName, String certType,
			UserDetails userDetails) {
		if (!isValidInputs(certName, certType)) {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
					.put(LogMessage.MESSAGE, SSLCertificateConstants.INVALID_INPUT_MSG)
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ERRORINVALID);
		}
		if (!certType.equalsIgnoreCase("external")) {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
					.put(LogMessage.MESSAGE, SSLCertificateConstants.INVALID_INPUT_MSG)
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(ERRORINVALID);
		}
        if (!isExternalCertEnabled){
            log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
                    .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
                    .put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
                    .put(LogMessage.MESSAGE,
                            "Failed to validate approval status for external SSL certificate. Operation not allowed.")
                    .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
            return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(
                    "{\"errors\":[\"Failed to validate approval status for external SSL certificate. Operation not allowed.\"]}");
        }
		String metaDataPath = (certType.equalsIgnoreCase(SSLCertificateConstants.INTERNAL)) ? SSLCertificateConstants.SSL_CERT_PATH
				: SSLCertificateConstants.SSL_EXTERNAL_CERT_PATH;
		String certificatePath = metaDataPath + '/' + certName;
		String authToken = null;
		if (!ObjectUtils.isEmpty(userDetails)) {
			if (userDetails.isAdmin()) {
				authToken = userDetails.getClientToken();
			} else {
				authToken = userDetails.getSelfSupportToken();
			}
			SSLCertificateMetadataDetails certificateMetaData = certificateUtils.getCertificateMetaData(authToken,
					certName, certType);
			if (ObjectUtils.isEmpty(certificateMetaData)) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
						.put(LogMessage.MESSAGE, "No certificate available")
						.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
				return ResponseEntity.status(HttpStatus.BAD_REQUEST)
						.body("{\"errors\":[\"No certificate available\"]}");
			} else {
				if (certificateMetaData.getRequestStatus()!=null && certificateMetaData.getRequestStatus().equalsIgnoreCase(SSLCertificateConstants.APPROVED)) {
					return ResponseEntity.status(HttpStatus.BAD_REQUEST)
							.body("{\"errors\":[\"Certificate already approved\"]}");
				}
				if ((!userDetails.isAdmin() && !userDetails.isCertAdmin()) && (userDetails.getUsername() != null)
						&& (!userDetails.getUsername().equalsIgnoreCase(certificateMetaData.getCertOwnerNtid()))) {
					log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
							.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
							.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
							.put(LogMessage.MESSAGE, "Access denied: No permission to access this certificate")
							.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
							.build()));
					return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
							.body("{\"errors\":[\"Access denied: No permission to access this certificate\"]}");
				}
				return getCertificateDetailsAndProcessMetadata(certificatePath, authToken, certificateMetaData, userDetails);
			}
		} else {
			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, SSLCertificateConstants.VALIDATE_CERTIFICATE_DETAILS_MSG)
					.put(LogMessage.MESSAGE, "Access denied: No permission to access this certificate")
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
			return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
					.body("{\"errors\":[\"Access denied: No permission to access this certificate\"]}");
		}
	}
public ResponseEntity < String > validateApprovalStatusAndGetCertificateDetails ( String certName , String certType , UserDetails userDetails ) { if ( ! isValidInputs ( certName , certType ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . VALIDATE_CERTIFICATE_DETAILS_MSG ) . put ( LogMessage . MESSAGE , SSLCertificateConstants . INVALID_INPUT_MSG ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( ERRORINVALID ) ; } if ( ! certType . equalsIgnoreCase ( "external" ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . VALIDATE_CERTIFICATE_DETAILS_MSG ) . put ( LogMessage . MESSAGE , SSLCertificateConstants . INVALID_INPUT_MSG ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( ERRORINVALID ) ; } if ( ! isExternalCertEnabled ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . VALIDATE_CERTIFICATE_DETAILS_MSG ) . put ( LogMessage . MESSAGE , "Failed to validate approval status for external SSL certificate. Operation not allowed." ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . UNPROCESSABLE_ENTITY ) . body ( "{\"errors\":[\"Failed to validate approval status for external SSL certificate. Operation not allowed.\"]}" ) ; } String metaDataPath = ( certType . equalsIgnoreCase ( SSLCertificateConstants . INTERNAL ) ) ? SSLCertificateConstants . SSL_CERT_PATH : SSLCertificateConstants . SSL_EXTERNAL_CERT_PATH ; String certificatePath = metaDataPath + '/' + certName ; String authToken = null ; if ( ! ObjectUtils . isEmpty ( userDetails ) ) { if ( userDetails . isAdmin ( ) ) { authToken = userDetails . getClientToken ( ) ; } else { authToken = userDetails . getSelfSupportToken ( ) ; } SSLCertificateMetadataDetails certificateMetaData = certificateUtils . getCertificateMetaData ( authToken , certName , certType ) ; if ( ObjectUtils . isEmpty ( certificateMetaData ) ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . VALIDATE_CERTIFICATE_DETAILS_MSG ) . put ( LogMessage . MESSAGE , "No certificate available" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"No certificate available\"]}" ) ; } else { if ( certificateMetaData . getRequestStatus ( ) != null && certificateMetaData . getRequestStatus ( ) . equalsIgnoreCase ( SSLCertificateConstants . APPROVED ) ) { return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Certificate already approved\"]}" ) ; } if ( ( ! userDetails . isAdmin ( ) && ! userDetails . isCertAdmin ( ) ) && ( userDetails . getUsername ( ) != null ) && ( ! userDetails . getUsername ( ) . equalsIgnoreCase ( certificateMetaData . getCertOwnerNtid ( ) ) ) ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . VALIDATE_CERTIFICATE_DETAILS_MSG ) . put ( LogMessage . MESSAGE , "Access denied: No permission to access this certificate" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( "{\"errors\":[\"Access denied: No permission to access this certificate\"]}" ) ; } return getCertificateDetailsAndProcessMetadata ( certificatePath , authToken , certificateMetaData , userDetails ) ; } } else { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . VALIDATE_CERTIFICATE_DETAILS_MSG ) . put ( LogMessage . MESSAGE , "Access denied: No permission to access this certificate" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( "{\"errors\":[\"Access denied: No permission to access this certificate\"]}" ) ; } }
Method to validate certificate approval status in nclm and get the latest
 certificate details
 @param certName
 @param certType
 @param userDetails
 @return
Method to validate certificate approval status in nclm and get the latest certificate details @param certName @param certType @param userDetails @return
// External certificate disabled check