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 StringPAR_ID_REFIXstatic StringPAR_ID_SHORT_REFIXstatic StringUTF8_STRING_ENCODING
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, io.jans.orm.annotation.AttributeEnum value)static voidaddToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, io.jans.orm.model.base.LocalizedString localizedString)static voidaddToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, Object value)static voidaddToJSONObjectIfNotNull(org.json.JSONObject jsonObject, String key, String[] value)static voidaddToJSONObjectIfNotNullOrEmpty(org.json.JSONObject jsonObject, String key, String[] value)static voidaddToListIfHas(List<String> list, org.json.JSONObject jsonObj, String key)static booleanallNotBlank(String... strings)static <T extends io.jans.orm.annotation.AttributeEnum>
List<T>asEnumList(org.json.JSONArray array, Class<T> clazz)static intasInt(Integer integer, int fallback)static StringasJson(Object object)static StringasJsonSilently(Object object)static List<String>asList(org.json.JSONArray array)static StringasPrettyJson(Object object)static StringasString(List<? extends HasParamName> list)static StringbyteArrayToHexString(byte[] b)static DatecreateExpirationDate(Integer lifetimeInSeconds)static com.fasterxml.jackson.databind.ObjectMappercreateJsonMapper()static StringescapeLog(Object param)static <T> TfirstItem(List<T> items)static byte[]getBytes(String str)static booleanisBuiltInPasswordAuthn(String acr)static booleanisNullOrEmpty(String string)static booleanisPar(String requestUri)static List<String>jsonArrayStringAsList(String jsonString)static Map<String,String>jsonObjectArrayStringAsMap(String jsonString)static StringlistAsString(List<String> list)static org.json.JSONArraylistToJsonArray(Collection<String> list)static StringmapAsString(Map<String,String> map)static IntegerparseIntegerSilently(String intString)static intparseIntSilently(String intString)static intparseIntSilently(String intString, int defaultValue)static voidputArray(org.json.JSONObject jsonObj, List<String> list, String key)static voidputNotBlank(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 StringtoSHA1HexString(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.JSONExceptionNoSuchMethodExceptionInvocationTargetExceptionIllegalAccessException
-
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)
-
-