Package io.jans.ca.plugin.adminui.utils
Class CommonUtils
- java.lang.Object
-
- io.jans.ca.plugin.adminui.utils.CommonUtils
-
public class CommonUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static DateTimeFormatterLS_DATE_FORMAT
-
Constructor Summary
Constructors Constructor Description CommonUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringconvertIsoToDateString(String isoDateTime)static StringconvertLocalDateToString(LocalDate date)static LocalDateconvertStringToLocalDate(String dateString)static GenericResponsecreateGenericResponse(boolean result, int responseCode, String responseMessage)static GenericResponsecreateGenericResponse(boolean result, int responseCode, String responseMessage, com.fasterxml.jackson.databind.JsonNode node)static Stringdecode(String toDecode)static Stringencode(String str)static StringgetFormattedDate()static booleanhasShortCode(String input)static booleanhasShortCode(Map<String,?> map)static booleanisValidJson(String json)static StringjoinAndUrlEncode(Collection<String> list)static Map<String,Object>jsonStringToMap(String jsonString)static RSAPrivateKeyloadPrivateKey(String privateKeyPEM)static StringmapToJsonString(Map<String,Object> mapObj)static StringreplacePlaceholders(String url, Map<String,Object> placeholderValues)static Map<String,Object>replacePlaceholders(Map<String,Object> map, Map<String,Object> placeholderValues)static com.fasterxml.jackson.databind.JsonNodetoJsonNode(Object object)Converts any Java object into a JsonNode representation.static booleantoPrimitiveOrDefaultFalse(Boolean booleanObject)Converts a Boolean object to a boolean primitive.
-
-
-
Field Detail
-
LS_DATE_FORMAT
public static final DateTimeFormatter LS_DATE_FORMAT
-
-
Method Detail
-
joinAndUrlEncode
public static String joinAndUrlEncode(Collection<String> list) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
encode
public static String encode(String str) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
getFormattedDate
public static String getFormattedDate()
-
loadPrivateKey
public static RSAPrivateKey loadPrivateKey(String privateKeyPEM) throws Exception
- Throws:
Exception
-
decode
public static String decode(String toDecode) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
createGenericResponse
public static GenericResponse createGenericResponse(boolean result, int responseCode, String responseMessage)
-
createGenericResponse
public static GenericResponse createGenericResponse(boolean result, int responseCode, String responseMessage, com.fasterxml.jackson.databind.JsonNode node)
-
hasShortCode
public static boolean hasShortCode(String input)
-
replacePlaceholders
public static Map<String,Object> replacePlaceholders(Map<String,Object> map, Map<String,Object> placeholderValues)
-
replacePlaceholders
public static String replacePlaceholders(String url, Map<String,Object> placeholderValues)
-
jsonStringToMap
public static Map<String,Object> jsonStringToMap(String jsonString) throws com.fasterxml.jackson.core.JsonProcessingException
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
mapToJsonString
public static String mapToJsonString(Map<String,Object> mapObj) throws com.fasterxml.jackson.core.JsonProcessingException
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
isValidJson
public static boolean isValidJson(String json)
-
toJsonNode
public static com.fasterxml.jackson.databind.JsonNode toJsonNode(Object object) throws com.fasterxml.jackson.core.JsonProcessingException
Converts any Java object into a JsonNode representation.- Parameters:
object- the Java object to convert- Returns:
- JSON representation of the object
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
toPrimitiveOrDefaultFalse
public static boolean toPrimitiveOrDefaultFalse(Boolean booleanObject)
Converts a Boolean object to a boolean primitive. Returns false if the input Boolean object is null.- Parameters:
booleanObject- The Boolean object to convert.- Returns:
- The boolean primitive value, or false if the input is null.
-
-