Example usage for javax.servlet.http HttpServletRequest getMethod

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

Introduction

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

Prototype

public String getMethod();

Source Link

Document

Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

Usage

From source file:org.surfnet.oaaas.consent.FormUserConsentHandler.java

private boolean isUserConsentPost(HttpServletRequest request) {
    String oauthApproval = request.getParameter(USER_OAUTH_APPROVAL);
    return request.getMethod().equals(HttpMethod.POST.toString()) && StringUtils.isNotBlank(oauthApproval);
}

From source file:com.enonic.cms.core.portal.datasource.handler.context.GetHttpContextHandler.java

private Element createHttpElement(final HttpServletRequest request) {
    final Element httpEl = new Element("http");

    if (request != null) {
        httpEl.setAttribute("action", request.getMethod());
        httpEl.addContent(new Element("user-agent").setText(request.getHeader("user-agent")));
        httpEl.addContent(new Element("client-ip").setText(request.getRemoteAddr()));
        httpEl.addContent(new Element("referer").setText(request.getHeader("referer")));

        // accept
        final Element acceptElem = new Element("accept");
        httpEl.addContent(acceptElem);//from  ww  w . j  a v a2 s .co m

        // language
        final String acceptLanguage = request.getHeader("accept-language");
        if (acceptLanguage != null) {
            final String[] languages = StringUtils.split(acceptLanguage, ",");
            for (String languageStr : languages) {
                if (languageStr.indexOf(";") > 0) {
                    final Element langElem = new Element("language");
                    langElem.setText(languageStr.substring(0, languageStr.indexOf(";")));
                    langElem.setAttribute("q", languageStr.substring(languageStr.indexOf(";") + 3));
                    acceptElem.addContent(langElem);
                } else {
                    acceptElem.addContent(new Element("language").setText(languageStr));
                }
            }
        }
    }
    return httpEl;
}

From source file:com.ibm.util.merge.web.rest.servlet.RequestData.java

public RequestData(HttpServletRequest request) {
    method = request.getMethod();
    byte[] bytes = readRequestBody(request);
    requestBody = bytes;/*from w  w w  . j  a  v a  2 s .  co  m*/
    contentType = request.getContentType();
    preferredLocale = request.getLocale();
    List<Locale> tlocales = getAllRequestLocales(request);
    locales = new ArrayList<>(tlocales);
    params = request.getParameterMap();
    pathInfo = request.getPathInfo();
    queryString = request.getQueryString();
    Map<String, List<String>> headerValues = readHeaderValues(request);
    headers = headerValues;
    requestUrl = request.getRequestURL().toString();
}

From source file:net.acesinc.convergentui.BaseFilter.java

protected String getVerb(HttpServletRequest request) {
    String method = request.getMethod();
    if (method == null) {
        return "GET";
    }//from w  ww . j  a va 2s .com
    return method;
}

From source file:org.uaa.security.core.LoggerManager.java

public void logBefore(HttpServletRequest request) {
    res_uri = request.getPathInfo();//from  w w w  .  j  a v  a  2  s.  c  o m
    if (res_uri.startsWith("/logs"))
        return;

    String res_action = request.getMethod();
    request_time = new Timestamp(System.currentTimeMillis());
    String addr = request.getRemoteAddr();
    String client = request.getHeader("User-Agent");

    log = new Apilog();
    log.setAddr(addr);
    log.setClient(client);
    log.setRequest_time(request_time.getTime());
    log.setRes_action(res_action);
    log.setRes_uri(res_uri);

    securityService.insertLog(log);
}

From source file:io.lavagna.web.security.CSFRFilter.java

/**
 * Return true if the filter must check the request
 *
 * @param request//from  w ww.j  a  va2  s.c om
 * @return
 */
private boolean mustCheckCSRF(HttpServletRequest request) {

    // ignore the websocket fallback...
    if ("POST".equals(request.getMethod()) && WEBSOCKET_FALLBACK
            .matcher(StringUtils.removeStart(request.getRequestURI(), request.getContextPath())).matches()) {
        return false;
    }

    return !CSRF_METHOD_DONT_CHECK.matcher(request.getMethod()).matches();
}

From source file:ru.mystamps.web.service.SiteServiceImpl.java

/**
 * @author Sergey Chechenev//  w  w  w. ja  v a 2 s  .  co m
 */
@Override
@Transactional
public void logAboutMissingCsrfToken(HttpServletRequest request) {

    logEvent(MISSING_CSRF_TOKEN, request.getRequestURI(), request.getMethod(), SecurityContextUtils.getUserId(),
            request.getRemoteAddr(), request.getHeader("referer"), request.getHeader("user-agent"), new Date());

}

From source file:ru.mystamps.web.service.SiteServiceImpl.java

/**
 * @author Sergey Chechenev/*from   www  .ja  v  a  2 s .co  m*/
 */
@Override
@Transactional
public void logAboutInvalidCsrfToken(HttpServletRequest request) {

    logEvent(INVALID_CSRF_TOKEN, request.getRequestURI(), request.getMethod(), SecurityContextUtils.getUserId(),
            request.getRemoteAddr(), request.getHeader("referer"), request.getHeader("user-agent"), new Date());

}

From source file:ar.com.zauber.commons.social.twitter.security.TwitterAuthenticationProcessingFilter.java

/**
 * @see AbstractAuthenticationProcessingFilter
 *      #attemptAuthentication(HttpServletRequest,
 *      HttpServletResponse)//from  w ww.  j a v a 2s. c o m
 */
@Override
public final Authentication attemptAuthentication(final HttpServletRequest request,
        final HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
    if (!request.getMethod().equals("GET")) {
        throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());
    }

    final String oauthToken = request.getParameter("oauth_token");
    final String oauthVerifier = request.getParameter("oauth_verifier");
    // verifier may be null
    final String denyToken = request.getParameter("denied");

    if (denyToken != null) {
        throw new BadCredentialsException("twitter access denied");
    }

    if (oauthToken == null) {
        throw new AuthenticationServiceException("missing oauth_token parameter");
    }

    return this.getAuthenticationManager()
            .authenticate(new TwitterAuthenticationToken(oauthToken, oauthVerifier));
}

From source file:fr.putnami.pwt.plugin.ajaxbot.filter.AjaxPageFilter.java

@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) req;

    if (HttpMethod.GET.toString().equals(request.getMethod())
            && req.getParameter(QUERY_PARAM_ESCAPED_FRAGMENT) != null) {
        ByteStreams.copy(this.getHtmlStream(request), resp.getOutputStream());
    } else {//from   ww  w.  j  a v  a2s  .c  om
        chain.doFilter(req, resp);
    }
}