@Test public void getRevocationReasons_Success() throws Exception { Integer certficateId = 123; String token = "FSR&&%S*"; String jsonStr = "{ \"username\": \"testusername1\", \"password\": \"testpassword1\"}"; Map<String, Object> requestMap = new HashMap<>(); requestMap.put("access_token", "12345"); requestMap.put("token_type", "type"); when(ControllerUtil.parseJson(jsonStr)).thenReturn(requestMap); CertManagerLogin certManagerLogin = new CertManagerLogin(); certManagerLogin.setToken_type("token type"); certManagerLogin.setAccess_token("1234"); CertResponse response = new CertResponse(); response.setHttpstatus(HttpStatus.OK); response.setResponse(jsonStr); response.setSuccess(true); when(reqProcessor.processCert(eq("/auth/certmanager/login"), anyObject(), anyString(), anyString())).thenReturn(response); String jsonStr2 ="{\"time_enabled\":false,\"details_enabled\":false,\"reasons\":[{\"reason\":\"unspecified\",\"displayName\":\"Unspecified\"},{\"reason\":\"keyCompromise\",\"displayName\":\"Key compromise\"},{\"reason\":\"cACompromise\",\"displayName\":\"CA compromise\"},{\"reason\":\"affiliationChanged\",\"displayName\":\"Affiliation changed\"},{\"reason\":\"superseded\",\"displayName\":\"Superseded\"},{\"reason\":\"cessationOfOperation\",\"displayName\":\"Cessation of operation\"},{\"reason\":\"certificateHold\",\"displayName\":\"Certificate hold\"}]}"; CertResponse revocationResponse = new CertResponse(); revocationResponse.setHttpstatus(HttpStatus.OK); revocationResponse.setResponse(jsonStr2); revocationResponse.setSuccess(true); when(reqProcessor.processCert(eq("/certificates/revocationreasons"), anyObject(), anyString(), anyString())).thenReturn(revocationResponse); ResponseEntity<?> enrollResponse = sSLCertificateService.getRevocationReasons(certficateId, token); assertNotNull(enrollResponse); assertEquals(HttpStatus.OK, enrollResponse.getStatusCode()); }
public ResponseEntity<String> getRevocationReasons(Integer certificateId, String token) { CertResponse revocationReasons = new CertResponse(); try { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, String.format("Trying to fetch Revocation Reasons for [%s]", certificateId)) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); String nclmAccessToken = nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ? TVaultConstants.NCLM_MOCK_VALUE : getNclmToken(); if(!StringUtils.isEmpty(nclmAccessToken)) { if(!nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ) { String nclmGetCertificateReasonsEndpoint = getCertifcateReasons.replace("certID", certificateId.toString()); revocationReasons = reqProcessor.processCert("/certificates/revocationreasons", certificateId, nclmAccessToken, getCertmanagerEndPoint(nclmGetCertificateReasonsEndpoint)); } else { revocationReasons = nclmMockUtil.getMockRevocationReasons(); } if (HttpStatus.INTERNAL_SERVER_ERROR.equals(revocationReasons.getHttpstatus())) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getRevocationReasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, "Fetch Revocation Reasons") .put(LogMessage.STATUS, revocationReasons.getHttpstatus().toString()) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); return ResponseEntity.status(revocationReasons.getHttpstatus()).body(revocationReasons.getResponse()); }else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "getRevocationeasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time."). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } } catch (TVaultValidationException error) { log.error( JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, String.format( "Inside TVaultValidationException " + "Exception = [%s] = Message [%s]", Arrays.toString(error.getStackTrace()), error.getMessage())) .build())); return ResponseEntity.status(HttpStatus.FORBIDDEN).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).toString()) .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\":[\"" + SSLCertificateConstants.SSL_CERTFICATE_REASONS_FAILED + "\"]}"); } }
SSLCertificateService { public ResponseEntity<String> getRevocationReasons(Integer certificateId, String token) { CertResponse revocationReasons = new CertResponse(); try { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, String.format("Trying to fetch Revocation Reasons for [%s]", certificateId)) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); String nclmAccessToken = nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ? TVaultConstants.NCLM_MOCK_VALUE : getNclmToken(); if(!StringUtils.isEmpty(nclmAccessToken)) { if(!nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ) { String nclmGetCertificateReasonsEndpoint = getCertifcateReasons.replace("certID", certificateId.toString()); revocationReasons = reqProcessor.processCert("/certificates/revocationreasons", certificateId, nclmAccessToken, getCertmanagerEndPoint(nclmGetCertificateReasonsEndpoint)); } else { revocationReasons = nclmMockUtil.getMockRevocationReasons(); } if (HttpStatus.INTERNAL_SERVER_ERROR.equals(revocationReasons.getHttpstatus())) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getRevocationReasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, "Fetch Revocation Reasons") .put(LogMessage.STATUS, revocationReasons.getHttpstatus().toString()) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); return ResponseEntity.status(revocationReasons.getHttpstatus()).body(revocationReasons.getResponse()); }else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "getRevocationeasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time."). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } } catch (TVaultValidationException error) { log.error( JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, String.format( "Inside TVaultValidationException " + "Exception = [%s] = Message [%s]", Arrays.toString(error.getStackTrace()), error.getMessage())) .build())); return ResponseEntity.status(HttpStatus.FORBIDDEN).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).toString()) .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\":[\"" + SSLCertificateConstants.SSL_CERTFICATE_REASONS_FAILED + "\"]}"); } } }
SSLCertificateService { public ResponseEntity<String> getRevocationReasons(Integer certificateId, String token) { CertResponse revocationReasons = new CertResponse(); try { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, String.format("Trying to fetch Revocation Reasons for [%s]", certificateId)) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); String nclmAccessToken = nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ? TVaultConstants.NCLM_MOCK_VALUE : getNclmToken(); if(!StringUtils.isEmpty(nclmAccessToken)) { if(!nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ) { String nclmGetCertificateReasonsEndpoint = getCertifcateReasons.replace("certID", certificateId.toString()); revocationReasons = reqProcessor.processCert("/certificates/revocationreasons", certificateId, nclmAccessToken, getCertmanagerEndPoint(nclmGetCertificateReasonsEndpoint)); } else { revocationReasons = nclmMockUtil.getMockRevocationReasons(); } if (HttpStatus.INTERNAL_SERVER_ERROR.equals(revocationReasons.getHttpstatus())) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getRevocationReasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, "Fetch Revocation Reasons") .put(LogMessage.STATUS, revocationReasons.getHttpstatus().toString()) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); return ResponseEntity.status(revocationReasons.getHttpstatus()).body(revocationReasons.getResponse()); }else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "getRevocationeasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time."). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } } catch (TVaultValidationException error) { log.error( JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, String.format( "Inside TVaultValidationException " + "Exception = [%s] = Message [%s]", Arrays.toString(error.getStackTrace()), error.getMessage())) .build())); return ResponseEntity.status(HttpStatus.FORBIDDEN).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).toString()) .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\":[\"" + SSLCertificateConstants.SSL_CERTFICATE_REASONS_FAILED + "\"]}"); } }  }
SSLCertificateService { public ResponseEntity<String> getRevocationReasons(Integer certificateId, String token) { CertResponse revocationReasons = new CertResponse(); try { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, String.format("Trying to fetch Revocation Reasons for [%s]", certificateId)) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); String nclmAccessToken = nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ? TVaultConstants.NCLM_MOCK_VALUE : getNclmToken(); if(!StringUtils.isEmpty(nclmAccessToken)) { if(!nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ) { String nclmGetCertificateReasonsEndpoint = getCertifcateReasons.replace("certID", certificateId.toString()); revocationReasons = reqProcessor.processCert("/certificates/revocationreasons", certificateId, nclmAccessToken, getCertmanagerEndPoint(nclmGetCertificateReasonsEndpoint)); } else { revocationReasons = nclmMockUtil.getMockRevocationReasons(); } if (HttpStatus.INTERNAL_SERVER_ERROR.equals(revocationReasons.getHttpstatus())) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getRevocationReasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, "Fetch Revocation Reasons") .put(LogMessage.STATUS, revocationReasons.getHttpstatus().toString()) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); return ResponseEntity.status(revocationReasons.getHttpstatus()).body(revocationReasons.getResponse()); }else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "getRevocationeasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time."). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } } catch (TVaultValidationException error) { log.error( JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, String.format( "Inside TVaultValidationException " + "Exception = [%s] = Message [%s]", Arrays.toString(error.getStackTrace()), error.getMessage())) .build())); return ResponseEntity.status(HttpStatus.FORBIDDEN).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).toString()) .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\":[\"" + SSLCertificateConstants.SSL_CERTFICATE_REASONS_FAILED + "\"]}"); } }  ResponseEntity<String> authenticate(CertManagerLoginRequest certManagerLoginRequest); CertManagerLogin login(CertManagerLoginRequest certManagerLoginRequest); ResponseEntity<String> generateSSLCertificate(SSLCertificateRequest sslCertificateRequest,
                                                               UserDetails userDetails ,String token); ResponseEntity<String> getServiceCertificates(String token, UserDetails userDetails, String certName, Integer limit, Integer offset, String certType); String getNclmToken(); ResponseEntity<String> getTargetSystemList(String token, UserDetails userDetails,String certType); ResponseEntity<String> getTargetSystemServiceList(String token, UserDetails userDetails, String targetSystemId); ResponseEntity<String> getRevocationReasons(Integer certificateId, String token); ResponseEntity<String> issueRevocationRequest(String certType, String certificateName, UserDetails userDetails, String token,
			RevocationRequest revocationRequest); String getCurrentLocalDateTimeStamp(); Boolean validateOwnerPermissionForNonAdmin(UserDetails userDetails, String certificateName); ResponseEntity<String> addUserToCertificate(CertificateUser certificateUser, UserDetails userDetails, boolean addSudoPermission); ResponseEntity<String> addGroupToCertificate(UserDetails userDetails, String userToken, CertificateGroup certificateGroup); boolean isAuthorized(UserDetails userDetails, String certificatename, String certType); ResponseEntity<String> addingGroupToCertificate(String token, CertificateGroup certificateGroup, UserDetails userDetails); ResponseEntity<String> associateApproletoCertificate(CertificateApprole certificateApprole, UserDetails userDetails); boolean hasDownloadPermission(String certificateName, UserDetails userDetails, String certType); SSLCertificateMetadataDetails getCertificateMetadata(String token, String certificateName); ResponseEntity<InputStreamResource> downloadCertificateWithPrivateKey(String token, CertificateDownloadRequest certificateDownloadRequest, UserDetails userDetails); ResponseEntity<InputStreamResource> downloadCertificateWithPrivateKey(CertificateDownloadRequest certificateDownloadRequest, SSLCertificateMetadataDetails sslCertificateMetadataDetails); ResponseEntity<InputStreamResource> downloadCertificate(String token, UserDetails userDetails,
                                                                   String certificateName, String certificateType,
                                                                   String sslCertType); ResponseEntity<String> getCertificateDetails(String token, String certificateName, String certificateType); ResponseEntity<String> renewCertificate(String certType, String certificateName, UserDetails userDetails, String token); ResponseEntity<String> removeUserFromCertificate(CertificateUser certificateUser, UserDetails userDetails); ResponseEntity<String> removeGroupFromCertificate(CertificateGroup certificateGroup, UserDetails userDetails); ResponseEntity<String> getListOfCertificates(String token, String certificateType); ResponseEntity<String> updateCertOwner(String token, String certType,String certName,String certOwnerEmailId,  UserDetails userDetails); ResponseEntity<String> validateApprovalStatusAndGetCertificateDetails(String certName, String certType,
			UserDetails userDetails); ResponseEntity<String> deleteCertificate( String token, String certType, String certificateName, UserDetails userDetails); Boolean validateCertOwnerPermissionForNonAdmin(UserDetails userDetails, String certificateName, String certType); ResponseEntity<String> getAllCertificates(String token, String certName, Integer limit, Integer offset); ResponseEntity<String> getAllCertificatesOnCertType(UserDetails userDetails, String certificateType); ResponseEntity<String> checkCertificateStatus(String certName, String certType,	
			UserDetails userDetails); ResponseEntity<String> getAllSelfServiceGroups(UserDetails userDetails); ResponseEntity<String> removeGroupFromCertificateForDelete(CertificateGroup certificateGroup, UserDetails userDetails); }
