List of usage examples for javax.servlet.http HttpServletRequest getHeader
public String getHeader(String name);
String
. From source file:edu.utah.further.i2b2.hook.further.web.ServletUtil.java
/** * @param request// w ww. j a v a 2 s .c om */ public static void printRequestHeaders(final HttpServletRequest request) { log.debug("Request headers:"); final Enumeration<?> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { final String name = (String) headerNames.nextElement(); log.debug(name + " = " + request.getHeader(name)); } }
From source file:org.artifactory.util.HttpUtils.java
/** * Return content length as long (required for uploaded files > 2GB). * The servlet api can only return this as int. * * @param request The request/* w w w. j a va2s. c o m*/ * @return The content length in bytes or -1 if not found */ public static long getContentLength(HttpServletRequest request) { return extractContentLengthFromHeader(request.getHeader(HttpHeaders.CONTENT_LENGTH)); }
From source file:org.artifactory.util.HttpUtils.java
public static String getServletContextUrl(HttpServletRequest httpRequest) { String origUrl = httpRequest.getHeader(ArtifactoryRequest.ARTIFACTORY_OVERRIDE_BASE_URL); if (StringUtils.isNotBlank(origUrl)) { // original artifactory request url overrides request and base url return origUrl; }/*from w w w . j a va 2s . c o m*/ CentralConfigService centralConfigService = ContextHelper.get().getCentralConfig(); String baseUrl = centralConfigService.getDescriptor().getUrlBase(); if (!StringUtils.isEmpty(baseUrl)) { String scheme = httpRequest.getScheme(); if (baseUrl.startsWith(scheme)) { return baseUrl; } else { int idx = baseUrl.indexOf("://"); if (idx > 0) { return scheme + "://" + baseUrl.substring(idx + 3); } else { return scheme + "://" + baseUrl; } } } return getServerUrl(httpRequest) + httpRequest.getContextPath(); }
From source file:fiftyone.mobile.detection.webapp.JavascriptProvider.java
/** * Returns a base 64 encoded version of the hash for the core JavaScript * being returned./*from w w w. j a v a 2s .c o m*/ * @param dataSet providing the JavaScript properties. * @param request * @return */ private static String eTagHash(Dataset dataSet, HttpServletRequest request) throws IOException, NoSuchAlgorithmException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); dos.writeLong(dataSet.published.getTime()); dos.writeChars(request.getHeader("User-Agent")); dos.writeChars(request.getQueryString()); return Base64.encodeBase64String(MessageDigest.getInstance("MD5").digest(bos.toByteArray())); }
From source file:net.siegmar.japtproxy.JaptProxyServlet.java
/** * Logs the header of the incoming request. * * @param req the HttpServletRequest object *///from w ww.j a v a 2 s.c om private static void logHeader(final HttpServletRequest req) { final Enumeration<String> headers = req.getHeaderNames(); final StringBuilder sb = new StringBuilder(); while (headers.hasMoreElements()) { final String headerName = headers.nextElement(); sb.append(headerName); sb.append('='); sb.append(req.getHeader(headerName)); if (headers.hasMoreElements()) { sb.append(','); } } LOG.debug("Request header: {}", sb); }
From source file:fr.paris.lutece.plugins.mydashboard.modules.nickname.web.MyDashboardNicknameApp.java
/** * Do change the nickname of the user// www . ja va 2 s . c o m * @param request The request * @return The next URL to redirect to */ public static String doChangeUserNickname(HttpServletRequest request) { LuteceUser user = SecurityService.isAuthenticationEnable() ? SecurityService.getInstance().getRegisteredUser(request) : null; if (user != null) { String strNickname = request.getParameter(PARAMETER_NICKNAME); UserPreferencesService.instance().setNickname(user.getName(), strNickname); } String strReferer = request.getHeader(HTML_PARAMETER_REFERER); if (StringUtils.isEmpty(strReferer)) { return MyDashboardApp.getUrlDefaultView(AppPathService.getBaseUrl(request)); } return strReferer; }
From source file:com.google.appengine.tools.mapreduce.MapReduceServletTest.java
private static HttpServletRequest createMockRequest(String handler, boolean taskQueueRequest, boolean ajaxRequest) { HttpServletRequest request = createMock(HttpServletRequest.class); if (taskQueueRequest) { expect(request.getHeader("X-AppEngine-QueueName")).andReturn("default").anyTimes(); } else {/*from ww w . ja v a 2s .c o m*/ expect(request.getHeader("X-AppEngine-QueueName")).andReturn(null).anyTimes(); } if (ajaxRequest) { expect(request.getHeader("X-Requested-With")).andReturn("XMLHttpRequest").anyTimes(); } else { expect(request.getHeader("X-Requested-With")).andReturn(null).anyTimes(); } expect(request.getRequestURI()).andReturn("/mapreduce/" + handler).anyTimes(); return request; }
From source file:info.magnolia.cms.security.Authenticator.java
/** * @param request current HttpServletRequest * @return String , current logged in user *//*ww w . j a v a2s .c o m*/ public static String getUserId(HttpServletRequest request) { String userId = null; HttpSession httpsession = request.getSession(false); if (httpsession != null) { userId = (String) httpsession.getAttribute(ATTRIBUTE_USER_ID); } if (userId == null) { String credentials = request.getHeader("Authorization"); if (credentials != null) { try { userId = getDecodedCredentials(credentials.substring(6).trim()); if (httpsession != null) { httpsession.setAttribute(ATTRIBUTE_USER_ID, userId); } } catch (Exception e) { log.debug(e.getMessage(), e); } } } return userId; }
From source file:com.concursive.connect.web.webdav.WebdavManager.java
public static boolean checkAuthentication(HttpServletRequest req) throws Exception { String argHeader = req.getHeader("Authorization"); if (argHeader == null || !argHeader.startsWith("Digest")) { LOG.debug("Missing Digest in header"); return false; }// w w w . jav a 2 s. c o m return true; }
From source file:edu.stanford.epad.epadws.security.EPADSessionOperations.java
private static String extractCredentialsFromAuthorizationHeader(HttpServletRequest request) { String authorizationHeader = request.getHeader("Authorization"); String credentials = ""; if (authorizationHeader != null && authorizationHeader.startsWith("Basic")) { String base64Credentials = authorizationHeader.substring("Basic".length()).trim(); credentials = new String(Base64.decodeBase64(base64Credentials), Charset.forName("UTF-8")); }//w w w .j av a 2s .c o m return credentials; }