Package io.jans.as.server.service.net
Class HttpService2
- java.lang.Object
-
- io.jans.as.server.service.net.HttpService2
-
- All Implemented Interfaces:
Serializable
@ApplicationScoped public class HttpService2 extends Object implements Serializable
Provides operations with http/https requests- Author:
- Yuriy Movchan Date: 04/10/2023
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description HttpService2()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.http.conn.routing.HttpRoutePlanner
buildDefaultRoutePlanner(String proxy)
org.apache.http.conn.routing.HttpRoutePlanner
buildDefaultRoutePlanner(String hostname, int port, String scheme)
String
constructServerUrl(jakarta.servlet.http.HttpServletRequest request)
void
consume(org.apache.http.HttpResponse httpResponse)
String
convertEntityToString(byte[] responseBytes)
String
convertEntityToString(byte[] responseBytes, String charsetName)
String
convertEntityToString(byte[] responseBytes, Charset charset)
String
encodeBase64(String value)
String
encodeUrl(String value)
HttpServiceResponse
executeGet(org.apache.http.client.HttpClient httpClient, String requestUri)
HttpServiceResponse
executeGet(org.apache.http.client.HttpClient httpClient, String requestUri, Map<String,String> headers)
HttpServiceResponse
executePost(org.apache.http.client.HttpClient httpClient, String uri, String authData, String postData, org.apache.http.entity.ContentType contentType)
HttpServiceResponse
executePost(org.apache.http.client.HttpClient httpClient, String uri, String authData, Map<String,String> headers, String postData)
HttpServiceResponse
executePost(org.apache.http.client.HttpClient httpClient, String uri, String authData, Map<String,String> headers, String postData, org.apache.http.entity.ContentType contentType)
org.apache.http.impl.client.CloseableHttpClient
getHttpsClient()
org.apache.http.impl.client.CloseableHttpClient
getHttpsClient(String trustStoreType, String trustStorePath, String trustStorePassword)
org.apache.http.impl.client.CloseableHttpClient
getHttpsClient(String trustStoreType, String trustStorePath, String trustStorePassword, String keyStoreType, String keyStorePath, String keyStorePassword)
org.apache.http.impl.client.CloseableHttpClient
getHttpsClient(org.apache.http.client.config.RequestConfig requestConfig)
org.apache.http.impl.client.CloseableHttpClient
getHttpsClient(org.apache.http.client.config.RequestConfig requestConfig, org.apache.http.conn.routing.HttpRoutePlanner routerPlanner)
org.apache.http.impl.client.CloseableHttpClient
getHttpsClient(org.apache.http.conn.routing.HttpRoutePlanner routerPlanner)
org.apache.http.impl.client.CloseableHttpClient
getHttpsClientTrustAll()
byte[]
getResponseContent(org.apache.http.HttpResponse httpResponse)
void
init()
boolean
isContentTypeXml(org.apache.http.HttpResponse httpResponse)
boolean
isResponseStastusCodeOk(org.apache.http.HttpResponse httpResponse)
boolean
isResponseStatusCodeOk(org.apache.http.HttpResponse httpResponse)
-
-
-
Method Detail
-
init
@PostConstruct public void init()
-
getHttpsClientTrustAll
public org.apache.http.impl.client.CloseableHttpClient getHttpsClientTrustAll() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException
-
getHttpsClient
public org.apache.http.impl.client.CloseableHttpClient getHttpsClient()
-
getHttpsClient
public org.apache.http.impl.client.CloseableHttpClient getHttpsClient(org.apache.http.client.config.RequestConfig requestConfig)
-
getHttpsClient
public org.apache.http.impl.client.CloseableHttpClient getHttpsClient(org.apache.http.conn.routing.HttpRoutePlanner routerPlanner)
-
getHttpsClient
public org.apache.http.impl.client.CloseableHttpClient getHttpsClient(org.apache.http.client.config.RequestConfig requestConfig, org.apache.http.conn.routing.HttpRoutePlanner routerPlanner)
-
getHttpsClient
public org.apache.http.impl.client.CloseableHttpClient getHttpsClient(String trustStoreType, String trustStorePath, String trustStorePassword) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException
-
getHttpsClient
public org.apache.http.impl.client.CloseableHttpClient getHttpsClient(String trustStoreType, String trustStorePath, String trustStorePassword, String keyStoreType, String keyStorePath, String keyStorePassword) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException, UnrecoverableKeyException
-
executePost
public HttpServiceResponse executePost(org.apache.http.client.HttpClient httpClient, String uri, String authData, Map<String,String> headers, String postData, org.apache.http.entity.ContentType contentType)
-
executePost
public HttpServiceResponse executePost(org.apache.http.client.HttpClient httpClient, String uri, String authData, Map<String,String> headers, String postData)
-
executePost
public HttpServiceResponse executePost(org.apache.http.client.HttpClient httpClient, String uri, String authData, String postData, org.apache.http.entity.ContentType contentType)
-
executeGet
public HttpServiceResponse executeGet(org.apache.http.client.HttpClient httpClient, String requestUri, Map<String,String> headers)
-
executeGet
public HttpServiceResponse executeGet(org.apache.http.client.HttpClient httpClient, String requestUri) throws org.apache.http.client.ClientProtocolException, IOException
- Throws:
org.apache.http.client.ClientProtocolException
IOException
-
getResponseContent
public byte[] getResponseContent(org.apache.http.HttpResponse httpResponse) throws IOException
- Throws:
IOException
-
consume
public void consume(org.apache.http.HttpResponse httpResponse) throws IOException
- Throws:
IOException
-
convertEntityToString
public String convertEntityToString(byte[] responseBytes)
-
convertEntityToString
public String convertEntityToString(byte[] responseBytes, String charsetName) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
isResponseStastusCodeOk
public boolean isResponseStastusCodeOk(org.apache.http.HttpResponse httpResponse)
-
isResponseStatusCodeOk
public boolean isResponseStatusCodeOk(org.apache.http.HttpResponse httpResponse)
-
isContentTypeXml
public boolean isContentTypeXml(org.apache.http.HttpResponse httpResponse)
-
constructServerUrl
public String constructServerUrl(jakarta.servlet.http.HttpServletRequest request)
-
buildDefaultRoutePlanner
public org.apache.http.conn.routing.HttpRoutePlanner buildDefaultRoutePlanner(String hostname, int port, String scheme)
-
buildDefaultRoutePlanner
public org.apache.http.conn.routing.HttpRoutePlanner buildDefaultRoutePlanner(String proxy)
-
-