List of usage examples for javax.servlet.http HttpServletRequest getScheme
public String getScheme();
From source file:org.cloudfoundry.identity.uaa.oauth.AccessController.java
protected String extractScheme(HttpServletRequest request) { return useSsl != null && useSsl ? "https" : request.getScheme(); }
From source file:edu.indiana.d2i.sloan.ui.LoginSuccessAction.java
private String getServerContext() { HttpServletRequest request = getServletRequest(); final StringBuilder serverPath = new StringBuilder(); serverPath.append(request.getScheme() + "://"); serverPath.append(request.getServerName()); if (request.getServerPort() != 80) { serverPath.append(":" + request.getServerPort()); }// w w w .j a v a 2s .c o m serverPath.append(request.getContextPath()); return serverPath.toString(); }
From source file:org.openmrs.module.webservices.rest.web.controller.HelpController.java
@RequestMapping("/module/webservices/rest/help") public void showPage(ModelMap map, HttpServletRequest request) throws IllegalAccessException, InstantiationException, IOException, ConversionException { // TODO put content into map about controller annotations and resource // views/*from w w w .jav a 2 s . co m*/ StringBuilder baseUrl = new StringBuilder(); String scheme = request.getScheme(); int port = request.getServerPort(); baseUrl.append(scheme); // http, https baseUrl.append("://"); baseUrl.append(request.getServerName()); if ((scheme.equals("http") && port != 80) || (scheme.equals("https") && port != 443)) { baseUrl.append(':'); baseUrl.append(request.getServerPort()); } baseUrl.append(request.getContextPath()); String url = Context.getAdministrationService() .getGlobalProperty(RestConstants.URI_PREFIX_GLOBAL_PROPERTY_NAME, baseUrl.toString()); url += "/ws"; map.put("data", ResourceDocCreator.create(url)); }
From source file:com.springsource.hq.plugin.tcserver.serverconfig.web.support.HqAuthenticationEntryPoint.java
@Override protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) { String loginForm = determineUrlToUseForThisRequest(request, response, authException); int serverPort = getPortResolver().getServerPort(request); String scheme = request.getScheme(); RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder(); urlBuilder.setScheme(scheme);//from ww w. j a v a 2 s . c o m urlBuilder.setServerName(request.getServerName()); urlBuilder.setPort(serverPort); logger.debug("contextPath = " + request.getContextPath()); urlBuilder.setPathInfo(loginForm); if (isForceHttps() && "http".equals(scheme)) { Integer httpsPort = getPortMapper().lookupHttpsPort(Integer.valueOf(serverPort)); if (httpsPort != null) { // Overwrite scheme and port in the redirect URL urlBuilder.setScheme("https"); urlBuilder.setPort(httpsPort.intValue()); } else { logger.warn("Unable to redirect to HTTPS as no port mapping found for HTTP port " + serverPort); } } logger.debug("Redirecting to " + urlBuilder.getUrl()); return urlBuilder.getUrl(); }
From source file:com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule.java
/** * Begin request processing./* ww w.java 2s.com*/ * @param req The request to process * @param res The response to modify */ @Override public void onBeginRequest(ServletRequest req, ServletResponse res) { if (!isInitialized) { // Avoid logging to not spam the log. It is sufficient that the module initialization failure // has been logged. return; } try { RequestTelemetryContext context = ThreadContext.getRequestTelemetryContext(); RequestTelemetry telemetry = context.getHttpRequestTelemetry(); HttpServletRequest request = (HttpServletRequest) req; String method = request.getMethod(); String rURI = request.getRequestURI(); String scheme = request.getScheme(); String host = request.getHeader("Host"); String query = request.getQueryString(); String userAgent = request.getHeader("User-Agent"); telemetry.setHttpMethod(method); if (!Strings.isNullOrEmpty(query)) { telemetry.setUrl(String.format("%s://%s%s?%s", scheme, host, rURI, query)); } else { telemetry.setUrl(String.format("%s://%s%s", scheme, host, rURI)); } // TODO: this is a very naive implementation, which doesn't take into account various MVC f/ws implementation. // Next step is to implement the smart request name calculation which will support the leading MVC f/ws. String rUriWithoutSessionId = removeSessionIdFromUri(rURI); telemetry.setName(String.format("%s %s", method, rUriWithoutSessionId)); telemetry.getContext().getUser().setUserAgent(userAgent); telemetry.setTimestamp(new Date(context.getRequestStartTimeTicks())); } catch (Exception e) { String moduleClassName = this.getClass().getSimpleName(); InternalLogger.INSTANCE.error( "Telemetry module " + moduleClassName + " onBeginRequest failed with exception: %s", e.getMessage()); } }
From source file:org.easyrec.controller.aop.LoggedInCheckAspect.java
private void initPath(HttpServletRequest request) { localName = request.getLocalName();//from ww w. j av a 2s.co m localName = localName.equals("0.0.0.0") ? "localhost" : localName; this.webappPath = request.getContextPath(); this.extendedWebAppPath = request.getScheme() + "://" + localName + ":" + request.getLocalPort() + webappPath; PUBLIC_SITES = Sets.newHashSet(Collections2.transform(PUBLIC_SITES, new Function<String, String>() { public String apply(@Nullable String input) { StringBuilder result = new StringBuilder(webappPath); result.append('/'); result.append(input); return result.toString(); } })); }
From source file:es.itecban.deployment.executionmanager.web.controller.UnitInverseDependenciesController.java
private String getXMLDependencyGraphURL(DeploymentUnitType unit, HttpServletRequest request) throws Exception { String file = request.getRequestURI(); if (request.getQueryString() != null) { file += '?' + request.getQueryString() + "&justGraph=true"; }//from ww w . ja v a2 s . c o m URL reconstructedURL = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), file); return reconstructedURL.toString(); }
From source file:dk.dma.msinm.user.security.SecurityServletFilter.java
/** * Returns the JWT issuer based on the current server name * @param request the servlet request//from ww w. j a v a 2 s . c o m * @return the JWT issuer */ protected String getJwtIssuer(HttpServletRequest request) { return String.format("%s://%s", request.getScheme(), request.getServerName()); }
From source file:com.boyuanitsm.fort.web.rest.AccountResource.java
/** * POST /account/reset_password/init : Send an e-mail to reset the password of the user * * @param mail the mail of the user// www .ja va2s. co m * @param request the HTTP request * @return the ResponseEntity with status 200 (OK) if the e-mail was sent, or status 400 (Bad Request) if the e-mail address is not registred */ @RequestMapping(value = "/account/reset_password/init", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) @Timed public ResponseEntity<?> requestPasswordReset(@RequestBody String mail, HttpServletRequest request) { return userService.requestPasswordReset(mail).map(user -> { String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); mailService.sendPasswordResetMail(user, baseUrl); return new ResponseEntity<>("e-mail was sent", HttpStatus.OK); }).orElse(new ResponseEntity<>("e-mail address not registered", HttpStatus.BAD_REQUEST)); }
From source file:org.hoteia.qalingo.core.security.fo.component.LoginUrlAuthenticationEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { String redirectUrl = null;//from ww w . j a v a 2 s . c om if (useForward) { if (forceHttps && "http".equals(request.getScheme())) { // First redirect the current request to HTTPS. // When that request is received, the forward to the login page will be used. redirectUrl = buildHttpsRedirectUrlForRequest(request); } if (redirectUrl == null) { String loginForm = determineUrlToUseForThisRequest(request, response, authException); RequestDispatcher dispatcher = request.getRequestDispatcher(loginForm); dispatcher.forward(request, response); return; } } else { // redirect to login page. Use https if forceHttps true redirectUrl = buildRedirectUrlToLoginPage(request, response, authException); } redirectStrategy.sendRedirect(request, response, redirectUrl); }