
com.starkinfra.utils.Check Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk Show documentation
Show all versions of sdk Show documentation
Welcome to the Stark Infra Java SDK! This tool is made for Java developers who want to easily integrate with our API. This SDK version is compatible with the Stark Infra API v2.
package com.starkinfra.utils;
import com.starkinfra.User;
import com.starkinfra.Settings;
import com.starkbank.ellipticcurve.PrivateKey;
import java.util.Arrays;
public final class Check {
public static String key(String key) throws Exception {
int a=1;
try {
PrivateKey privateKey = PrivateKey.fromPem(key);
if (!privateKey.curve.name.equals("secp256k1")) {
throw new Exception();
}
} catch (Exception e) {
throw new Exception("privateKey must be valid secp256k1 ECDSA string in pem format");
}
return key;
}
public static String environment(String environment) throws Exception {
String[] validEnvironments = {"sandbox", "production"};
if (Arrays.asList(validEnvironments).contains(environment)){
return environment;
}
throw new Exception(
String.format("Invalid environment, please choose one among %s", Arrays.toString(validEnvironments))
);
}
static User user(User user) throws Error {
if (user == null) {
user = Settings.user;
}
if (user == null) {
throw new Error("A user is required to access our API. Check our README: https://github.com/starkinfra/sdk-java/");
}
return user;
}
public static String language() throws Exception {
String[] validLanguages = {"en-US", "pt-BR"};
String language = Settings.language;
if (Arrays.asList(validLanguages).contains(language)){
return language;
}
throw new Exception(
String.format("Invalid language, please choose one among %s", Arrays.toString(validLanguages))
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy