----------Below code written in my service impl class ------------
restTemplate.setRequestFactory(new MyBasicAuthentication());
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, request, String.class,
urlVariables);
What is the use of below code..? When we shoul use this code Please explain step by step.
public class MyBasicAuthentication extends SimpleClientHttpRequestFactory {
private static class MyHostnameVerifier implements HostnameVerifier {
@Override
public boolean verify(String urlHostName, SSLSession session) {
return true;
}
}
@Override
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
if (connection instanceof HttpsURLConnection) {
((HttpsURLConnection) connection).setHostnameVerifier(new MyHostnameVerifier());
}
super.prepareConnection(connection, httpMethod);
}
Aucun commentaire:
Enregistrer un commentaire