Example usage for javax.servlet.http HttpServletRequest getRequestURL

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

Introduction

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

Prototype

public StringBuffer getRequestURL();

Source Link

Document

Reconstructs the URL the client used to make the request.

Usage

From source file:edu.usc.lunchnlearn.elasticsearch.interceptor.BreadCrumbInterceptor.java

private boolean isExclusion(HttpServletRequest request) {
    boolean exclusion = false;

    StringBuffer stringBuffer = request.getRequestURL();
    if (request.getQueryString() != null) {
        stringBuffer.append("?").append(request.getQueryString());
    }/*ww  w . j a v a  2s. c o m*/
    String url = stringBuffer.toString();

    for (String uri : this.uriExclusionList) {
        if (url.contains(uri)) {
            exclusion = true;
            break;
        }
    }
    return exclusion;
}

From source file:org.apache.cxf.fediz.service.idp.kerberos.KerberosEntryPoint.java

public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException ex)
        throws IOException, ServletException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Sending back Negotiate Header for request: " + request.getRequestURL());
    }/*from  w w w  .j a v a  2s .  com*/
    response.addHeader("WWW-Authenticate", "Negotiate");
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    response.flushBuffer();
}

From source file:com.kurento.kmf.jsonrpcconnector.internal.server.config.OAuthFiWareFilter.java

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

    String fullUrl = request.getRequestURL().append('?').append(request.getQueryString()).toString();

    log.info("Client trying to stablish new websocket session with {}", fullUrl);

    if (!Strings.isNullOrEmpty(props.getKeystoneHost())) {
        String accessToken = parseAccessToken(request);
        if (Strings.isNullOrEmpty(accessToken)) {
            log.warn("Request from {} without OAuth token", request.getRemoteAddr());
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access token not found in request");
        } else if (isTokenValid(accessToken)) {
            log.info("The request from {} was authorized", request.getRemoteAddr());
            filterChain.doFilter(request, response);
        } else {// w  ww.  jav a 2 s. co m
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unathorized request");
        }
    } else {
        log.info("Request from {} authorized: no keystone host configured", request.getRemoteAddr());
        filterChain.doFilter(request, response);
    }
}

From source file:com.eschava.forevernote.EvernoteLoginController.java

@RequestMapping(method = RequestMethod.GET)
public String get(ModelMap model, HttpServletRequest servletRequest) throws IOException {
    OAuthHmacSigner signer = new OAuthHmacSigner();
    signer.clientSharedSecret = Constants.EVERNOTE_CLIENT_SHARED_SECRET;

    String callbackUrl = new URL(new URL(servletRequest.getRequestURL().toString()), "evernote-login-confirm")
            .toString();// www  .j  av  a2 s  . com

    OAuthGetTemporaryToken temporaryToken = new OAuthGetTemporaryToken(EVERNOTE_LOGIN_HOST + "oauth");
    temporaryToken.callback = callbackUrl;
    temporaryToken.consumerKey = Constants.EVERNOTE_CONSUMER_KEY;
    temporaryToken.transport = transport;
    temporaryToken.signer = signer;

    OAuthCredentialsResponse response = temporaryToken.execute();
    String url = EVERNOTE_LOGIN_HOST + "OAuth.action?oauth_token=" + response.token;
    String tokenSecret = response.tokenSecret;

    model.addAttribute(OAUTH_TOKEN_SECRET_SESSION_ATTR, tokenSecret);
    return "redirect:" + url;
}

From source file:de.arago.rike.leaderboard.LeaderBoardImagesServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("image/png");

    try {//from  www .  j av  a 2s . com
        SVGDataServlet.addExpires(response);

        int pos = request.getRequestURL().lastIndexOf("/");
        String name = request.getRequestURL().substring(pos + 1);
        File tmp = new File(System.getProperty("java.io.tmpdir"), name);
        if (!tmp.exists()) {
            String uri = GlobalConfig.get(GlobalConfig.PATH_TO_PERSONAL_PICS);
            URL resource = (new URI(uri + name)).toURL();
            FileUtils.copyURLToFile(resource, tmp);
        }
        FileUtils.copyFile(tmp, response.getOutputStream());
    } catch (Exception ex) {
        IOUtils.copy(LeaderBoardImagesServlet.class.getResourceAsStream("/unknown.png"),
                response.getOutputStream());
    }
}

