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
1 change: 1 addition & 0 deletions common/src/main/java/com/skyflow/errors/ErrorMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public enum ErrorMessage {
JwtDecodeError("%s0 Validation error. Invalid access token. Verify your credentials."),
MissingAccessToken("%s0 Validation error. Access token not present in the response from bearer token generation. Verify your credentials."),
MissingTokenType("%s0 Validation error. Token type not present in the response from bearer token generation. Verify your credentials."),
BearerTokenExpired("%s0 Validation error. Bearer token is invalid or expired. Please provide a valid bearer token."),

// Insert
TableKeyError("%s0 Validation error. 'table' key is missing from the payload. Specify a 'table' key."),
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/java/com/skyflow/logs/ErrorLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ public enum ErrorLogs {

UNEXPECTED_ERROR_DURING_BATCH_PROCESSING("Unexpected error occurred during batch processing. Error: %s1"),

PROCESSING_ERROR_RESPONSE("Processing error response.")
;
PROCESSING_ERROR_RESPONSE("Processing error response.");

private final String log;

Expand Down
3 changes: 2 additions & 1 deletion common/src/main/java/com/skyflow/logs/InfoLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public enum InfoLogs {
GET_SIGNED_DATA_TOKENS_TRIGGERED("getSignedDataTokens method triggered."),
GET_SIGNED_DATA_TOKEN_SUCCESS("Signed data tokens generated."),
REUSE_BEARER_TOKEN("Reusing bearer token."),
REUSE_API_KEY("Reusing api key."),
USE_CLIENT_PROVIDED_BEARER_TOKEN("Using bearer token provided by client."),
USE_API_KEY("Using api key."),
GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_TRIGGERED("generateBearerTokenFromCredentials method triggered."),
GENERATE_BEARER_TOKEN_FROM_CREDENTIALS_STRING_TRIGGERED("generateBearerTokenFromCredentialString method triggered."),
GENERATE_SIGNED_TOKENS_FROM_CREDENTIALS_FILE_TRIGGERED("generateSignedTokensFromCredentialsFile method triggered."),
Expand Down
15 changes: 12 additions & 3 deletions common/src/main/java/com/skyflow/utils/BaseUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.skyflow.logs.ErrorLogs;
import com.skyflow.logs.InfoLogs;
import com.skyflow.serviceaccount.util.BearerToken;
import com.skyflow.serviceaccount.util.Token;
import com.skyflow.utils.logger.LogUtil;
import org.apache.commons.codec.binary.Base64;

Expand Down Expand Up @@ -43,23 +44,31 @@ public static String getVaultURL(String clusterId, Env env, String vaultDomain)
}

public static String generateBearerToken(Credentials credentials) throws SkyflowException {
String bearerToken;
if (credentials.getPath() != null) {
return BearerToken.builder()
bearerToken = BearerToken.builder()
.setCredentials(new File(credentials.getPath()))
.setRoles(credentials.getRoles())
.setCtx(credentials.getContext())
.build()
.getBearerToken();
} else if (credentials.getCredentialsString() != null) {
return BearerToken.builder()
bearerToken = BearerToken.builder()
.setCredentials(credentials.getCredentialsString())
.setRoles(credentials.getRoles())
.setCtx(credentials.getContext())
.build()
.getBearerToken();
} else {
return credentials.getToken();
LogUtil.printInfoLog(InfoLogs.USE_CLIENT_PROVIDED_BEARER_TOKEN.getLog());
bearerToken = credentials.getToken();
}
// check expiry for generated token
if (Token.isExpired(bearerToken)) {
LogUtil.printErrorLog(ErrorLogs.INVALID_BEARER_TOKEN.getLog());
throw new SkyflowException(ErrorCode.INVALID_INPUT.getCode(), ErrorMessage.BearerTokenExpired.getMessage());
}
return bearerToken;
}

public static PrivateKey getPrivateKeyFromPem(String pemKey) throws SkyflowException {
Expand Down
2 changes: 1 addition & 1 deletion v2/src/main/java/com/skyflow/ConnectionClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void setApiKey() {
if (apiKey == null) {
apiKey = this.finalCredentials.getApiKey();
} else {
LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog());
LogUtil.printInfoLog(InfoLogs.USE_API_KEY.getLog());
}
}

Expand Down
2 changes: 1 addition & 1 deletion v2/src/main/java/com/skyflow/VaultClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ protected void setBearerToken() throws SkyflowException {
prioritiseCredentials();
Validations.validateCredentials(this.finalCredentials);
if (this.finalCredentials.getApiKey() != null) {
LogUtil.printInfoLog(InfoLogs.REUSE_API_KEY.getLog());
LogUtil.printInfoLog(InfoLogs.USE_API_KEY.getLog());
token = this.finalCredentials.getApiKey();
} else if (Token.isExpired(token)) {
LogUtil.printInfoLog(InfoLogs.BEARER_TOKEN_EXPIRED.getLog());
Expand Down
140 changes: 0 additions & 140 deletions v2/src/main/java/com/skyflow/logs/ErrorLogs.java

This file was deleted.

Loading
Loading