List of usage examples for javax.servlet.http HttpServletRequest getHeader
public String getHeader(String name);
String
. From source file:org.georchestra.security.ImpersonateUserRequestHeaderProvider.java
@Override protected Collection<Header> getCustomRequestHeaders(HttpSession session, HttpServletRequest originalRequest) { if (originalRequest.getHeader(HeaderNames.IMP_USERNAME) != null) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication != null && trustedUsers != null && trustedUsers.contains(authentication.getName())) { List<Header> headers = new ArrayList<Header>(2); headers.add(new BasicHeader(HeaderNames.SEC_USERNAME, originalRequest.getHeader(HeaderNames.IMP_USERNAME))); headers.add(//from w w w .j a va2 s.c om new BasicHeader(HeaderNames.SEC_ROLES, originalRequest.getHeader(HeaderNames.IMP_ROLES))); return headers; } } return Collections.emptyList(); }
From source file:com.twinsoft.convertigo.engine.enums.HeaderName.java
public String getHeader(HttpServletRequest request) { return request.getHeader(value); }
From source file:com.appzone.sim.services.BasicAuthAuthenticationService.java
@Override public boolean authenticate(HttpServletRequest request) { // Autherization header String auth = request.getHeader("Authorization"); logger.debug("Basic Auth header: {}", auth); if (auth == null || auth.trim().length() < 6) return false; auth = auth.substring(6); // remove "BASIC " String decoded = new String(Base64.decodeBase64(auth)); logger.debug("Decoded Basic Auth: {}", decoded); String parts[] = decoded.split(":"); return checkAuthentication(parts[0], parts[1]); }
From source file:pl.hycom.jira.plugins.gitlab.integration.controller.GitJiraController.java
@Path("/listener") //zloz to z poprzednim pathem @POSTo/*from w w w .j a va 2s . c o m*/ @Produces({ MediaType.TEXT_HTML }) @Consumes("application/json") public void getRequest(HttpServletRequest request, Push event) { String header = request.getHeader("X-Gitlab-Event"); if (header == null || !header.contains("Hook")) { log.debug("Received request is not Gitlab request. Skipping processing"); return; } try { event.getProject().getName(); //FIXME: get JIRA project Id and call: updateCommitsForProject(id); manager.updateCommitsForAll(); } catch (SQLException | ParseException | IOException e) { log.error("Error refreshing commits from Gitlab, with exception: ", e); } }
From source file:com.enonic.cms.server.service.portal.security.BasicAuthInterceptor.java
private String[] getAuthCredentials(HttpServletRequest req) { String auth = req.getHeader("Authorization"); if (auth == null) { return null; }/*from w ww . j av a2s . c om*/ String[] tmp = auth.split(" "); if (tmp.length < 2) { return null; } if (!"basic".equalsIgnoreCase(tmp[0])) { return null; } String authStr = new String(Base64.decodeBase64(tmp[1].getBytes())); String[] credentials = authStr.split(":"); if (credentials == null) { return null; } // Set blank password if none provided if (credentials.length == 1) { return new String[] { credentials[0], "" }; } else if (credentials.length == 2) { return credentials; } else { return null; } }
From source file:com.granule.CompressorHandler.java
private boolean gzipSupported(HttpServletRequest request) { String acceptEncoding = request.getHeader("Accept-Encoding"); if (acceptEncoding == null || acceptEncoding.indexOf("gzip") == -1) { return false; }/*from w w w.ja v a 2 s .c o m*/ String userAgent = request.getHeader("user-agent"); if (userAgent == null) { return false; } if (userAgent.indexOf("MSIE 6") != -1 && userAgent.indexOf("SV1") == -1) { return false; } return true; }
From source file:com.rockagen.gnext.service.spring.security.extension.TokenAuthenticationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; String token = req.getHeader(tokenName); if (CommUtil.isNotBlank(token)) { //Validate token UserDetails user = exTokenAuthentication.getUserDetailsFromToken(token); if (user != null) { // authenticated UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken( user.getUsername(), user.getPassword(), user.getAuthorities()); authentication.setDetails(new ExWebAuthenticationDetails(req)); SecurityContextHolder.getContext().setAuthentication(authentication); }/* ww w . j a va 2 s .c o m*/ } chain.doFilter(request, response); }
From source file:org.shredzone.cilla.web.tag.IfBrowserTag.java
@Override public int doStartTag() throws JspException { HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); String ua = req.getHeader("User-Agent"); if (ua != null && Pattern.matches(agent, ua)) { return EVAL_BODY_INCLUDE; }/* w w w. j av a 2 s. c o m*/ return SKIP_BODY; }
From source file:ru.codemine.ccms.router.api.ApiSecurityRouter.java
@RequestMapping(value = "/api/login", method = RequestMethod.POST) public ResponseEntity<?> authRequest(HttpServletRequest req) { String reqUsername = req.getHeader("username"); String reqPass = req.getHeader("password"); String token = null;//from www . j ava 2 s . com Map<String, String> headers = new HashMap(); try { Authentication authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(reqUsername, reqPass)); SecurityContextHolder.getContext().setAuthentication(authentication); Employee employee = employeeService.getByUsername(reqUsername); token = apiTokenUtils.generateToken(employee); headers.put("X-Auth-Token", token); } catch (BadCredentialsException e) { log.warn(" , ?: " + reqUsername); } return token == null ? new ResponseEntity<>(HttpStatus.FORBIDDEN) : new ResponseEntity<>(headers, HttpStatus.OK); }
From source file:feedme.controller.AddOrDeleteCategoryServlet.java
private boolean isAjax(HttpServletRequest request) { return "XMLHttpRequest".equals(request.getHeader("X-Requested-With")); }