SSLCertificateService { public ResponseEntity<String> getRevocationReasons(Integer certificateId, String token) { CertResponse revocationReasons = new CertResponse(); try { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, String.format("Trying to fetch Revocation Reasons for [%s]", certificateId)) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); String nclmAccessToken = nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ? TVaultConstants.NCLM_MOCK_VALUE : getNclmToken(); if(!StringUtils.isEmpty(nclmAccessToken)) { if(!nclmMockEnabled.equalsIgnoreCase(TVaultConstants.TRUE) ) { String nclmGetCertificateReasonsEndpoint = getCertifcateReasons.replace("certID", certificateId.toString()); revocationReasons = reqProcessor.processCert("/certificates/revocationreasons", certificateId, nclmAccessToken, getCertmanagerEndPoint(nclmGetCertificateReasonsEndpoint)); } else { revocationReasons = nclmMockUtil.getMockRevocationReasons(); } if (HttpStatus.INTERNAL_SERVER_ERROR.equals(revocationReasons.getHttpstatus())) { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)). put(LogMessage.ACTION, "getRevocationReasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, "Fetch Revocation Reasons") .put(LogMessage.MESSAGE, "Fetch Revocation Reasons") .put(LogMessage.STATUS, revocationReasons.getHttpstatus().toString()) .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()) .build())); return ResponseEntity.status(revocationReasons.getHttpstatus()).body(revocationReasons.getResponse()); }else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "getRevocationeasons"). put(LogMessage.MESSAGE, "NCLM services are down. Please try after some time."). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("{\"errors\":[\"" + nclmErrorMessage + "\"]}"); } } catch (TVaultValidationException error) { log.error( JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()) .put(LogMessage.ACTION, String.format( "Inside TVaultValidationException " + "Exception = [%s] = Message [%s]", Arrays.toString(error.getStackTrace()), error.getMessage())) .build())); return ResponseEntity.status(HttpStatus.FORBIDDEN).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).toString()) .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\":[\"" + SSLCertificateConstants.SSL_CERTFICATE_REASONS_FAILED + "\"]}"); } }  ResponseEntity<String> authenticate(CertManagerLoginRequest certManagerLoginRequest); CertManagerLogin login(CertManagerLoginRequest certManagerLoginRequest); ResponseEntity<String> generateSSLCertificate(SSLCertificateRequest sslCertificateRequest,
                                                               UserDetails userDetails ,String token); ResponseEntity<String> getServiceCertificates(String token, UserDetails userDetails, String certName, Integer limit, Integer offset, String certType); String getNclmToken(); ResponseEntity<String> getTargetSystemList(String token, UserDetails userDetails,String certType); ResponseEntity<String> getTargetSystemServiceList(String token, UserDetails userDetails, String targetSystemId); ResponseEntity<String> getRevocationReasons(Integer certificateId, String token); ResponseEntity<String> issueRevocationRequest(String certType, String certificateName, UserDetails userDetails, String token,
			RevocationRequest revocationRequest); String getCurrentLocalDateTimeStamp(); Boolean validateOwnerPermissionForNonAdmin(UserDetails userDetails, String certificateName); ResponseEntity<String> addUserToCertificate(CertificateUser certificateUser, UserDetails userDetails, boolean addSudoPermission); ResponseEntity<String> addGroupToCertificate(UserDetails userDetails, String userToken, CertificateGroup certificateGroup); boolean isAuthorized(UserDetails userDetails, String certificatename, String certType); ResponseEntity<String> addingGroupToCertificate(String token, CertificateGroup certificateGroup, UserDetails userDetails); ResponseEntity<String> associateApproletoCertificate(CertificateApprole certificateApprole, UserDetails userDetails); boolean hasDownloadPermission(String certificateName, UserDetails userDetails, String certType); SSLCertificateMetadataDetails getCertificateMetadata(String token, String certificateName); ResponseEntity<InputStreamResource> downloadCertificateWithPrivateKey(String token, CertificateDownloadRequest certificateDownloadRequest, UserDetails userDetails); ResponseEntity<InputStreamResource> downloadCertificateWithPrivateKey(CertificateDownloadRequest certificateDownloadRequest, SSLCertificateMetadataDetails sslCertificateMetadataDetails); ResponseEntity<InputStreamResource> downloadCertificate(String token, UserDetails userDetails,
                                                                   String certificateName, String certificateType,
                                                                   String sslCertType); ResponseEntity<String> getCertificateDetails(String token, String certificateName, String certificateType); ResponseEntity<String> renewCertificate(String certType, String certificateName, UserDetails userDetails, String token); ResponseEntity<String> removeUserFromCertificate(CertificateUser certificateUser, UserDetails userDetails); ResponseEntity<String> removeGroupFromCertificate(CertificateGroup certificateGroup, UserDetails userDetails); ResponseEntity<String> getListOfCertificates(String token, String certificateType); ResponseEntity<String> updateCertOwner(String token, String certType,String certName,String certOwnerEmailId,  UserDetails userDetails); ResponseEntity<String> validateApprovalStatusAndGetCertificateDetails(String certName, String certType,
			UserDetails userDetails); ResponseEntity<String> deleteCertificate( String token, String certType, String certificateName, UserDetails userDetails); Boolean validateCertOwnerPermissionForNonAdmin(UserDetails userDetails, String certificateName, String certType); ResponseEntity<String> getAllCertificates(String token, String certName, Integer limit, Integer offset); ResponseEntity<String> getAllCertificatesOnCertType(UserDetails userDetails, String certificateType); ResponseEntity<String> checkCertificateStatus(String certName, String certType,	
			UserDetails userDetails); ResponseEntity<String> getAllSelfServiceGroups(UserDetails userDetails); ResponseEntity<String> removeGroupFromCertificateForDelete(CertificateGroup certificateGroup, UserDetails userDetails); @Value("${sslcertmanager.targetsystemgroup.public_single_san.ts_gp_id}")
    private int public_single_san_ts_gp_id; @Value("${sslcertmanager.targetsystemgroup.public_multi_san.ts_gp_id}")
    private int public_multi_san_ts_gp_id; }