tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
private ResponseEntity<String> checkPolicyDetailsAndRemoveGroupFromCertificate(String groupName,
			String certificateName, String authToken, String certificateType, UserDetails userDetails) {
		OIDCGroup oidcGroup = new OIDCGroup();

		// check for this group is associated to this certificate
		String sslCertMetaDataPath = (certificateType.equalsIgnoreCase(SSLCertificateConstants.INTERNAL))?
                new StringBuilder(SSLCertificateConstants.SSL_CERT_PATH).append("/").append(certificateName).toString() : new StringBuilder(SSLCertificateConstants.SSL_EXTERNAL_CERT_PATH).append("/").append(certificateName).toString();
		Response metadataReadResponse = reqProcessor.process("/read", "{\"path\":\"" + sslCertMetaDataPath + "\"}", authToken);
		
		Map<String, Object> responseMap = null;
		boolean metaDataResponseStatus = true;
		if(metadataReadResponse != null && HttpStatus.OK.equals(metadataReadResponse.getHttpstatus())) {
			responseMap = ControllerUtil.parseJson(metadataReadResponse.getResponse());
			if(responseMap.isEmpty()) {
				metaDataResponseStatus = false;
			}
		}
		else {
			metaDataResponseStatus = false;
		}

		if(metaDataResponseStatus) {
			@SuppressWarnings("unchecked")
			Map<String,Object> metadataMap = (Map<String,Object>)responseMap.get("data");
			Map<String,Object> groupsData = (Map<String,Object>)metadataMap.get(TVaultConstants.GROUPS);

			if (groupsData == null || !groupsData.containsKey(groupName)) {
				log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
						put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_GROUP_FROM_CERT_MSG).
						put(LogMessage.MESSAGE, String.format ("Group [%s] is not associated to certificate [%s]", groupName, certificateName)).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
						build()));
				return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Failed to remove group from certificate. Group association to certificate not found\"]}");
			}
		}else {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_GROUP_FROM_CERT_MSG).
					put(LogMessage.MESSAGE, String.format ("Error Fetching existing certificate info [%s]", certificateName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Error Fetching existing certificate info. please check the path specified\"]}");
		}

		return getGroupDetailsAndCallRemovalProcessForCert(groupName, certificateName, authToken, certificateType,
				userDetails, oidcGroup);
	}
/**
	 * Method to check the group policy and remove the group from certificate
	 * @param groupName
	 * @param certificateName
	 * @param authToken
	 * @return
	 */
Method to check the group policy and remove the group from certificate
@param groupName
@param certificateName
@param authToken
@return
Method to check the group policy and remove the group from certificate @param groupName @param certificateName @param authToken @return
private ResponseEntity<String> checkPolicyDetailsAndRemoveGroupFromCertificate(String groupName,
			String certificateName, String authToken, String certificateType, UserDetails userDetails) {
		OIDCGroup oidcGroup = new OIDCGroup();
		String sslCertMetaDataPath = (certificateType.equalsIgnoreCase(SSLCertificateConstants.INTERNAL))?
                new StringBuilder(SSLCertificateConstants.SSL_CERT_PATH).append("/").append(certificateName).toString() : new StringBuilder(SSLCertificateConstants.SSL_EXTERNAL_CERT_PATH).append("/").append(certificateName).toString();
		Response metadataReadResponse = reqProcessor.process("/read", "{\"path\":\"" + sslCertMetaDataPath + "\"}", authToken);
		Map<String, Object> responseMap = null;
		boolean metaDataResponseStatus = true;
		if(metadataReadResponse != null && HttpStatus.OK.equals(metadataReadResponse.getHttpstatus())) {
			responseMap = ControllerUtil.parseJson(metadataReadResponse.getResponse());
			if(responseMap.isEmpty()) {
				metaDataResponseStatus = false;
			}
		}
		else {
			metaDataResponseStatus = false;
		}
		if(metaDataResponseStatus) {
			@SuppressWarnings("unchecked")
			Map<String,Object> metadataMap = (Map<String,Object>)responseMap.get("data");
			Map<String,Object> groupsData = (Map<String,Object>)metadataMap.get(TVaultConstants.GROUPS);
			if (groupsData == null || !groupsData.containsKey(groupName)) {
				log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
						put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_GROUP_FROM_CERT_MSG).
						put(LogMessage.MESSAGE, String.format ("Group [%s] is not associated to certificate [%s]", groupName, certificateName)).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
						build()));
				return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Failed to remove group from certificate. Group association to certificate not found\"]}");
			}
		}else {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, SSLCertificateConstants.REMOVE_GROUP_FROM_CERT_MSG).
					put(LogMessage.MESSAGE, String.format ("Error Fetching existing certificate info [%s]", certificateName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Error Fetching existing certificate info. please check the path specified\"]}");
		}
		return getGroupDetailsAndCallRemovalProcessForCert(groupName, certificateName, authToken, certificateType,
				userDetails, oidcGroup);
	}
private ResponseEntity < String > checkPolicyDetailsAndRemoveGroupFromCertificate ( String groupName , String certificateName , String authToken , String certificateType , UserDetails userDetails ) { OIDCGroup oidcGroup = new OIDCGroup ( ) ; String sslCertMetaDataPath = ( certificateType . equalsIgnoreCase ( SSLCertificateConstants . INTERNAL ) ) ? new StringBuilder ( SSLCertificateConstants . SSL_CERT_PATH ) . append ( "/" ) . append ( certificateName ) . toString ( ) : new StringBuilder ( SSLCertificateConstants . SSL_EXTERNAL_CERT_PATH ) . append ( "/" ) . append ( certificateName ) . toString ( ) ; Response metadataReadResponse = reqProcessor . process ( "/read" , "{\"path\":\"" + sslCertMetaDataPath + "\"}" , authToken ) ; Map < String , Object > responseMap = null ; boolean metaDataResponseStatus = true ; if ( metadataReadResponse != null && HttpStatus . OK . equals ( metadataReadResponse . getHttpstatus ( ) ) ) { responseMap = ControllerUtil . parseJson ( metadataReadResponse . getResponse ( ) ) ; if ( responseMap . isEmpty ( ) ) { metaDataResponseStatus = false ; } } else { metaDataResponseStatus = false ; } if ( metaDataResponseStatus ) { @ SuppressWarnings ( "unchecked" ) Map < String , Object > metadataMap = ( Map < String , Object > ) responseMap . get ( "data" ) ; Map < String , Object > groupsData = ( Map < String , Object > ) metadataMap . get ( TVaultConstants . GROUPS ) ; if ( groupsData == null || ! groupsData . containsKey ( groupName ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . REMOVE_GROUP_FROM_CERT_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Group [%s] is not associated to certificate [%s]" , groupName , certificateName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Failed to remove group from certificate. Group association to certificate not found\"]}" ) ; } } else { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , SSLCertificateConstants . REMOVE_GROUP_FROM_CERT_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Error Fetching existing certificate info [%s]" , certificateName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Error Fetching existing certificate info. please check the path specified\"]}" ) ; } return getGroupDetailsAndCallRemovalProcessForCert ( groupName , certificateName , authToken , certificateType , userDetails , oidcGroup ) ; }
Method to check the group policy and remove the group from certificate
 @param groupName
 @param certificateName
 @param authToken
 @return
Method to check the group policy and remove the group from certificate @param groupName @param certificateName @param authToken @return
// check for this group is associated to this certificate