Java Code Examples for javax.net.ssl.SSLSession#getLocalPrincipal()
The following examples show how to use
javax.net.ssl.SSLSession#getLocalPrincipal() .
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: ClientEndpoint.java From conga with Apache License 2.0 | 6 votes |
/** * Opens a WebSocket to the server * * @throws Exception complete exceptionally with one of the following errors: * <ul> * <li>{@link IOException} - if an I/O error occurs * <li>{@link WebSocketHandshakeException} - if the opening handshake fails * <li>{@link HttpTimeoutException} - if the opening handshake does not complete within * the timeout * <li>{@link InterruptedException} - if the operation is interrupted * <li>{@link SecurityException} - if a security manager has been installed and it denies * {@link java.net.URLPermission access} to {@code uri}. * <a href="HttpRequest.html#securitychecks">Security checks</a> contains more information * relating to the security context in which the the listener is invoked. * <li>{@link IllegalArgumentException} - if any of the arguments to the constructor are * invalid * </ul> * */ public void open() throws Exception { while (!connectedCriticalSection.compareAndSet(false, true)) { Thread.yield(); } try { if (webSocket == null) { final HttpClient httpClient = HttpClient.newHttpClient(); webSocket = httpClient.newWebSocketBuilder().subprotocols(subprotocol) .connectTimeout(Duration.ofSeconds(timeoutSeconds)).buildAsync(uri, listener).get(); final SSLSessionContext clientSessionContext = httpClient.sslContext().getClientSessionContext(); byte[] id = clientSessionContext.getIds().nextElement(); SSLSession sslSession = clientSessionContext.getSession(id); Principal principal = sslSession.getLocalPrincipal(); source = (null != principal) ? principal.getName() : new String(id); } } finally { connectedCriticalSection.compareAndSet(true, false); } }
Example 2
Source File: AsyncHTTPConduit.java From cxf with Apache License 2.0 | 5 votes |
public void setSSLSession(SSLSession sslsession) { session = sslsession; synchronized (sessionLock) { sslState = sslsession.getLocalPrincipal(); sslURL = url; sessionLock.notifyAll(); } }
Example 3
Source File: RecordedRequest.java From j2objc with Apache License 2.0 | 4 votes |
public RecordedRequest(String requestLine, List<String> headers, List<Integer> chunkSizes, int bodySize, byte[] body, int sequenceNumber, Socket socket) { this.requestLine = requestLine; this.headers = headers; this.chunkSizes = chunkSizes; this.bodySize = bodySize; this.body = body; this.sequenceNumber = sequenceNumber; if (socket instanceof SSLSocket) { SSLSocket sslSocket = (SSLSocket) socket; SSLSession session = sslSocket.getSession(); sslProtocol = session.getProtocol(); sslCipherSuite = session.getCipherSuite(); sslLocalPrincipal = session.getLocalPrincipal(); sslLocalCertificates = session.getLocalCertificates(); Principal peerPrincipal = null; Certificate[] peerCertificates = null; try { peerPrincipal = session.getPeerPrincipal(); peerCertificates = session.getPeerCertificates(); } catch (SSLPeerUnverifiedException e) { // No-op: use nulls instead } sslPeerPrincipal = peerPrincipal; sslPeerCertificates = peerCertificates; } else { sslProtocol = null; sslCipherSuite = null; sslLocalPrincipal = null; sslLocalCertificates = null; sslPeerPrincipal = null; sslPeerCertificates = null; } if (requestLine != null) { int methodEnd = requestLine.indexOf(' '); int pathEnd = requestLine.indexOf(' ', methodEnd + 1); this.method = requestLine.substring(0, methodEnd); this.path = requestLine.substring(methodEnd + 1, pathEnd); } else { this.method = null; this.path = null; } }