From source file:org.kurento.jsonrpc.internal.server.config.OAuthFiWareFilter.java

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

    String fullUrl = request.getRequestURL().append('?').append(request.getQueryString()).toString();

    log.trace("Client trying to stablish new websocket session with {}", fullUrl);

    if (!Strings.isNullOrEmpty(props.getKeystoneHost())) {
        String accessToken = parseAccessToken(request);
        if (Strings.isNullOrEmpty(accessToken)) {
            log.warn("Request from {} without OAuth token", request.getRemoteAddr());
            response.sendError(SC_UNAUTHORIZED, "Access token not found in request");
        } else if (isTokenValid(accessToken)) {
            log.trace("The request from {} was authorized", request.getRemoteAddr());
            filterChain.doFilter(request, response);
        } else {/*  w  w w .  j av a2  s .c o  m*/
            response.sendError(SC_UNAUTHORIZED, "Unathorized request");
        }
    } else {
        log.trace("Request from {} authorized: no keystone host configured", request.getRemoteAddr());
        filterChain.doFilter(request, response);
    }
}

From source file:com.palantir.stash.disapprove.servlet.DisapprovalServlet.java

private URI getUri(HttpServletRequest req) {
    StringBuffer builder = req.getRequestURL();
    if (req.getQueryString() != null) {
        builder.append("?");
        builder.append(req.getQueryString());
    }/*from   w  w  w . j a  v a  2 s  .c o m*/
    return URI.create(builder.toString());
}

From source file:com.epam.reportportal.extension.bugtracking.jira.JiraOAuthController.java

private void getRequestToken(String projectName, String consumerId, String baseUrl, HttpServletRequest request,
        HttpServletResponse response, String username) throws Exception {
    String resource = "/api/v1/oauth/callback";
    String callback = getBaseUri(request.getRequestURL().toString()).concat(resource);
    // args: consumerKey, certPrivateKey, baseJiraUrl, callbackUrl
    //      AtlassianOAuthClient client = new AtlassianOAuthClient(consumerId, pairProvider.extractPrivateKey(), baseUrl, callback);
    ////  w ww  .  j av a2  s . c o m
    //      JiraOAuthParams holder = client.getRequestToken();
    //      holder.setConsumerKey(consumerId);
    //      holder.setRpProject(projectName);
    //      holder.setBaseUrl(baseUrl);
    //      holder.setCallback(callback);
    //      holder.setUsername(username);
    //      // Referer for redirect back to report portal
    //      holder.setReferer(request.getHeader(oauthJiraService.getBackHeader()));
    //      oauthJiraService.storeOAuthDetails(username, holder);
    //      client.redirect(request, response, client.getAuthorizeUrlForToken(holder.getRequestToken()));
}

From source file:org.darwinathome.server.controller.WebstartController.java

@RequestMapping("/{user}/{pass}/tetragotchi.jnlp")
public ResponseEntity<String> jnlpFile(HttpServletRequest request, @PathVariable String user,
        @PathVariable String pass) throws IOException {
    String from = String.format("%s/%s/tetragotchi.jnlp", user, pass);
    String base = request.getRequestURL().toString().replace(from, "");
    String realFileName = servletContext.getRealPath("tetragotchi.jnlp");
    BufferedReader in = new BufferedReader(new FileReader(realFileName));
    StringBuilder out = new StringBuilder();
    String line;/*ww  w.j av a2  s .c om*/
    while ((line = in.readLine()) != null) {
        if (line.contains("@@")) {
            line = line.replace("@@BASE@@", base);
            line = line.replace("@@USER@@", user);
            line = line.replace("@@PASS@@", pass);
        }
        out.append(line).append('\n');
    }
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(new MediaType("application", "java-jnlp-file"));
    return new ResponseEntity<String>(out.toString(), headers, HttpStatus.OK);
}

From source file:com.ari.controller.catalog.CategoryController.java

private String getLinkUrl(String sort) {

    HttpServletRequest request = BroadleafRequestContext.getBroadleafRequestContext().getRequest();
    String baseUrl = request.getRequestURL().toString();
    Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());

    if (StringUtils.isNotBlank(sort)) {
        params.put(ProductSearchCriteria.SORT_STRING, new String[] { sort });
    } else {/*from  ww  w  .j a v  a2 s.  c  o m*/
        params.remove(ProductSearchCriteria.SORT_STRING);
    }

    params.remove(ProductSearchCriteria.PAGE_NUMBER);

    String url = ProcessorUtils.getUrl(baseUrl, params);

    return url;
}