tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/IAMServiceAccountsService.java
private boolean deleteAccessKeyAndSecret(String token, String accessKeyId, String uniqueSvcAccName,
			JsonArray svcSecretArray) {
		int deleteCount = 0;
		for (int i = 0; i < svcSecretArray.size(); i++) {
			JsonObject iamSecret = (JsonObject) svcSecretArray.get(i);
			if (iamSecret.has(IAMServiceAccountConstants.ACCESS_KEY_ID) && accessKeyId
					.equals(iamSecret.get(IAMServiceAccountConstants.ACCESS_KEY_ID).getAsString())) {
				// get the correct secret folder name for an accesskeyid
				String folderName = getSecretFolderNameForAccessKeyId(token, uniqueSvcAccName, accessKeyId);
				String folderPath = new StringBuilder(IAMServiceAccountConstants.IAM_SVCC_ACC_PATH).append(uniqueSvcAccName).append("/").append(folderName).toString();
				Response deleteFolderResponse = reqProcessor.process(DELETEPATH, PATHSTR + folderPath + "\"}", token);
				if (deleteFolderResponse.getHttpstatus().equals(HttpStatus.NO_CONTENT)
						|| deleteFolderResponse.getHttpstatus().equals(HttpStatus.OK)) {
					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("Deleted access key [%s] and secret for the IAM Service account [%s]",
											accessKeyId, uniqueSvcAccName))
							.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
							.build()));

					deleteCount++;
				}
			}
		}
		return (deleteCount > 0);
	}
/**
	 * Method to delete the access key from vault path.
	 * @param token
	 * @param accessKeyId
	 * @param uniqueSvcAccName
	 * @param svcSecretArray
	 * @return
	 */
Method to delete the access key from vault path.
Method to delete the access key from vault path .
private boolean deleteAccessKeyAndSecret(String token, String accessKeyId, String uniqueSvcAccName,
			JsonArray svcSecretArray) {
		int deleteCount = 0;
		for (int i = 0; i < svcSecretArray.size(); i++) {
			JsonObject iamSecret = (JsonObject) svcSecretArray.get(i);
			if (iamSecret.has(IAMServiceAccountConstants.ACCESS_KEY_ID) && accessKeyId
					.equals(iamSecret.get(IAMServiceAccountConstants.ACCESS_KEY_ID).getAsString())) {
				String folderName = getSecretFolderNameForAccessKeyId(token, uniqueSvcAccName, accessKeyId);
				String folderPath = new StringBuilder(IAMServiceAccountConstants.IAM_SVCC_ACC_PATH).append(uniqueSvcAccName).append("/").append(folderName).toString();
				Response deleteFolderResponse = reqProcessor.process(DELETEPATH, PATHSTR + folderPath + "\"}", token);
				if (deleteFolderResponse.getHttpstatus().equals(HttpStatus.NO_CONTENT)
						|| deleteFolderResponse.getHttpstatus().equals(HttpStatus.OK)) {
					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("Deleted access key [%s] and secret for the IAM Service account [%s]",
											accessKeyId, uniqueSvcAccName))
							.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
							.build()));
					deleteCount++;
				}
			}
		}
		return (deleteCount > 0);
	}
private boolean deleteAccessKeyAndSecret ( String token , String accessKeyId , String uniqueSvcAccName , JsonArray svcSecretArray ) { int deleteCount = 0 ; for ( int i = 0 ; i < svcSecretArray . size ( ) ; i ++ ) { JsonObject iamSecret = ( JsonObject ) svcSecretArray . get ( i ) ; if ( iamSecret . has ( IAMServiceAccountConstants . ACCESS_KEY_ID ) && accessKeyId . equals ( iamSecret . get ( IAMServiceAccountConstants . ACCESS_KEY_ID ) . getAsString ( ) ) ) { String folderName = getSecretFolderNameForAccessKeyId ( token , uniqueSvcAccName , accessKeyId ) ; String folderPath = new StringBuilder ( IAMServiceAccountConstants . IAM_SVCC_ACC_PATH ) . append ( uniqueSvcAccName ) . append ( "/" ) . append ( folderName ) . toString ( ) ; Response deleteFolderResponse = reqProcessor . process ( DELETEPATH , PATHSTR + folderPath + "\"}" , token ) ; if ( deleteFolderResponse . getHttpstatus ( ) . equals ( HttpStatus . NO_CONTENT ) || deleteFolderResponse . getHttpstatus ( ) . equals ( HttpStatus . OK ) ) { 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 ( "Deleted access key [%s] and secret for the IAM Service account [%s]" , accessKeyId , uniqueSvcAccName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; deleteCount ++ ; } } } return ( deleteCount > 0 ) ; }
Method to delete the access key from vault path.
Method to delete the access key from vault path .
// get the correct secret folder name for an accesskeyid