com.sun.net.httpserver.HttpsExchange Java Examples
The following examples show how to use
com.sun.net.httpserver.HttpsExchange.
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: AuthenticatedClientRequestHandler.java From protect with MIT License | 6 votes |
@Override public void handleWithExceptions(final HttpExchange exchange) throws IOException, UnauthorizedException, NotFoundException, ConflictException, BadRequestException, ResourceUnavailableException, InternalServerException { if (exchange instanceof HttpsExchange) { // Get SSL Session final HttpsExchange secureExchange = (HttpsExchange) exchange; final SSLSession sslSession = secureExchange.getSSLSession(); final String username = determineUsername(this.clientKeys, sslSession); // Invoke the sub-class's handler with the detected entity id this.authenticatedClientHandle(exchange, username); } else { throw new RuntimeException("HTTPS is required"); } }
Example #2
Source File: ServerConnectionImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
Example #3
Source File: ServerConnectionImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
Example #4
Source File: ServerConnectionImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
Example #5
Source File: ServerConnectionImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
Example #6
Source File: ServerConnectionImpl.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
Example #7
Source File: AuthenticatedServerRequestHandler.java From protect with MIT License | 6 votes |
@Override public void handleWithExceptions(final HttpExchange exchange) throws IOException, UnauthorizedException, NotFoundException, ConflictException, BadRequestException, ResourceUnavailableException { if (exchange instanceof HttpsExchange) { // Get SSL Session final HttpsExchange secureExchange = (HttpsExchange) exchange; final SSLSession sslSession = secureExchange.getSSLSession(); final Integer entityId = determineServerIdentity(this.serverKeys, sslSession); // Invoke the sub-class's handler with the detected entity id this.authenticatedServerHandle(exchange, entityId); } else { throw new RuntimeException("HTTPS is required"); } }
Example #8
Source File: ServerConnectionImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
Example #9
Source File: ServerConnectionImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
Example #10
Source File: ServerConnectionImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
Example #11
Source File: ServerConnectionImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public String getRequestScheme() { return (httpExchange instanceof HttpsExchange) ? "https" : "http"; }
Example #12
Source File: ServerConnectionImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public String getRequestScheme() { return (httpExchange instanceof HttpsExchange) ? "https" : "http"; }
Example #13
Source File: ServerConnectionImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSecure() { return (httpExchange instanceof HttpsExchange); }
Example #14
Source File: ServerConnectionImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSecure() { return (httpExchange instanceof HttpsExchange); }
Example #15
Source File: ServerConnectionImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public String getRequestScheme() { return (httpExchange instanceof HttpsExchange) ? "https" : "http"; }
Example #16
Source File: ServerConnectionImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSecure() { return (httpExchange instanceof HttpsExchange); }
Example #17
Source File: HttpHandlerContainer.java From metrics with Apache License 2.0 | 4 votes |
@Override public void handle(final HttpExchange exchange) throws IOException { /** * This is a URI that contains the path, query and fragment components. */ URI exchangeUri = exchange.getRequestURI(); /** * The base path specified by the HTTP context of the HTTP handler. It * is in decoded form. */ String decodedBasePath = exchange.getHttpContext().getPath(); // Ensure that the base path ends with a '/' if (!decodedBasePath.endsWith("/")) { if (decodedBasePath.equals(exchangeUri.getPath())) { /** * This is an edge case where the request path does not end in a * '/' and is equal to the context path of the HTTP handler. * Both the request path and base path need to end in a '/' * Currently the request path is modified. * * TODO support redirection in accordance with resource configuration feature. */ exchangeUri = UriBuilder.fromUri(exchangeUri) .path("/").build(); } decodedBasePath += "/"; } /* * The following is madness, there is no easy way to get the complete * URI of the HTTP request!! * * TODO this is missing the user information component, how can this be obtained? */ final boolean isSecure = exchange instanceof HttpsExchange; final String scheme = isSecure ? "https" : "http"; final URI baseUri = getBaseUri(exchange, decodedBasePath, scheme); final URI requestUri = getRequestUri(exchange, baseUri); final ResponseWriter responseWriter = new ResponseWriter(exchange); final ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri, exchange.getRequestMethod(), getSecurityContext(exchange.getPrincipal(), isSecure), new MapPropertiesDelegate()); requestContext.setEntityStream(exchange.getRequestBody()); requestContext.getHeaders().putAll(exchange.getRequestHeaders()); requestContext.setWriter(responseWriter); try { appHandler.handle(requestContext); } catch (Exception e) { LOGGER.log(Level.WARNING, "Error handling request: ", e); } finally { // if the response was not committed yet by the JerseyApplication // then commit it and log warning responseWriter.closeAndLogWarning(); } }
Example #18
Source File: ServerConnectionImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public String getRequestScheme() { return (httpExchange instanceof HttpsExchange) ? "https" : "http"; }
Example #19
Source File: ServerConnectionImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSecure() { return (httpExchange instanceof HttpsExchange); }
Example #20
Source File: ServerConnectionImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Override public String getRequestScheme() { return (httpExchange instanceof HttpsExchange) ? "https" : "http"; }
Example #21
Source File: ServerConnectionImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSecure() { return (httpExchange instanceof HttpsExchange); }
Example #22
Source File: ServerConnectionImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public String getRequestScheme() { return (httpExchange instanceof HttpsExchange) ? "https" : "http"; }
Example #23
Source File: ServerConnectionImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSecure() { return (httpExchange instanceof HttpsExchange); }
Example #24
Source File: ServerConnectionImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override public String getRequestScheme() { return (httpExchange instanceof HttpsExchange) ? "https" : "http"; }
Example #25
Source File: ServerConnectionImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSecure() { return (httpExchange instanceof HttpsExchange); }
Example #26
Source File: ServerConnectionImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public String getRequestScheme() { return (httpExchange instanceof HttpsExchange) ? "https" : "http"; }
Example #27
Source File: ServerConnectionImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public boolean isSecure() { return (httpExchange instanceof HttpsExchange); }