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.orange.clara.tool.config.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.requestMatcher(new RequestMatcher() {
        @Override//from w  w  w  .  ja v  a2  s  .  c o m
        public boolean matches(HttpServletRequest httpServletRequest) {
            return httpServletRequest.getHeader("Authorization") == null;
        }
    }).authorizeRequests().antMatchers("/api/admin/**").hasRole(UserRole.ADMIN)
            .antMatchers("/info/**", "/ws/**").permitAll().anyRequest().authenticated().and().csrf()
            .csrfTokenRepository(csrfTokenRepository()).and()
            .addFilterAfter(csrfHeaderFilter(), CsrfFilter.class);
    if (useSsl) {
        http.requiresChannel().anyRequest().requiresSecure();
    }
}

From source file:guru.nidi.ramlproxy.core.CommandDecorators.java

public boolean isSet(HttpServletRequest request) {
    final String value;
    if (header) {
        value = request.getHeader(name);
    } else {//from   w ww  .j a  va2s  . c om
        value = request.getParameter(name);
    }
    return value != null && !value.equalsIgnoreCase("false");
}

From source file:com.sonicle.webtop.core.app.shiro.filter.JWTSignatureVerifier.java

protected String getAuthzHeader(ServletRequest request) {
    HttpServletRequest httpRequest = WebUtils.toHttp(request);
    return httpRequest.getHeader(AUTHORIZATION_HEADER);
}

From source file:fi.aluesarjat.prototype.ContextAccessServlet.java

private String getAcceptedType(HttpServletRequest request, Format defaultFormat) {
    String accept = request.getHeader("Accept");
    if (!StringUtils.isEmpty(accept)) {
        if (accept.contains(",")) {
            accept = accept.substring(0, accept.indexOf(','));
        }// ww w  .  jav  a 2 s  . co  m
        return Format.getFormat(accept, defaultFormat).getMimetype();
    } else {
        return defaultFormat.getMimetype();
    }
}

From source file:net.duckling.ddl.web.interceptor.access.VWBDenyListener.java

private boolean isAjaxRequest(HttpServletRequest request) {
    String ajaxFlag = request.getHeader("X-Requested-With");
    if ("XMLHttpRequest".equals(ajaxFlag)) {
        return true;
    }//from w  w w.  j  a  va2s .com
    return false;
}

From source file:com.wonders.bud.freshmommy.service.sysuser.service.impl.LoginSuccessHandler.java

/**
 * <p>/*  w  w w.j  a v  a2s  .  c o  m*/
 * Description:[?ip?]
 * </p>
 * 
 * @param request
 * @return
 */
public String getIpAddress(HttpServletRequest request) {
    String ip = request.getHeader("x-forwarded-for");
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("Proxy-Client-IP");
    }
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("WL-Proxy-Client-IP");
    }
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("HTTP_CLIENT_IP");
    }
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("HTTP_X_FORWARDED_FOR");
    }
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getRemoteAddr();
    }
    return ip;
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.BaseRestController.java

private boolean shouldAddWWWAuthHeader(HttpServletRequest request) {
    return request.getHeader(DISABLE_WWW_AUTH_HEADER_NAME) == null
            || !request.getHeader(DISABLE_WWW_AUTH_HEADER_NAME).equals("true");
}

From source file:com.bstek.dorado.view.resolver.FontAwesomeLocationTransformer.java

public String transform(String protocal, String location) {
    HttpServletRequest request = DoradoContext.getAttachedRequest();
    if (request != null) {
        String ua = request.getHeader("User-Agent");
        if (ua.indexOf(CHROME_FRAME) < 0) {
            boolean isMSIE = (ua != null && ua.indexOf(MSIE) != -1);
            if (isMSIE) {
                String version = MSIE_VERSION_PATTERN.matcher(ua).replaceAll("$1");
                if (StringUtils.isNotEmpty(version) && "8".compareTo(version) > 0) {
                    return PathUtils.concatPath(FAILSAFE_DIR, location.substring(protocal.length()));
                }/*from ww w  .  j a v a2s.  c om*/
            }
        }
    }
    return PathUtils.concatPath(NORMAL_DIR, location.substring(protocal.length()));
}

From source file:no.kantega.commons.taglib.util.GetHtmlTag.java

public int doStartTag() throws JspException {
    HttpGet get = new HttpGet(url);
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    get.setHeader("User-Agent", request.getHeader("User-Agent"));

    CloseableHttpClient httpclient = HttpClients.createDefault();
    try (CloseableHttpResponse response = httpclient.execute(get)) {
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            pageContext.getOut().write(IOUtils.toString(entity.getContent()));
        }/*  w  ww . j  a v  a 2s. c om*/
    } catch (IOException e) {
        log.error("Error getting html", e);
    }
    return SKIP_BODY;
}

From source file:cats.twitter.webapp.controller.mvc.CORSFilter.java

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    if (request.getHeader("Access-Control-Request-Method") != null && "OPTIONS".equals(request.getMethod())) {
        // CORS "pre-flight" request
        response.addHeader("Access-Control-Allow-Origin", "*");
        response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
        response.addHeader("Access-Control-Allow-Headers", "Content-Type");
        response.addHeader("Access-Control-Max-Age", "1800");//30 min
    }//from  ww w . ja  v  a 2 s  .  c  om
    filterChain.doFilter(request, response);
}