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.dub.skoolie.web.controller.system.school.rooms.SystemSchoolRoomController.java

@RequestMapping(value = "/system/schools/{id}/rooms", method = RequestMethod.POST)
public ModelAndView addSchoolRoom(@PathVariable("id") Long schoolid, @Valid SchoolRoomBean schoolRoomBean,
        BindingResult result, Model model, HttpServletRequest request) {
    String referrer = request.getHeader("Referer");
    if (result.hasErrors()) {
        if (!referrer.equals("/system/schools/" + schoolid + "/rooms")) {
            return new ModelAndView("redirect:" + referrer);
        }/*  ww w.  jav a 2  s  .  c  o m*/
        return new ModelAndView("system/school/schools");
    }
    uiSchoolRoomServiceImpl.addSchoolRoom(schoolRoomBean);
    return new ModelAndView("redirect:" + referrer);
}

From source file:org.italiangrid.storm.webdav.authz.util.HeaderRegexMatcher.java

@Override
public boolean matches(HttpServletRequest request) {

    String headerValue = request.getHeader(headerName);
    if (headerValue != null) {

        boolean matches = matcher.match(pattern, headerValue);

        if (logger.isDebugEnabled()) {

            logger.debug("Request header value {} {} match with pattern {}", headerValue,
                    (matches ? "does" : "does not"), pattern);
        }/*from  w  w w .jav  a  2 s  .  c o m*/
        return matches;
    }
    return false;
}

From source file:org.keycloak.adapters.springsecurity.authentication.HttpHeaderInspectingApiRequestMatcher.java

/**
 * Returns true if the given request is an API request or false if it's an interactive
 * login request.//from   w ww  . jav  a  2s  .  c o m
 *
 * @param request the <code>HttpServletRequest</code>
 * @return <code>true</code> if the given <code>request</code> is an API request;
 * <code>false</code> otherwise
 */
@Override
public boolean matches(HttpServletRequest request) {
    return X_REQUESTED_WITH_HEADER_AJAX_VALUE.equals(request.getHeader(X_REQUESTED_WITH_HEADER));
}

From source file:belajar.nfc.controller.OptionsController.java

@RequestMapping(value = "/{id}", method = RequestMethod.OPTIONS)
public void handleOptionsUserWithId(@PathVariable String id, HttpServletRequest request,
        HttpServletResponse response) {//from   ww w. j  av  a  2s .  c om
    String host = request.getHeader("Host");
    String origin = request.getHeader("Origin");
    LOGGER.info("Options Controller URI [{}] method [{}] headers [{}] ipserver [{}]",
            new Object[] { request.getRequestURI(), request.getMethod(), origin, host });
}

From source file:com.yoho.core.trace.instrument.web.HttpServletRequestExtractor.java

@Override
public Span joinTrace(HttpServletRequest carrier) {
    if (carrier.getHeader(Span.TRACE_ID_NAME) == null) {
        // can't build a Span without trace id
        return null;
    }/*w ww . j  a  va 2 s.  c o  m*/
    String uri = this.urlPathHelper.getPathWithinApplication(carrier);
    boolean skip = this.skipPattern.matcher(uri).matches()
            || Span.SPAN_NOT_SAMPLED.equals(carrier.getHeader(Span.SAMPLED_NAME));
    long traceId = Span.hexToId(carrier.getHeader(Span.TRACE_ID_NAME));
    long spanId = carrier.getHeader(Span.SPAN_ID_NAME) != null
            ? Span.hexToId(carrier.getHeader(Span.SPAN_ID_NAME))
            : this.random.nextLong();
    return buildParentSpan(carrier, uri, skip, traceId, spanId);
}

From source file:Hello.java

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    String acceptLanguage = req.getHeader("Accept-Language");
    String acceptCharset = req.getHeader("Accept-Charset");

    res.getOutputStream().println("acceptLanguage: " + acceptLanguage);
    res.getOutputStream().println("acceptCharset" + acceptCharset);
}

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

/**
 * function to obtain the messic token//from  w  w  w  . ja  v  a 2  s.co  m
 * 
 * @param request {@link HttpServletRequest}
 * @return {@link String} messic token obtained
 */
protected String obtainToken(HttpServletRequest request) {
    return request.getHeader("messic_token");
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginExternalAuthSetup.java

/** Remember where we came from - we'll need to go back there. */
private void storeTheReferringPage(HttpServletRequest req) {
    String referrer = req.getHeader(HEADING_REFERRER);
    if (referrer == null) {
        dumpRequestHeaders(req);/*ww  w . ja  v a  2  s. c o  m*/
        referrer = figureHomePageUrl(req);
    }
    log.debug("Referring page is '" + referrer + "'");
    req.getSession().setAttribute(ATTRIBUTE_REFERRER, referrer);
}

From source file:com.jevontech.wabl.controllers.AuthenticationController.java

@CrossOrigin
@RequestMapping(value = "/refresh", method = RequestMethod.GET)
public ResponseEntity<?> authenticationRequest(HttpServletRequest request) {
    String token = request.getHeader(this.tokenHeader);
    String username = this.tokenUtils.getUsernameFromToken(token);
    SecurityUser user = (SecurityUser) this.userDetailsService.loadUserByUsername(username);
    if (this.tokenUtils.canTokenBeRefreshed(token, user.getLastPasswordReset())) {
        String refreshedToken = this.tokenUtils.refreshToken(token);
        return ResponseEntity.ok(new AuthenticationResponse(refreshedToken));
    } else {//from w ww. j  a v  a 2  s .c  om
        return ResponseEntity.badRequest().body(null);
    }
}

From source file:eionet.web.filter.ContentNegotiationFilter.java

/**
 * Returns true, if request wants RDF content.
 *
 * @param httpRequest//  www  . j a va2  s  . c  om
 * @return
 */
private boolean isRdfXmlPreferred(HttpServletRequest httpRequest) {
    String acceptHeader = httpRequest.getHeader("Accept");
    return acceptHeader != null && acceptHeader.trim().toLowerCase().startsWith("application/rdf+xml");
}