Class HttpUtil
- java.lang.Object
-
- org.keycloak.client.admin.cli.util.HttpUtil
-
public class HttpUtil extends Object
- Author:
- Marko Strukelj
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPPLICATION_FORM_URL_ENCODEDstatic StringAPPLICATION_JSONstatic StringAPPLICATION_XMLstatic StringUTF_8
-
Constructor Summary
Constructors Constructor Description HttpUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringaddQueryParamsToUri(String uri, String... queryParams)static StringaddQueryParamsToUri(String uri, Map<String,String> queryParams)static voidcheckSuccess(String url, HeadersBodyStatus response)static StringcomposeResourceUrl(String adminRoot, String realm, String uri)static voiddoDelete(String url, String authorization)static HeadersBodyStatusdoDelete(String url, HeadersBody request)static voiddoDeleteJSON(String resourceUrl, String auth, Object content)static InputStreamdoGet(String url, String acceptType, String authorization)static HeadersBodyStatusdoGet(String url, HeadersBody request)static <T> TdoGetJSON(Class<T> type, String resourceUrl, String auth)static InputStreamdoPost(String url, String contentType, String acceptType, String content, String authorization)static HeadersBodyStatusdoPost(String url, HeadersBody request)static voiddoPostJSON(String resourceUrl, String auth, Object content)static InputStreamdoPut(String url, String contentType, String acceptType, String content, String authorization)static HeadersBodyStatusdoPut(String url, HeadersBody request)static HeadersBodyStatusdoRequest(String type, String url, HeadersBody request)static StringextractIdFromLocation(String location)static StringgetAttrForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String inputAttrName, String returnAttrName)static StringgetAttrForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String inputAttrName, String returnAttrName, Supplier<String[]> endpointParams)static org.apache.http.client.HttpClientgetHttpClient()static StringgetIdForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String inputAttrName)static StringgetIdForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String inputAttrName, Supplier<String[]> endpointParams)static Stringnormalize(String value)static voidsetSkipCertificateValidation()static voidsetTruststore(File file, String password)static Stringsingularize(String value)static Stringurlencode(String value)
-
-
-
Field Detail
-
APPLICATION_XML
public static final String APPLICATION_XML
- See Also:
- Constant Field Values
-
APPLICATION_JSON
public static final String APPLICATION_JSON
- See Also:
- Constant Field Values
-
APPLICATION_FORM_URL_ENCODED
public static final String APPLICATION_FORM_URL_ENCODED
- See Also:
- Constant Field Values
-
UTF_8
public static final String UTF_8
- See Also:
- Constant Field Values
-
-
Method Detail
-
doGet
public static InputStream doGet(String url, String acceptType, String authorization)
-
doPost
public static InputStream doPost(String url, String contentType, String acceptType, String content, String authorization)
-
doPut
public static InputStream doPut(String url, String contentType, String acceptType, String content, String authorization)
-
doGet
public static HeadersBodyStatus doGet(String url, HeadersBody request) throws IOException
- Throws:
IOException
-
doPost
public static HeadersBodyStatus doPost(String url, HeadersBody request) throws IOException
- Throws:
IOException
-
doPut
public static HeadersBodyStatus doPut(String url, HeadersBody request) throws IOException
- Throws:
IOException
-
doDelete
public static HeadersBodyStatus doDelete(String url, HeadersBody request) throws IOException
- Throws:
IOException
-
doRequest
public static HeadersBodyStatus doRequest(String type, String url, HeadersBody request) throws IOException
- Throws:
IOException
-
getHttpClient
public static org.apache.http.client.HttpClient getHttpClient()
-
setTruststore
public static void setTruststore(File file, String password) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, KeyManagementException
-
setSkipCertificateValidation
public static void setSkipCertificateValidation()
-
addQueryParamsToUri
public static String addQueryParamsToUri(String uri, Map<String,String> queryParams)
-
composeResourceUrl
public static String composeResourceUrl(String adminRoot, String realm, String uri)
-
checkSuccess
public static void checkSuccess(String url, HeadersBodyStatus response)
-
getIdForType
public static String getIdForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String inputAttrName)
-
getIdForType
public static String getIdForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String inputAttrName, Supplier<String[]> endpointParams)
-
getAttrForType
public static String getAttrForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String inputAttrName, String returnAttrName)
-
getAttrForType
public static String getAttrForType(String rootUrl, String realm, String auth, String resourceEndpoint, String attrName, String attrValue, String inputAttrName, String returnAttrName, Supplier<String[]> endpointParams)
-
-