Java Code Examples for javax.net.ssl.HttpsURLConnection#getCipherSuite()
The following examples show how to use
javax.net.ssl.HttpsURLConnection#getCipherSuite() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Connection.java From J2ME-Loader with Apache License 2.0 | 6 votes |
@Override public SecurityInfo getSecurityInfo() throws IOException { if (securityInfo == null) { if (cn == null) { throw new IOException(); } if (!connected) { cn.connect(); connected = true; } HttpsURLConnection https = (HttpsURLConnection) cn; Certificate[] certs = https.getServerCertificates(); if (certs.length == 0) { throw new IOException(); } securityInfo = new SecurityInfoImpl( https.getCipherSuite(), sslContext.getProtocol(), new CertificateImpl((X509Certificate) certs[0])); } return securityInfo; }
Example 2
Source File: HttpResponseCache.java From cordova-android-chromeview with Apache License 2.0 | 6 votes |
public Entry(URI uri, RawHeaders varyHeaders, HttpURLConnection httpConnection) throws IOException { this.uri = uri.toString(); this.varyHeaders = varyHeaders; this.requestMethod = httpConnection.getRequestMethod(); this.responseHeaders = RawHeaders.fromMultimap(httpConnection.getHeaderFields(), true); if (isHttps()) { HttpsURLConnection httpsConnection = (HttpsURLConnection) httpConnection; cipherSuite = httpsConnection.getCipherSuite(); Certificate[] peerCertificatesNonFinal = null; try { peerCertificatesNonFinal = httpsConnection.getServerCertificates(); } catch (SSLPeerUnverifiedException ignored) { } peerCertificates = peerCertificatesNonFinal; localCertificates = httpsConnection.getLocalCertificates(); } else { cipherSuite = null; peerCertificates = null; localCertificates = null; } }
Example 3
Source File: HttpResponseCache.java From cordova-android-chromeview with Apache License 2.0 | 6 votes |
public Entry(URI uri, RawHeaders varyHeaders, HttpURLConnection httpConnection) throws IOException { this.uri = uri.toString(); this.varyHeaders = varyHeaders; this.requestMethod = httpConnection.getRequestMethod(); this.responseHeaders = RawHeaders.fromMultimap(httpConnection.getHeaderFields(), true); if (isHttps()) { HttpsURLConnection httpsConnection = (HttpsURLConnection) httpConnection; cipherSuite = httpsConnection.getCipherSuite(); Certificate[] peerCertificatesNonFinal = null; try { peerCertificatesNonFinal = httpsConnection.getServerCertificates(); } catch (SSLPeerUnverifiedException ignored) { } peerCertificates = peerCertificatesNonFinal; localCertificates = httpsConnection.getLocalCertificates(); } else { cipherSuite = null; peerCertificates = null; localCertificates = null; } }
Example 4
Source File: HttpResponseCache.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 6 votes |
public Entry(URI uri, RawHeaders varyHeaders, HttpURLConnection httpConnection) throws IOException { this.uri = uri.toString(); this.varyHeaders = varyHeaders; this.requestMethod = httpConnection.getRequestMethod(); this.responseHeaders = RawHeaders.fromMultimap(httpConnection.getHeaderFields(), true); if (isHttps()) { HttpsURLConnection httpsConnection = (HttpsURLConnection) httpConnection; cipherSuite = httpsConnection.getCipherSuite(); Certificate[] peerCertificatesNonFinal = null; try { peerCertificatesNonFinal = httpsConnection.getServerCertificates(); } catch (SSLPeerUnverifiedException ignored) { } peerCertificates = peerCertificatesNonFinal; localCertificates = httpsConnection.getLocalCertificates(); } else { cipherSuite = null; peerCertificates = null; localCertificates = null; } }
Example 5
Source File: HttpResponseCache.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 6 votes |
public Entry(URI uri, RawHeaders varyHeaders, HttpURLConnection httpConnection) throws IOException { this.uri = uri.toString(); this.varyHeaders = varyHeaders; this.requestMethod = httpConnection.getRequestMethod(); this.responseHeaders = RawHeaders.fromMultimap(httpConnection.getHeaderFields(), true); if (isHttps()) { HttpsURLConnection httpsConnection = (HttpsURLConnection) httpConnection; cipherSuite = httpsConnection.getCipherSuite(); Certificate[] peerCertificatesNonFinal = null; try { peerCertificatesNonFinal = httpsConnection.getServerCertificates(); } catch (SSLPeerUnverifiedException ignored) { } peerCertificates = peerCertificatesNonFinal; localCertificates = httpsConnection.getLocalCertificates(); } else { cipherSuite = null; peerCertificates = null; localCertificates = null; } }
Example 6
Source File: ExternalSelfSignedResource.java From quarkus with Apache License 2.0 | 5 votes |
private String doGetCipher() throws IOException { // this URL provides an always on example of an HTTPS URL utilizing self-signed certificate URL url = new URL("https://self-signed.badssl.com/"); HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); con.setRequestMethod("GET"); con.getResponseCode(); return con.getCipherSuite(); }
Example 7
Source File: JCurl.java From JCurl with Apache License 2.0 | 5 votes |
private void processResponseCertificates(HttpURLConnection con, Response response) throws SSLPeerUnverifiedException { if (con instanceof HttpsURLConnection) { try { HttpsURLConnection secureConn = (HttpsURLConnection) con; response.cipherSuite = secureConn.getCipherSuite(); response.serverCertificates = secureConn.getServerCertificates(); response.clientCertificates = secureConn.getLocalCertificates(); } catch (IllegalStateException e) { // If the response is not a 200, getting response certificates will fail with the (misleading) message // "connection not yet open". Ignore this. } } }
Example 8
Source File: BaseLogger.java From gateway-android-sdk with Apache License 2.0 | 5 votes |
@Override public void logResponse(HttpsURLConnection c, String data) { String log = "RESPONSE: "; // log response headers Map<String, List<String>> headers = c.getHeaderFields(); Set<String> keys = headers.keySet(); int i = 0; for (String key : keys) { List<String> values = headers.get(key); for (String value : values) { if (i == 0 && key == null) { log += value; if (data != null && data.length() > 0) { log += "\n-- Data: " + data; } } else { log += "\n-- " + (key == null ? "" : key + ": ") + value; } i++; } } log += "\n-- Cipher Suite: " + c.getCipherSuite(); String[] parts = log.split("\n"); for (String part : parts) { logDebug(part); } }
Example 9
Source File: HttpsURLConnectionInfo.java From cxf with Apache License 2.0 | 5 votes |
/** * This constructor is used to create the info object * representing the this HttpsURLConnection. Connection parameter is * of supertype HttpURLConnection, which allows internal cast to * potentially divergent subtype (Https) implementations. */ public HttpsURLConnectionInfo(HttpURLConnection connection) throws IOException { super(connection.getURL(), connection.getRequestMethod()); if (connection instanceof HttpsURLConnection) { HttpsURLConnection conn = (HttpsURLConnection) connection; enabledCipherSuite = conn.getCipherSuite(); localCertificates = conn.getLocalCertificates(); localPrincipal = conn.getLocalPrincipal(); serverCertificates = conn.getServerCertificates(); peerPrincipal = conn.getPeerPrincipal(); } else { Exception ex = null; try { Method method = null; method = connection.getClass().getMethod("getCipherSuite", (Class[]) null); enabledCipherSuite = (String) method.invoke(connection, (Object[]) null); method = connection.getClass().getMethod("getLocalCertificates", (Class[]) null); localCertificates = (Certificate[]) method.invoke(connection, (Object[]) null); method = connection.getClass().getMethod("getServerCertificates", (Class[]) null); serverCertificates = (Certificate[]) method.invoke(connection, (Object[]) null); //TODO Obtain localPrincipal and peerPrincipal using the com.sun.net.ssl api } catch (Exception e) { ex = e; } finally { if (ex != null) { if (ex instanceof IOException) { throw (IOException) ex; } IOException ioe = new IOException("Error constructing HttpsURLConnectionInfo " + "for connection class " + connection.getClass().getName()); ioe.initCause(ex); throw ioe; } } } }