tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
public ResponseEntity<String> checkCertificateStatus(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, "checkCertificateStatus")	
					.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 (certType.equals(SSLCertificateConstants.EXTERNAL) && !isExternalCertEnabled){
            log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
                    .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
                    .put(LogMessage.ACTION, "checkCertificateStatus")
                    .put(LogMessage.MESSAGE,
                            "Failed to check 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 check status for external SSL certificate. Operation not allowed.\"]}");
        }

		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, "checkCertificateStatus")	
						.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 {	
				int containerId = certificateMetaData.getContainerId();	
				String nclmAccessToken = (isMockingEnabled(certType)) ? TVaultConstants.NCLM_MOCK_VALUE:getNclmToken();
				if(!StringUtils.isEmpty(nclmAccessToken)) {	
				try {
					CertificateData certData = (!isMockingEnabled(certType)) ? getLatestCertificate(certName,
                            nclmAccessToken, containerId):nclmMockUtil.getMockDataForRevoked();
					if(!ObjectUtils.isEmpty(certData) && certData.getCertificateId() != 0) {
						if(!certData.getCertificateStatus().equalsIgnoreCase("Revoked")) {	
							 return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"errors\":[\"Certificate is in Revoke Requested status\"]}");	
						}	
					}else {	
						return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)	
								.body("{\"errors\":[\"Certificate unavailable in system.\"]}");	
					}	
				} catch (Exception e) {	
					log.error(JSONUtil.getJSON(ImmutableMap.<String, String> builder()	
							.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
							.put(LogMessage.ACTION, String.format("Inside  Exception = [%s] =  Message [%s]",	
									Arrays.toString(e.getStackTrace()), e.getMessage()))	
							.build()));	
					return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)	
							.body(ERRORS + e.getMessage() + "\"]}");	
				}	
				}else {	
	            	log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().	
	                        put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
	                        put(LogMessage.ACTION, "checkStatus").	
	                        put(LogMessage.MESSAGE, SSLCertificateConstants.NCLM_DOWN_MSG).                        	
	                        put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
	                        build()));	
	            	return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)	
	    					.body(ERRORS + nclmErrorMessage + "\"]}");
	            }	
				return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"Certificate is in Revoked status \"]}");
			}	
		} 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 add users to 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 check certificate status	
	 * certificate details	
	 * @param certName	
	 * @param certType	
	 * @param userDetails	
	 * @return	
	 */
Method to check certificate status
certificate details
@param certName
@param certType
@param userDetails
@return
Method to check certificate status certificate details @param certName @param certType @param userDetails @return
public ResponseEntity<String> checkCertificateStatus(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, "checkCertificateStatus")	
					.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.equals(SSLCertificateConstants.EXTERNAL) && !isExternalCertEnabled){
            log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
                    .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
                    .put(LogMessage.ACTION, "checkCertificateStatus")
                    .put(LogMessage.MESSAGE,
                            "Failed to check 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 check status for external SSL certificate. Operation not allowed.\"]}");
        }
		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, "checkCertificateStatus")	
						.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 {	
				int containerId = certificateMetaData.getContainerId();	
				String nclmAccessToken = (isMockingEnabled(certType)) ? TVaultConstants.NCLM_MOCK_VALUE:getNclmToken();
				if(!StringUtils.isEmpty(nclmAccessToken)) {	
				try {
					CertificateData certData = (!isMockingEnabled(certType)) ? getLatestCertificate(certName,
                            nclmAccessToken, containerId):nclmMockUtil.getMockDataForRevoked();
					if(!ObjectUtils.isEmpty(certData) && certData.getCertificateId() != 0) {
						if(!certData.getCertificateStatus().equalsIgnoreCase("Revoked")) {	
							 return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"errors\":[\"Certificate is in Revoke Requested status\"]}");	
						}	
					}else {	
						return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)	
								.body("{\"errors\":[\"Certificate unavailable in system.\"]}");	
					}	
				} catch (Exception e) {	
					log.error(JSONUtil.getJSON(ImmutableMap.<String, String> builder()	
							.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
							.put(LogMessage.ACTION, String.format("Inside  Exception = [%s] =  Message [%s]",	
									Arrays.toString(e.getStackTrace()), e.getMessage()))	
							.build()));	
					return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)	
							.body(ERRORS + e.getMessage() + "\"]}");	
				}	
				}else {	
	            	log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().	
	                        put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
	                        put(LogMessage.ACTION, "checkStatus").	
	                        put(LogMessage.MESSAGE, SSLCertificateConstants.NCLM_DOWN_MSG).                        	
	                        put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
	                        build()));	
	            	return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)	
	    					.body(ERRORS + nclmErrorMessage + "\"]}");
	            }	
				return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"Certificate is in Revoked status \"]}");
			}	
		} 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 add users to 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 > checkCertificateStatus ( 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 , "checkCertificateStatus" ) . 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 . equals ( SSLCertificateConstants . EXTERNAL ) && ! isExternalCertEnabled ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , "checkCertificateStatus" ) . put ( LogMessage . MESSAGE , "Failed to check 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 check status for external SSL certificate. Operation not allowed.\"]}" ) ; } 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 , "checkCertificateStatus" ) . 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 { int containerId = certificateMetaData . getContainerId ( ) ; String nclmAccessToken = ( isMockingEnabled ( certType ) ) ? TVaultConstants . NCLM_MOCK_VALUE : getNclmToken ( ) ; if ( ! StringUtils . isEmpty ( nclmAccessToken ) ) { try { CertificateData certData = ( ! isMockingEnabled ( certType ) ) ? getLatestCertificate ( certName , nclmAccessToken , containerId ) : nclmMockUtil . getMockDataForRevoked ( ) ; if ( ! ObjectUtils . isEmpty ( certData ) && certData . getCertificateId ( ) != 0 ) { if ( ! certData . getCertificateStatus ( ) . equalsIgnoreCase ( "Revoked" ) ) { return ResponseEntity . status ( HttpStatus . UNPROCESSABLE_ENTITY ) . body ( "{\"errors\":[\"Certificate is in Revoke Requested status\"]}" ) ; } } else { return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( "{\"errors\":[\"Certificate unavailable in system.\"]}" ) ; } } catch ( Exception e ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , String . format ( "Inside  Exception = [%s] =  Message [%s]" , Arrays . toString ( e . getStackTrace ( ) ) , e . getMessage ( ) ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( ERRORS + e . getMessage ( ) + "\"]}" ) ; } } else { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , "checkStatus" ) . put ( LogMessage . MESSAGE , SSLCertificateConstants . NCLM_DOWN_MSG ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( ERRORS + nclmErrorMessage + "\"]}" ) ; } return ResponseEntity . status ( HttpStatus . OK ) . body ( "{\"messages\":[\"Certificate is in Revoked status \"]}" ) ; } } 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 add users to 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 check certificate status
 certificate details
 @param certName
 @param certType
 @param userDetails
 @return
Method to check certificate status certificate details @param certName @param certType @param userDetails @return
// External certificate disabled check