List of usage examples for org.springframework.web.context.request RequestContextHolder getRequestAttributes
@Nullable public static RequestAttributes getRequestAttributes()
From source file:com.gwtplatform.dispatch.rpc.server.spring.HttpSessionSecurityCookieFilter.java
@Override protected HttpSession getSession() { return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getSession(); }
From source file:org.jasig.portlet.calendar.adapter.exchange.ExchangeWsCredentialsProvider.java
@Override public Credentials getCredentials(AuthScope authscope) { final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); final Credentials credentials = (Credentials) requestAttributes.getAttribute( ExchangeWsCredentialsProvider.EXCHANGE_CREDENTIALS_ATTRIBUTE, RequestAttributes.SCOPE_SESSION); return credentials; }
From source file:org.openmrs.module.openconceptlab.extension.html.HighlightSubscribedConcept.java
public String getOverrideContent(String bodyContent) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest();// www .j a v a 2s . com Concept concept = Context.getConceptService() .getConcept(Integer.parseInt(request.getParameter("conceptId"))); String message = ""; if (service.isSubscribedConcept(concept.getUuid())) { message = "<div class=\"highlight\">This concept was downloaded from your Open Concept Lab subscription. Any local changes that you make to this concept here will be lost the next time you download updates from the OCL server. \n\n We strongly recommend that you do not edit this concept locally.</div>"; } return message; }
From source file:com.mtgi.analytics.servlet.SpringSessionContext.java
public String getContextUserId() { ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder .getRequestAttributes();//from ww w . j av a 2 s .co m return attributes == null ? null : attributes.getRequest().getRemoteUser(); }
From source file:org.hdiv.web.validator.AbstractEditableParameterValidator.java
/** * Obtains the errors from request detected by HDIV during the validation process of the editable parameters. * /* ww w. j a v a 2 s . c o m*/ * @param errors * errors detected by HDIV during the validation process of the editable parameters. */ @SuppressWarnings("unchecked") protected void validateEditableParameters(Errors errors) { RequestAttributes attr = RequestContextHolder.getRequestAttributes(); if (attr == null) { // This is not a web request return; } Hashtable<String, String[]> parameters = (Hashtable<String, String[]>) attr .getAttribute(Constants.EDITABLE_PARAMETER_ERROR, 0); if (parameters != null && parameters.size() > 0) { for (String param : parameters.keySet()) { String[] unauthorizedValues = parameters.get(param); this.rejectParamValues(param, unauthorizedValues, errors); } } }
From source file:com.sesnu.orion.config.AccessInterceptor.java
@Override public String onPrepareStatement(String sql) { String tableName = getTableName(sql.toLowerCase()); // System.out.println(tableName); if (tableName == null) { return sql; }/*from w ww.j ava 2s .c o m*/ if (!protectedTables.contains(tableName) || sql.indexOf("select id from orders") > -1) { // System.out.println("table not found in array"); return sql; } if (new ConfigFile().getProp().get("devMode").equals("true")) return sql; RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); User user = null; if (attributes != null) { user = (User) attributes.getAttribute("user", 0); } else { return sql; } if (user != null && user.getRole().equals("Admin")) return sql; List<Long> allowedOrderRefs = (List<Long>) attributes.getAttribute("grantedIds", 0); if (allowedOrderRefs == null) { allowedOrderRefs = new ArrayList<Long>(); allowedOrderRefs.add(0l); } String parsedSql = insertId(sql.toLowerCase(), allowedOrderRefs, tableName); System.out.println("parsed sql " + parsedSql); return parsedSql; }
From source file:com.beginner.core.utils.ProjectUtil.java
/** * ?IP(?????)/*from w w w .j av a 2 s .c o m*/ */ public static String ip() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest(); return request.getLocalAddr(); }
From source file:org.esupportail.cas.audit.support.ServiceAuditTrailManager.java
public void record(final AuditActionContext auditActionContext) { if (("SERVICE_TICKET_CREATED").equals(auditActionContext.getActionPerformed())) { String resourceOperatedUpon = auditActionContext.getResourceOperatedUpon(); if (resourceOperatedUpon.contains(" for ")) { String parts[] = auditActionContext.getResourceOperatedUpon().split(" for "); String ticket = parts[0]; String service = parts[1]; ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder .getRequestAttributes(); HttpServletRequest req = sra.getRequest(); String useragent = req.getHeader("User-Agent"); LOG.info("[" + auditActionContext.getWhenActionWasPerformed() + "] " + "[IP:" + auditActionContext.getClientIpAddress() + "] " + "[ID:" + auditActionContext.getPrincipal() + "] " + "[TICKET:" + ticket + "] " + "[SERVICE:" + service + "] " + "[USER-AGENT:" + useragent + "]"); }//from w w w. j av a2 s .co m } }
From source file:com.epam.cme.storefront.breadcrumb.impl.DefaultResourceBreadcrumbBuilder.java
protected MessageSource getMessageSource() { final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder .getRequestAttributes();/*ww w. j av a 2s . c om*/ if (requestAttributes != null) { final HttpServletRequest request = requestAttributes.getRequest(); final Theme theme = RequestContextUtils.getTheme(request); if (theme != null) { return theme.getMessageSource(); } } return null; }
From source file:org.jasig.portlet.emailpreview.dao.exchange.MailCredentialsProvider.java
@Override public void clear() { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes != null) { // Exchange requestAttributes.setAttribute(MailCredentialsProvider.EXCHANGE_CREDENTIALS_ATTRIBUTE, null, RequestAttributes.SCOPE_REQUEST); // Javamail requestAttributes.setAttribute(MailCredentialsProvider.JAVAMAIL_CREDENTIALS_ATTRIBUTE, null, RequestAttributes.SCOPE_REQUEST); }//from ww w . j a v a 2 s . com }