Package io.jans.as.model.util
Class Util
- java.lang.Object
-
- io.jans.as.model.util.Util
-
public class Util extends Object
- Version:
- April 25, 2022
- Author:
- Yuriy Zabrovarnyy, Javier Rojas Blum
-
-
Field Summary
Fields Modifier and Type Field Description static String
PAR_ID_REFIX
static String
PAR_ID_SHORT_REFIX
static String
UTF8_STRING_ENCODING
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, io.jans.orm.annotation.AttributeEnum value)
static void
addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, io.jans.orm.model.base.LocalizedString localizedString)
static void
addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, Object value)
static void
addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, String[] value)
static void
addToJSONObjectIfNotNullOrEmpty(org.json.JSONObject jsonObject, String key, String[] value)
static void
addToListIfHas(List<String> list, org.json.JSONObject jsonObj, String key)
static boolean
allNotBlank(String... strings)
static <T extends io.jans.orm.annotation.AttributeEnum>
List<T>asEnumList(org.json.JSONArray array, Class<T> clazz)
static int
asInt(Integer integer, int fallback)
static String
asJson(Object object)
static String
asJsonSilently(Object object)
static List<String>
asList(org.json.JSONArray array)
static String
asPrettyJson(Object object)
static String
asString(List<? extends HasParamName> list)
static String
byteArrayToHexString(byte[] b)
static Date
createExpirationDate(Integer lifetimeInSeconds)
static com.fasterxml.jackson.databind.ObjectMapper
createJsonMapper()
static String
escapeLog(Object param)
static <T> T
firstItem(List<T> items)
static byte[]
getBytes(String str)
static boolean
isBuiltInPasswordAuthn(String acr)
static boolean
isNullOrEmpty(String string)
static boolean
isPar(String requestUri)
static List<String>
jsonArrayStringAsList(String jsonString)
static Map<String,String>
jsonObjectArrayStringAsMap(String jsonString)
static String
listAsString(List<String> list)
static org.json.JSONArray
listToJsonArray(Collection<String> list)
static String
mapAsString(Map<String,String> map)
static Integer
parseIntegerSilently(String intString)
static int
parseIntSilently(String intString)
static int
parseIntSilently(String intString, int defaultValue)
static void
putArray(org.json.JSONObject jsonObj, List<String> list, String key)
static void
putNotBlank(Map map, String key, Object value)
static List<String>
splittedStringAsList(String string, String delimiter)
static Map<String,Serializable>
toSerializableMap(Map<String,Object> map)
static Map<String,String>
toSerializableMapOfStrings(Map<String,Object> map)
static String
toSHA1HexString(String input)
-
-
-
Field Detail
-
UTF8_STRING_ENCODING
public static final String UTF8_STRING_ENCODING
- See Also:
- Constant Field Values
-
PAR_ID_REFIX
public static final String PAR_ID_REFIX
- See Also:
- Constant Field Values
-
PAR_ID_SHORT_REFIX
public static final String PAR_ID_SHORT_REFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
createJsonMapper
public static com.fasterxml.jackson.databind.ObjectMapper createJsonMapper()
-
asPrettyJson
public static String asPrettyJson(Object object) throws IOException
- Throws:
IOException
-
asJson
public static String asJson(Object object) throws IOException
- Throws:
IOException
-
getBytes
public static byte[] getBytes(String str)
-
asList
public static List<String> asList(org.json.JSONArray array) throws org.json.JSONException
- Throws:
org.json.JSONException
-
asEnumList
public static <T extends io.jans.orm.annotation.AttributeEnum> List<T> asEnumList(org.json.JSONArray array, Class<T> clazz) throws org.json.JSONException, NoSuchMethodException, InvocationTargetException, IllegalAccessException
- Throws:
org.json.JSONException
NoSuchMethodException
InvocationTargetException
IllegalAccessException
-
addToListIfHas
public static void addToListIfHas(List<String> list, org.json.JSONObject jsonObj, String key) throws org.json.JSONException
- Throws:
org.json.JSONException
-
addToJSONObjectIfNotNull
public static void addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, Object value) throws org.json.JSONException
- Throws:
org.json.JSONException
-
addToJSONObjectIfNotNull
public static void addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, io.jans.orm.annotation.AttributeEnum value) throws org.json.JSONException
- Throws:
org.json.JSONException
-
addToJSONObjectIfNotNull
public static void addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, String[] value) throws org.json.JSONException
- Throws:
org.json.JSONException
-
addToJSONObjectIfNotNullOrEmpty
public static void addToJSONObjectIfNotNullOrEmpty(org.json.JSONObject jsonObject, String key, String[] value) throws org.json.JSONException
- Throws:
org.json.JSONException
-
addToJSONObjectIfNotNull
public static void addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, io.jans.orm.model.base.LocalizedString localizedString) throws org.json.JSONException
- Throws:
org.json.JSONException
-
asString
public static String asString(List<? extends HasParamName> list)
-
mapAsString
public static String mapAsString(Map<String,String> map) throws org.json.JSONException
- Throws:
org.json.JSONException
-
allNotBlank
public static boolean allNotBlank(String... strings)
-
splittedStringAsList
public static List<String> splittedStringAsList(String string, String delimiter)
-
jsonArrayStringAsList
public static List<String> jsonArrayStringAsList(String jsonString) throws org.json.JSONException
- Throws:
org.json.JSONException
-
listToJsonArray
public static org.json.JSONArray listToJsonArray(Collection<String> list)
-
jsonObjectArrayStringAsMap
public static Map<String,String> jsonObjectArrayStringAsMap(String jsonString) throws org.json.JSONException
- Parameters:
jsonString
- [{"CustomHeader1":"custom_header_value_1"},.....,{"CustomHeaderN":"custom_header_value_N"}]- Returns:
- Throws:
org.json.JSONException
-
firstItem
public static <T> T firstItem(List<T> items)
-
isNullOrEmpty
public static boolean isNullOrEmpty(String string)
-
parseIntSilently
public static int parseIntSilently(String intString)
-
parseIntSilently
public static int parseIntSilently(String intString, int defaultValue)
-
isBuiltInPasswordAuthn
public static boolean isBuiltInPasswordAuthn(String acr)
-
asInt
public static int asInt(Integer integer, int fallback)
-
byteArrayToHexString
public static String byteArrayToHexString(byte[] b)
-
isPar
public static boolean isPar(String requestUri)
-
toSerializableMap
public static Map<String,Serializable> toSerializableMap(Map<String,Object> map)
-
toSerializableMapOfStrings
public static Map<String,String> toSerializableMapOfStrings(Map<String,Object> map)
-
-