Example usage for javax.servlet.http HttpServletRequest getHeader

List of usage examples for javax.servlet.http HttpServletRequest getHeader

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getHeader.

Prototype

public String getHeader(String name);

Source Link

Document

Returns the value of the specified request header as a String.

Usage

From source file:com.monarchapis.driver.authentication.JwtClaimsProcessor.java

@Override
public ObjectNode getClaims(HttpServletRequest request) {
    if (StringUtils.isBlank(jwtKey)) {
        return null;
    }//  ww  w  . j a  va  2  s  .c  om

    String authorization = request.getHeader("Authorization");

    if (authorization != null && StringUtils.startsWithIgnoreCase(authorization, "Bearer ")) {
        String jwt = authorization.substring(7).trim();

        if (StringUtils.countMatches(jwt, ".") == 2) {
            try {
                return getClaims(jwt);
            } catch (Exception e) {
                logger.warn("Could not parse JWT token", e);
            }
        }
    }

    return null;
}

From source file:com.nebhale.cyclinglibrary.web.GzipFilter.java

private boolean sendsGzipEncoding(HttpServletRequest request) {
    return isGzipEncoding(request.getHeader("Content-Encoding"));
}

From source file:com.nebhale.cyclinglibrary.web.GzipFilter.java

private boolean acceptsGzipEncoding(HttpServletRequest request) {
    return isGzipEncoding(request.getHeader("Accept-Encoding"));
}

From source file:com.appdynamics.cloudfoundry.appdservicebroker.BrokerApiVersionFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws IOException, ServletException {

    String header = request.getHeader(HEADER);
    if (header == null) {
        response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
        return;//w ww . j a  v  a2s . c  om
    }

    Integer[] parsed = parse(header);
    Version version = Version.forIntegers(parsed[0], parsed[1]);
    if (!version.satisfies(VALID_VERSIONS)) {
        response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
        return;
    }

    filterChain.doFilter(request, response);
}

From source file:com.seguriboxltv.backing.BeanBase.java

public String GetIp() {

    HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
            .getRequest();/*from ww w .jav a2  s .c  o  m*/
    String ipAddress = request.getHeader("X-FORWARDED-FOR");
    if (ipAddress == null) {
        ipAddress = request.getRemoteAddr();
    }

    return ipAddress;
}

From source file:org.messic.server.facade.security.SecurityLoginFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))) {
        Login login = Login.failedLogin("Username/Password are invalid");
        response.getWriter().print(login.getJSON());
        response.getWriter().flush();//from  www  . ja va2  s  . c  om
    } else {
        super.onAuthenticationFailure(request, response, exception);
    }
}

From source file:com.thinkberg.webdav.WebdavHandler.java

/**
 * Get the overwrite header value, whether to overwrite destination
 * objects or collections or not./*from   w  w  w  .j  a  v a  2s .c  o m*/
 *
 * @param request the servlet request
 * @return true or false
 */
boolean getOverwrite(HttpServletRequest request) {
    String overwrite = request.getHeader("Overwrite");
    boolean overwriteValue = overwrite == null || "T".equals(overwrite);

    LOG.debug(String.format("request header: Overwrite: %s", overwriteValue));
    return overwriteValue;
}

From source file:com.thoughtworks.go.server.newsecurity.filters.X509AuthenticationFilter.java

private boolean headersMatchForAgent(HttpServletRequest request) {
    return isNotBlank(request.getHeader("X-Agent-GUID")) && isNotBlank(request.getHeader("Authorization"));
}

From source file:com.iflytek.edu.cloud.frame.web.filter.CORSFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    String origin = request.getHeader("Origin");
    if (allowedOrigins.contains(origin)) {
        response.addHeader("Access-Control-Allow-Origin", origin);
        response.addHeader("Access-Control-Allow-Methods", "GET, POST");
        response.addHeader("Access-Control-Allow-Headers", "Content-Type");
    }/*w w w .j ava 2  s .  c om*/

    filterChain.doFilter(request, response);
}

From source file:org.chimi.s4s.controller.FileDownloadController.java

private boolean checkModifiedRequest(HttpServletRequest request) {
    String modifedSinceHeader = request.getHeader("If-Modified-Since");
    if (modifedSinceHeader != null) {
        return true;
    }/*from w w w .  j  a va 2 s.co  m*/
    return false;
}