use of java.net.SecureCacheResponse in project robovm by robovm.
the class HttpsURLConnectionImpl method getServerCertificates.
@Override
public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException {
SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
if (cacheResponse != null) {
List<Certificate> result = cacheResponse.getServerCertificateChain();
return result != null ? result.toArray(new Certificate[result.size()]) : null;
}
SSLSocket sslSocket = getSslSocket();
if (sslSocket != null) {
return sslSocket.getSession().getPeerCertificates();
}
return null;
}
use of java.net.SecureCacheResponse in project robovm by robovm.
the class HttpsURLConnectionImpl method getPeerPrincipal.
@Override
public Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
if (cacheResponse != null) {
return cacheResponse.getPeerPrincipal();
}
SSLSocket sslSocket = getSslSocket();
if (sslSocket != null) {
return sslSocket.getSession().getPeerPrincipal();
}
return null;
}
use of java.net.SecureCacheResponse in project robovm by robovm.
the class HttpsURLConnectionImpl method getCipherSuite.
@Override
public String getCipherSuite() {
SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
if (cacheResponse != null) {
return cacheResponse.getCipherSuite();
}
SSLSocket sslSocket = getSslSocket();
if (sslSocket != null) {
return sslSocket.getSession().getCipherSuite();
}
return null;
}
use of java.net.SecureCacheResponse in project phonegap-facebook-plugin by Wizcorp.
the class HttpsURLConnectionImpl method getPeerPrincipal.
@Override
public Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
SecureCacheResponse cacheResponse = delegate.getSecureCacheResponse();
if (cacheResponse != null) {
return cacheResponse.getPeerPrincipal();
}
SSLSocket sslSocket = getSslSocket();
if (sslSocket != null) {
return sslSocket.getSession().getPeerPrincipal();
}
return null;
}
use of java.net.SecureCacheResponse in project jdk8u_jdk by JetBrains.
the class EmptyInputStream method plainConnect0.
protected void plainConnect0() throws IOException {
// try to see if request can be served from local cache
if (cacheHandler != null && getUseCaches()) {
try {
URI uri = ParseUtil.toURI(url);
if (uri != null) {
cachedResponse = cacheHandler.get(uri, getRequestMethod(), getUserSetHeaders().getHeaders());
if ("https".equalsIgnoreCase(uri.getScheme()) && !(cachedResponse instanceof SecureCacheResponse)) {
cachedResponse = null;
}
if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
logger.finest("Cache Request for " + uri + " / " + getRequestMethod());
logger.finest("From cache: " + (cachedResponse != null ? cachedResponse.toString() : "null"));
}
if (cachedResponse != null) {
cachedHeaders = mapToMessageHeader(cachedResponse.getHeaders());
cachedInputStream = cachedResponse.getBody();
}
}
} catch (IOException ioex) {
// ignore and commence normal connection
}
if (cachedHeaders != null && cachedInputStream != null) {
connected = true;
return;
} else {
cachedResponse = null;
}
}
try {
if (instProxy == null) {
// no instance Proxy is set
/**
* Do we have to use a proxy?
*/
ProxySelector sel = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<ProxySelector>() {
public ProxySelector run() {
return ProxySelector.getDefault();
}
});
if (sel != null) {
URI uri = sun.net.www.ParseUtil.toURI(url);
if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
logger.finest("ProxySelector Request for " + uri);
}
Iterator<Proxy> it = sel.select(uri).iterator();
Proxy p;
while (it.hasNext()) {
p = it.next();
try {
if (!failedOnce) {
http = getNewHttpClient(url, p, connectTimeout);
http.setReadTimeout(readTimeout);
} else {
// make sure to construct new connection if first
// attempt failed
http = getNewHttpClient(url, p, connectTimeout, false);
http.setReadTimeout(readTimeout);
}
if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
if (p != null) {
logger.finest("Proxy used: " + p.toString());
}
}
break;
} catch (IOException ioex) {
if (p != Proxy.NO_PROXY) {
sel.connectFailed(uri, p.address(), ioex);
if (!it.hasNext()) {
// fallback to direct connection
http = getNewHttpClient(url, null, connectTimeout, false);
http.setReadTimeout(readTimeout);
break;
}
} else {
throw ioex;
}
continue;
}
}
} else {
// No proxy selector, create http client with no proxy
if (!failedOnce) {
http = getNewHttpClient(url, null, connectTimeout);
http.setReadTimeout(readTimeout);
} else {
// make sure to construct new connection if first
// attempt failed
http = getNewHttpClient(url, null, connectTimeout, false);
http.setReadTimeout(readTimeout);
}
}
} else {
if (!failedOnce) {
http = getNewHttpClient(url, instProxy, connectTimeout);
http.setReadTimeout(readTimeout);
} else {
// make sure to construct new connection if first
// attempt failed
http = getNewHttpClient(url, instProxy, connectTimeout, false);
http.setReadTimeout(readTimeout);
}
}
ps = (PrintStream) http.getOutputStream();
} catch (IOException e) {
throw e;
}
// constructor to HTTP client calls openserver
connected = true;
}
Aggregations