tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/SSLCertificateService.java
private void deleteApprolePolicyAssociationOnCertificate(String certificateName, String token, JsonParser jsonParser,
			JsonObject object) {
        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, "Trying delete ApprolePolicyAssociationOnCertificate").
                put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
                build()));
        Map<String, String> appRoleParams = new HashMap<>();
		if (object.get("app-roles") != null) {
			JsonObject appRoleObj = ((JsonObject) jsonParser.parse(object.get("app-roles").toString()));
			appRoleParams = new Gson().fromJson(appRoleObj.toString(), Map.class);
			if (!appRoleParams.isEmpty()) {
				for (Map.Entry<String, String> entry : appRoleParams.entrySet()) {
					ResponseEntity<String> response = checkPolicyDetailsAndRemoveApproleFromCertificate(token,
			entry.getKey(), certificateName, entry.getValue(), object.get(SSLCertificateConstants.CERT_TYPE).getAsString());
					if (response.getStatusCode().equals(HttpStatus.OK)) {
						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,
										String.format("%s, App role is deleted as part of deleting certificate.",
												entry.getKey()))
								.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
								.build()));
					} 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,
										String.format("%s, App Role deletion as part of deleting certificate failed.",
												entry.getKey()))
								.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
								.build()));
					}
				}
			}
		}
    }
/**
     * Approle policy delete as part of certificate delete
     * @param certificateName
     * @param token
     * @param jsonParser
     * @param object
     */
Approle policy delete as part of certificate delete
@param certificateName
@param token
@param jsonParser
@param object
Approle policy delete as part of certificate delete @param certificateName @param token @param jsonParser @param object
private void deleteApprolePolicyAssociationOnCertificate(String certificateName, String token, JsonParser jsonParser,
			JsonObject object) {
        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, "Trying delete ApprolePolicyAssociationOnCertificate").
                put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
                build()));
        Map<String, String> appRoleParams = new HashMap<>();
		if (object.get("app-roles") != null) {
			JsonObject appRoleObj = ((JsonObject) jsonParser.parse(object.get("app-roles").toString()));
			appRoleParams = new Gson().fromJson(appRoleObj.toString(), Map.class);
			if (!appRoleParams.isEmpty()) {
				for (Map.Entry<String, String> entry : appRoleParams.entrySet()) {
					ResponseEntity<String> response = checkPolicyDetailsAndRemoveApproleFromCertificate(token,
			entry.getKey(), certificateName, entry.getValue(), object.get(SSLCertificateConstants.CERT_TYPE).getAsString());
					if (response.getStatusCode().equals(HttpStatus.OK)) {
						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,
										String.format("%s, App role is deleted as part of deleting certificate.",
												entry.getKey()))
								.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
								.build()));
					} 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,
										String.format("%s, App Role deletion as part of deleting certificate failed.",
												entry.getKey()))
								.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
								.build()));
					}
				}
			}
		}
    }
private void deleteApprolePolicyAssociationOnCertificate ( String certificateName , String token , JsonParser jsonParser , JsonObject object ) { 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 , "Trying delete ApprolePolicyAssociationOnCertificate" ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; Map < String , String > appRoleParams = new HashMap < > ( ) ; if ( object . get ( "app-roles" ) != null ) { JsonObject appRoleObj = ( ( JsonObject ) jsonParser . parse ( object . get ( "app-roles" ) . toString ( ) ) ) ; appRoleParams = new Gson ( ) . fromJson ( appRoleObj . toString ( ) , Map . class ) ; if ( ! appRoleParams . isEmpty ( ) ) { for ( Map . Entry < String , String > entry : appRoleParams . entrySet ( ) ) { ResponseEntity < String > response = checkPolicyDetailsAndRemoveApproleFromCertificate ( token , entry . getKey ( ) , certificateName , entry . getValue ( ) , object . get ( SSLCertificateConstants . CERT_TYPE ) . getAsString ( ) ) ; if ( response . getStatusCode ( ) . equals ( HttpStatus . OK ) ) { 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 , String . format ( "%s, App role is deleted as part of deleting certificate." , entry . getKey ( ) ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; } 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 , String . format ( "%s, App Role deletion as part of deleting certificate failed." , entry . getKey ( ) ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; } } } } }
Approle policy delete as part of certificate delete
 @param certificateName
 @param token
 @param jsonParser
 @param object
Approle policy delete as part of certificate delete @param certificateName @param token @param jsonParser @param object