Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .github/workflows/flowvault-internal-release.yml

This file was deleted.

28 changes: 22 additions & 6 deletions .github/workflows/internal-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish v2 module to the JFROG Artifactory
name: Publish module to the JFROG Artifactory
on:
push:
tags-ignore:
Expand All @@ -7,21 +7,37 @@ on:
- "*.md"
branches:
- release/*
- flowvault-release/*

jobs:
build-and-deploy-v2:
resolve-module:
runs-on: ubuntu-latest
outputs:
module: ${{ steps.set-module.outputs.module }}
steps:
- name: Resolve module from branch name
id: set-module
run: |
if [[ "${{ github.ref_name }}" == flowvault-release/* ]]; then
echo "module=flowvault" >> "$GITHUB_OUTPUT"
else
echo "module=v2" >> "$GITHUB_OUTPUT"
fi

build-and-deploy:
needs: resolve-module
uses: ./.github/workflows/shared-build-and-deploy.yml
with:
ref: ${{ github.ref_name }}
server-id: central
profile: jfrog
tag: 'internal'
module: 'v2'
module: ${{ needs.resolve-module.outputs.module }}
secrets:
server-username: ${{ secrets.ARTIFACTORY_USERNAME }}
server-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
gpg-key: ${{ secrets.JFROG_GPG_KEY }}
gpg-passphrase: ${{ secrets.JFROG_GPG_PASSPHRASE }}
skyflow-credentials: ${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
test-expired-token: ${{ secrets.TEST_EXPIRED_TOKEN }} >> .env
test-reusable-token: ${{ secrets.TEST_REUSABLE_TOKEN }} >> .env
skyflow-credentials: ${{ secrets.SKYFLOW_CREDENTIALS }}
test-expired-token: ${{ secrets.TEST_EXPIRED_TOKEN }}
test-reusable-token: ${{ secrets.TEST_REUSABLE_TOKEN }}
2 changes: 1 addition & 1 deletion common/src/main/java/com/skyflow/BaseSkyflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Map;


abstract class BaseSkyflow<Self, V extends BaseVaultConfig, VC> implements ISkyflow<Self, V, Credentials, VC> {
abstract class BaseSkyflow<Self extends BaseSkyflow, V extends BaseVaultConfig, VC> implements ISkyflow<Self, V, Credentials, VC> {
protected final BaseSkyflowClientBuilder<V, VC> builder;

protected BaseSkyflow(BaseSkyflowClientBuilder<V, VC> builder) {
Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/com/skyflow/logs/ErrorLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public enum ErrorLogs {
EMPTY_DELETE_TOKENS_DATA("Invalid %s1 request. Delete tokens data can not be empty."),
EMPTY_OR_NULL_TOKEN_IN_DELETE_TOKENS_DATA("Invalid %s1 request. Token can not be null or empty in delete tokens data at index %s2."),
DELETE_TOKENS_SIZE_EXCEED("Maximum number of tokens exceeded. The limit is 10000."),
DELETE_TOKENS_REQUEST_REJECTED("DeleteTokens request resulted in failure."),

// invoke connection interface
INVOKE_CONNECTION_INVALID_CONNECTION_URL("Invalid %s1 request. Connection URL is not a valid URL."),
Expand Down
6 changes: 5 additions & 1 deletion common/src/main/java/com/skyflow/logs/WarningLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ public enum WarningLogs {
INVALID_BATCH_SIZE_PROVIDED("Invalid value for batch size provided, switching to default value."),
INVALID_CONCURRENCY_LIMIT_PROVIDED("Invalid value for concurrency limit provided, switching to default value."),
BATCH_SIZE_EXCEEDS_MAX_LIMIT("Provided batch size exceeds the maximum limit, switching to max limit."),
CONCURRENCY_EXCEEDS_MAX_LIMIT("Provided concurrency limit exceeds the maximum limit, switching to max limit.")
CONCURRENCY_EXCEEDS_MAX_LIMIT("Provided concurrency limit exceeds the maximum limit, switching to max limit."),
EMPTY_DELETE_TOKENS_RESPONSE("DeleteTokens response did not include any token results."),
INCOMPLETE_DELETE_TOKENS_RESPONSE("DeleteTokens response did not account for all requested tokens."),
EMPTY_TOKENIZE_RESPONSE("Tokenize response did not include any record results."),
INCOMPLETE_TOKENIZE_RESPONSE("Tokenize response did not account for all requested records.")
;

private final String log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static V1GetAuthTokenResponse generateBearerTokenFromCredentials(
} finally {
try { reader.close(); } catch (IOException ignored) {}
}
} catch (JsonSyntaxException e) {
} catch (JsonSyntaxException | IllegalStateException e) {
LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_FILE_FORMAT.getLog());
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), BaseUtils.parameterizedString(
ErrorMessage.FileInvalidJson.getMessage(), credentialsFile.getPath()));
Expand All @@ -87,7 +87,7 @@ private static V1GetAuthTokenResponse generateBearerTokenFromCredentialString(
}
JsonObject serviceAccountCredentials = JsonParser.parseString(credentials).getAsJsonObject();
return getBearerTokenFromCredentials(serviceAccountCredentials, context, roles);
} catch (JsonSyntaxException e) {
} catch (JsonSyntaxException | IllegalStateException e) {
LogUtil.printErrorLog(ErrorLogs.INVALID_CREDENTIALS_STRING_FORMAT.getLog());
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(),
ErrorMessage.CredentialsStringInvalidJson.getMessage());
Expand Down
100 changes: 98 additions & 2 deletions flowvault/src/main/java/com/skyflow/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.skyflow.generated.rest.types.*;
import com.skyflow.logs.ErrorLogs;
import com.skyflow.logs.InfoLogs;
import com.skyflow.logs.WarningLogs;
import com.skyflow.serviceaccount.util.BearerToken;
import com.skyflow.serviceaccount.util.Token;
import com.skyflow.utils.logger.LogUtil;
Expand Down Expand Up @@ -165,7 +166,7 @@ public static InsertResponse buildInsertResponse(V1InsertResponse res) {
ArrayList<HashMap<String, Object>> insertedFields = new ArrayList<>();
ArrayList<HashMap<String, Object>> errors = new ArrayList<>();

if (res.getRecords().isPresent()) {
if (res != null && res.getRecords().isPresent()) {
for (V1RecordResponseObject record : res.getRecords().get()) {
if (record.getError().isPresent()) {
HashMap<String, Object> errorRecord = new HashMap<>();
Expand Down Expand Up @@ -215,7 +216,7 @@ public static DetokenizeResponse buildDetokenizeResponse(V1FlowDetokenizeRespons
ArrayList<DetokenizeRecordResponse> detokenizedFields = new ArrayList<>();
ArrayList<DetokenizeRecordResponse> errors = new ArrayList<>();

if (res.getResponse().isPresent()) {
if (res != null && res.getResponse().isPresent()) {
for (V1FlowDetokenizeResponseObject record : res.getResponse().get()) {
String token = record.getToken().orElse(null);
String tokenGroupName = record.getTokenGroupName().orElse(null);
Expand All @@ -230,4 +231,99 @@ public static DetokenizeResponse buildDetokenizeResponse(V1FlowDetokenizeRespons
}
return new DetokenizeResponse(detokenizedFields, errors);
}

public static com.skyflow.generated.rest.resources.flowservice.requests.V1FlowDeleteTokenRequest getDeleteTokensRequestBody(DeleteTokensRequest request, String vaultid) {
return com.skyflow.generated.rest.resources.flowservice.requests.V1FlowDeleteTokenRequest.builder()
.vaultId(vaultid)
.tokens(request.getTokens())
.build();
}
private static String extractRequestId(Map<String, List<String>> headers) {
if (headers == null) return null;
List<String> ids = headers.get(BaseConstants.REQUEST_ID_HEADER_KEY);
return (ids == null || ids.isEmpty()) ? null : ids.get(0);
}

public static DeleteTokensResponse buildDeleteTokensResponse(V1FlowDeleteTokenResponse res, Map<String, List<String>> headers, int requestedTokenCount) {
ArrayList<String> deletedTokens = new ArrayList<>();
ArrayList<HashMap<String, Object>> errors = new ArrayList<>();
String requestId = extractRequestId(headers);
if (res != null && res.getTokens().isPresent()) {
for (V1DeleteTokenResponseObject record : res.getTokens().get()) {
if (record.getError().isPresent()) {
HashMap<String, Object> errorRecord = new HashMap<>();
errorRecord.put("error", record.getError().get());
record.getHttpCode().ifPresent(httpCode -> errorRecord.put("httpCode", httpCode));
errorRecord.put("requestId", requestId);
errors.add(errorRecord);
} else {
record.getValue().ifPresent(deletedTokens::add);
}
}
if (deletedTokens.size() + errors.size() != requestedTokenCount) {
LogUtil.printWarningLog(WarningLogs.INCOMPLETE_DELETE_TOKENS_RESPONSE.getLog());
}
} else {
LogUtil.printWarningLog(WarningLogs.EMPTY_DELETE_TOKENS_RESPONSE.getLog());
}
return new DeleteTokensResponse(deletedTokens, errors);
}

public static com.skyflow.generated.rest.resources.flowservice.requests.V1FlowTokenizeRequest getTokenizeRequestBody(TokenizeRequest request, String vaultid) {
List<V1FlowTokenizeRequestObject> dataList = new ArrayList<>();
for (TokenizeRecord record : request.getData()) {
V1FlowTokenizeRequestObject obj = V1FlowTokenizeRequestObject.builder()
.value(record.getValue())
.tokenGroupNames(record.getTokenGroupNames())
.build();
dataList.add(obj);
}
return com.skyflow.generated.rest.resources.flowservice.requests.V1FlowTokenizeRequest.builder()
.vaultId(vaultid)
.data(dataList)
.build();
}

public static TokenizeResponse buildTokenizeResponse(V1FlowTokenizeResponse res, Map<String, List<String>> headers, int requestedRecordCount) {
List<TokenizeData> tokenizedData = new ArrayList<>();
ArrayList<HashMap<String, Object>> errors = new ArrayList<>();
String requestId = extractRequestId(headers);
if (res != null && res.getResponse().isPresent()) {
List<V1FlowTokenizeResponseObject> records = res.getResponse().get();
int indexNumber = 0;
for (V1FlowTokenizeResponseObject record : records) {
Object value = record.getValue().orElse(null);
TokenizeData tokenizeData = new TokenizeData(value, indexNumber);
boolean hasAnySuccess = false;
if (record.getTokens().isPresent()) {
for (FlowTokenizeResponseObjectToken tokenObj : record.getTokens().get()) {
if (tokenObj.getError().isPresent()) {
HashMap<String, Object> errorRecord = new HashMap<>();
errorRecord.put("error", tokenObj.getError().get());
tokenObj.getHttpCode().ifPresent(httpCode -> errorRecord.put("httpCode", httpCode));
tokenObj.getTokenGroupName().ifPresent(name -> errorRecord.put("tokenGroupName", name));
errorRecord.put("index", indexNumber);
errorRecord.put("requestId", requestId);
errors.add(errorRecord);
} else if (tokenObj.getTokenGroupName().isPresent() && tokenObj.getToken().isPresent()) {
tokenizeData.addToken(tokenObj.getTokenGroupName().get(), tokenObj.getToken().get());
hasAnySuccess = true;
}
}
}
if (hasAnySuccess) {
tokenizedData.add(tokenizeData);
}
indexNumber++;
}
if (indexNumber != requestedRecordCount) {
LogUtil.printWarningLog(WarningLogs.INCOMPLETE_TOKENIZE_RESPONSE.getLog());
}
} else {
LogUtil.printWarningLog(WarningLogs.EMPTY_TOKENIZE_RESPONSE.getLog());
}
TokenizeResponse tokenizeResponse = new TokenizeResponse(errors);
tokenizeResponse.setTokenizedData(tokenizedData);
return tokenizeResponse;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ public static void validateInsertRequest(InsertRequest insertRequest) throws Sky
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyRecords.getMessage());
}
// else if (records.size() > 10000) {
// LogUtil.printErrorLog(ErrorLogs.RECORD_SIZE_EXCEED.getLog());
// throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.RecordSizeExceedError.getMessage());
// }

for (InsertRecord record : records) {
if(record == null){
LogUtil.printErrorLog(Utils.parameterizedString(
Expand Down Expand Up @@ -273,13 +270,10 @@ public static void validateDetokenizeRequest(DetokenizeRequest request) throws S
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyDetokenizeData.getMessage());
}
// if (tokens.size() > 10000) {
// LogUtil.printErrorLog(ErrorLogs.TOKENS_SIZE_EXCEED.getLog());
// throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.TokensSizeExceedError.getMessage());
// }

for (int index = 0; index < tokens.size(); index++) {
DetokenizeData token = tokens.get(index);
if (token != null && token.getToken().isEmpty() && token.getToken().trim().isEmpty()) {
if (token == null || token.getToken() == null || token.getToken().trim().isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.EMPTY_OR_NULL_TOKEN_IN_DETOKENIZE_DATA.getLog(),
InterfaceName.DETOKENIZE.getName(),
Expand Down Expand Up @@ -307,7 +301,84 @@ public static void validateDetokenizeRequest(DetokenizeRequest request) throws S
}
}
}

}

public static void validateDeleteTokensRequest(DeleteTokensRequest request) throws SkyflowException {
if (request == null) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.DELETE_TOKENS_REQUEST_NULL.getLog(), InterfaceName.DELETE.getName()
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.DeleteTokensRequestNull.getMessage());
}
List<String> tokens = request.getTokens();
if (tokens == null || tokens.isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.EMPTY_DELETE_TOKENS_DATA.getLog(), InterfaceName.DELETE.getName()
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyDeleteTokensData.getMessage());
}

for (int index = 0; index < tokens.size(); index++) {
String token = tokens.get(index);
if (token == null || token.trim().isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.EMPTY_OR_NULL_TOKEN_IN_DELETE_TOKENS_DATA.getLog(),
InterfaceName.DELETE.getName(),
String.valueOf(index)));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokenInDeleteTokensData.getMessage());
}
}
}

public static void validateTokenizeRequest(TokenizeRequest request) throws SkyflowException {
if (request == null) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.TOKENIZE_REQUEST_NULL.getLog(), InterfaceName.TOKENIZE.getName()
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.TokenizeRequestNull.getMessage());
}
ArrayList<TokenizeRecord> data = request.getData();
if (data == null || data.isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.EMPTY_TOKENIZE_DATA.getLog(), InterfaceName.TOKENIZE.getName()
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokenizeData.getMessage());
}
for (int index = 0; index < data.size(); index++) {
TokenizeRecord record = data.get(index);
if (record == null) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.TOKENIZE_RECORD_NULL.getLog(), InterfaceName.TOKENIZE.getName()
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.TokenizeRecordNull.getMessage());
}
Object value = record.getValue();
boolean isInvalidValue = value == null || (value instanceof String && ((String) value).trim().isEmpty());
if (isInvalidValue) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.EMPTY_VALUE_IN_TOKENIZE_RECORD.getLog(), InterfaceName.TOKENIZE.getName()
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyValueInTokenizeRecord.getMessage());
}
List<String> tokenGroupNames = record.getTokenGroupNames();
if (tokenGroupNames == null || tokenGroupNames.isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.EMPTY_TOKEN_GROUP_NAMES_IN_TOKENIZE_RECORD.getLog(), InterfaceName.TOKENIZE.getName()
));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokenGroupNamesInTokenizeRecord.getMessage());
}
for (int groupIndex = 0; groupIndex < tokenGroupNames.size(); groupIndex++) {
String groupName = tokenGroupNames.get(groupIndex);
if (groupName == null || groupName.trim().isEmpty()) {
LogUtil.printErrorLog(Utils.parameterizedString(
ErrorLogs.EMPTY_TOKEN_GROUP_NAME_IN_TOKENIZE_RECORD.getLog(),
InterfaceName.TOKENIZE.getName(),
String.valueOf(groupIndex)));
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.EmptyTokenGroupNameInTokenizeRecord.getMessage());
}
}
}
}

}
Loading
Loading