tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/IAMServiceAccountsService.java
private boolean deleteIAMSvcAccAccessKeySecretFromVault(String token, String awsAccountId, String iamSvcAccName, String accessKeyId, JsonObject iamMetadataJson) {
		String uniqueSvcAccName = awsAccountId + "_" + iamSvcAccName;
		if (null != iamMetadataJson && iamMetadataJson.has("secret") && !iamMetadataJson.get("secret").isJsonNull()) {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG)
					.put(LogMessage.MESSAGE, String.format("Trying to delete access key and secret for the IAM Service account [%s]", uniqueSvcAccName))
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));

			JsonArray svcSecretArray = null;
			try {
				svcSecretArray = iamMetadataJson.get("secret").getAsJsonArray();
			} catch (IllegalStateException e) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG)
						.put(LogMessage.MESSAGE, String.format("Failed to get secret folders. Invalid metadata " + "for [%s].", uniqueSvcAccName))
						.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
				return false;
			}

			if (null != svcSecretArray) {
				return deleteAccessKeyAndSecret(token, accessKeyId, uniqueSvcAccName, svcSecretArray);
			}
		}
		return true;
	}
/**
	 * Method to delete IAM service account access keys and secret.
	 * @param token
	 * @param awsAccountId
	 * @param iamSvcAccName
	 * @return
	 */
Method to delete IAM service account access keys and secret.
Method to delete IAM service account access keys and secret .
private boolean deleteIAMSvcAccAccessKeySecretFromVault(String token, String awsAccountId, String iamSvcAccName, String accessKeyId, JsonObject iamMetadataJson) {
		String uniqueSvcAccName = awsAccountId + "_" + iamSvcAccName;
		if (null != iamMetadataJson && iamMetadataJson.has("secret") && !iamMetadataJson.get("secret").isJsonNull()) {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
					.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
					.put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG)
					.put(LogMessage.MESSAGE, String.format("Trying to delete access key and secret for the IAM Service account [%s]", uniqueSvcAccName))
					.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
			JsonArray svcSecretArray = null;
			try {
				svcSecretArray = iamMetadataJson.get("secret").getAsJsonArray();
			} catch (IllegalStateException e) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG)
						.put(LogMessage.MESSAGE, String.format("Failed to get secret folders. Invalid metadata " + "for [%s].", uniqueSvcAccName))
						.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
				return false;
			}
			if (null != svcSecretArray) {
				return deleteAccessKeyAndSecret(token, accessKeyId, uniqueSvcAccName, svcSecretArray);
			}
		}
		return true;
	}
private boolean deleteIAMSvcAccAccessKeySecretFromVault ( String token , String awsAccountId , String iamSvcAccName , String accessKeyId , JsonObject iamMetadataJson ) { String uniqueSvcAccName = awsAccountId + "_" + iamSvcAccName ; if ( null != iamMetadataJson && iamMetadataJson . has ( "secret" ) && ! iamMetadataJson . get ( "secret" ) . isJsonNull ( ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , IAMServiceAccountConstants . DELETE_IAMSVCACC_ACCESSKEY_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Trying to delete access key and secret for the IAM Service account [%s]" , uniqueSvcAccName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; JsonArray svcSecretArray = null ; try { svcSecretArray = iamMetadataJson . get ( "secret" ) . getAsJsonArray ( ) ; } catch ( IllegalStateException e ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , IAMServiceAccountConstants . DELETE_IAMSVCACC_ACCESSKEY_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Failed to get secret folders. Invalid metadata " + "for [%s]." , uniqueSvcAccName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return false ; } if ( null != svcSecretArray ) { return deleteAccessKeyAndSecret ( token , accessKeyId , uniqueSvcAccName , svcSecretArray ) ; } } return true ; }
Method to delete IAM service account access keys and secret.
Method to delete IAM service account access keys and secret .