@Test public void testValidateApprovalStatusForInvalidUser() { ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("{\"errors\":[\"Access denied: No permission to access this certificate\"]}"); UserDetails userDetail = getMockUser(true); userDetail.setUsername("testuser1"); ReflectionTestUtils.setField(sSLCertificateService, "vaultAuthMethod", "ldap"); String certType = "external"; String certName = "certificatename.t-mobile.com"; ResponseEntity<?> enrollResponse = sSLCertificateService .validateApprovalStatusAndGetCertificateDetails(certName, certType, null); assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, enrollResponse.getStatusCode()); assertEquals(responseEntityExpected, enrollResponse); }
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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } 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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } String metaDataPath = (certType.equalsIgnoreCase("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().equalsIgnoreCase("Approved")) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body("{\"errors\":[\"Certificate already approved\"]}"); } if ((!userDetails.isAdmin()) && (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); } } 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\"]}"); } }
SSLCertificateService { 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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } 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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } String metaDataPath = (certType.equalsIgnoreCase("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().equalsIgnoreCase("Approved")) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body("{\"errors\":[\"Certificate already approved\"]}"); } if ((!userDetails.isAdmin()) && (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); } } 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\"]}"); } } }
SSLCertificateService { 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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } 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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } String metaDataPath = (certType.equalsIgnoreCase("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().equalsIgnoreCase("Approved")) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body("{\"errors\":[\"Certificate already approved\"]}"); } if ((!userDetails.isAdmin()) && (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); } } 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\"]}"); } }  }
SSLCertificateService { 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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } 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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } String metaDataPath = (certType.equalsIgnoreCase("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().equalsIgnoreCase("Approved")) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body("{\"errors\":[\"Certificate already approved\"]}"); } if ((!userDetails.isAdmin()) && (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); } } 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\"]}"); } }  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> 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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } 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, "Invalid user inputs") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Invalid input values\"]}"); } String metaDataPath = (certType.equalsIgnoreCase("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().equalsIgnoreCase("Approved")) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body("{\"errors\":[\"Certificate already approved\"]}"); } if ((!userDetails.isAdmin()) && (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); } } 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\"]}"); } }  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; }