List of usage examples for javax.servlet.http HttpServletRequest getRequestURI
public String getRequestURI();
From source file:com.qcadoo.view.internal.resource.module.UniversalResourceModule.java
private String getContentTypeFromURI(final HttpServletRequest request) { String[] arr = request.getRequestURI().split("\\."); String ext = arr[arr.length - 1]; if ("js".equals(ext)) { return "text/javascript"; } else if ("css".equals(ext)) { return "text/css"; } else {/* w w w . j a va 2 s. c o m*/ return URLConnection.guessContentTypeFromName(request.getRequestURL().toString()); } }
From source file:org.uaa.security.core.LogoutHandler.java
public boolean isLogout(HttpServletRequest request) { String uri = request.getRequestURI(); int pathParamIndex = uri.indexOf(';'); if (pathParamIndex > 0) { // strip everything from the first semi-colon uri = uri.substring(0, pathParamIndex); }/* w w w . j a va 2 s . c o m*/ int queryParamIndex = uri.indexOf('?'); if (queryParamIndex > 0) { // strip everything from the first question mark uri = uri.substring(0, queryParamIndex); } if ("".equals(request.getContextPath())) { return uri.endsWith(logout_url); } return uri.endsWith(request.getContextPath() + logout_url); }
From source file:com.erudika.para.security.OpenIDAuthFilter.java
/** * Default constructor./*from www . ja va2 s. c o m*/ * @param defaultFilterProcessesUrl the url of the filter */ public OpenIDAuthFilter(final String defaultFilterProcessesUrl) { setRequiresAuthenticationRequestMatcher(new RequestMatcher() { public boolean matches(HttpServletRequest request) { String uri = request.getRequestURI(); boolean matches; if ("".equals(request.getContextPath())) { matches = uri.endsWith(defaultFilterProcessesUrl); } else { matches = uri.endsWith(request.getContextPath() + defaultFilterProcessesUrl); } return matches; } }); }
From source file:com.gae.LoginServlet.java
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { String thisURL = req.getRequestURI(); resp.setContentType("text/html"); UserService userService = UserServiceFactory.getUserService(); PrintWriter pw = resp.getWriter(); if (req.getUserPrincipal() == null) { pw.println("<a href=\"" + userService.createLoginURL(thisURL) + "\">Login</a>"); } else {/* ww w . j a v a2 s . c o m*/ User user = userService.getCurrentUser(); pw.println("<a href=\"" + userService.createLogoutURL(thisURL) + "\">Logout</a><br/>"); pw.println("name = " + req.getUserPrincipal().getName() + "<br/>"); pw.println("isAdmin = " + userService.isUserAdmin() + "<br/>"); pw.println("domain = " + user.getAuthDomain() + "<br/>"); pw.println("email = " + user.getEmail() + "<br/>"); pw.println("nickname = " + user.getNickname() + "<br/>"); } }
From source file:net.duckling.ddl.web.interceptor.access.PanFetchCodeInterceptor.java
private int getShareId(HttpServletRequest request) { String requestURI = request.getRequestURI(); int index = requestURI.lastIndexOf("/"); String ridS = requestURI.substring(index + 1); return ShareRidCodeUtil.decode(ridS); }
From source file:net.webpasswordsafe.server.controller.SsoController.java
private String getBaseUrl(HttpServletRequest request) { return request.getRequestURL().toString().replace(request.getRequestURI(), request.getContextPath()); }
From source file:com.thoughtworks.go.spark.SparkPreFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException { HttpServletRequest request = (HttpServletRequest) req; if (request.getRequestURI().startsWith("/go/spark/api/") && !request.getRequestURI().startsWith("/go/spark/api/plugin_images") && !request.getRequestURI().startsWith("/go/spark/api/support") && !request.getRequestURI().startsWith("/go/spark/api/v1/health") && noApiVersionInAcceptHeader((HttpServletRequest) req)) { render404((HttpServletResponse) resp); return;//from w w w .ja va2 s . c o m } String url = request.getRequestURI().replaceAll("^/go/spark/", "/go/"); servletHelper.getRequest(request).setRequestURI(url); super.doFilter(req, resp, chain); }
From source file:ar.com.zauber.commons.web.uri.UriJspFunctionsTest.java
/** Test de UriJsp sin cotexto*/ @Test/*w w w . jav a2 s . c om*/ @Ignore(value = "ahora que no se envia el request...") public final void buildUriDefault() throws Exception { setException(true); PageContext ctx = getPc(); HttpServletRequest req = getReq(); Mockito.when(req.getRequestURI()).thenReturn("/123/abc/asd/asd"); Mockito.when(req.getContextPath()).thenReturn(StringUtils.EMPTY); Assert.assertEquals("../../../abc", UriJspFunctions.buildVarArgs(ctx, "abc", ctx.getRequest())); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.BaseLoginServlet.java
/** * If we don't have a referrer, send them to the home page. *//*from w w w . j ava 2 s . com*/ protected String figureHomePageUrl(HttpServletRequest req) { StringBuffer url = req.getRequestURL(); String uri = req.getRequestURI(); int authLength = url.length() - uri.length(); String auth = url.substring(0, authLength); return auth + req.getContextPath(); }
From source file:io.lavagna.web.helper.CardCommentOwnershipChecker.java
@Override public boolean hasOwnership(HttpServletRequest request, UserWithPermission user) { Matcher matcher = pattern.matcher(request.getRequestURI()); try {/*w w w. j a v a2s. c o m*/ if (matcher.matches()) { int userId = UserSession.getUserId(request); int commentId = Integer.parseInt(matcher.group(1), 10); return eventRepository.findUsersIdFor(commentId, EventType.COMMENT_CREATE).contains(userId); } } catch (NumberFormatException nfe) { return false; } return false; }