List of usage examples for org.springframework.web.context.request RequestContextHolder getRequestAttributes
@Nullable public static RequestAttributes getRequestAttributes()
From source file:org.dbflute.utflute.spring.web.bean.BarActionTest.java
protected void assertUTFluteSpringWebSystem() { assertNotNull(RequestContextHolder.getRequestAttributes()); assertTrue(getApplicationContext() instanceof WebApplicationContext); assertNotNull(barLogic);//from www. j a va 2 s . c o m }
From source file:org.esupportail.lecture.domain.utils.PortletService.java
/** * @throws InternalExternalException,NoExternalValueException * @throws NoExternalValueException/*from w ww. j a va 2 s. c om*/ * @see org.esupportail.lecture.domain.utils.ModeService#getUserAttribute(java.lang.String) */ @SuppressWarnings("unchecked") public List<String> getUserAttribute(final String attribute) throws InternalExternalException, NoExternalValueException { if (LOG.isDebugEnabled()) { LOG.debug("getUserAttribute(" + attribute + ")"); } List<String> values; try { final PortletRequest request = ((PortletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest(); // Portlet Request wich return multivalues attributes doesn't exist, Uportal added his implementation for this case : https://issues.jasig.org/browse/UP-933 Map<String, ArrayList<String>> userInfo = (Map<String, ArrayList<String>>) request .getAttribute("org.jasig.portlet.USER_INFO_MULTIVALUED"); //(Map<String, ArrayList<String>>) request.getAttribute(PortletRequest.USER_INFO); values = userInfo.get(attribute); } catch (Exception e) { LOG.error("Can't find attribute " + attribute); throw new InternalExternalException(e); } if (values == null) { throw new NoExternalValueException("User Attribute " + attribute + " not found! See your portlet.xml file for user-attribute definition."); } return values; }
From source file:org.jasig.portlet.emailpreview.dao.exchange.MailCredentialsProvider.java
@Override public void initialize(PortletRequest request, MailStoreConfiguration config, IAuthenticationService authService) { // Exchange//from w w w. j a va2s . c o m Credentials credentials = authService.getCredentials(request, config); // cache the credentials object to this thread RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes == null) { requestAttributes = new PortletRequestAttributes(request); RequestContextHolder.setRequestAttributes(requestAttributes); } requestAttributes.setAttribute(MailCredentialsProvider.EXCHANGE_CREDENTIALS_ATTRIBUTE, credentials, RequestAttributes.SCOPE_REQUEST); // Javamail Authenticator authenticator = authService.getAuthenticator(request, config); requestAttributes.setAttribute(MailCredentialsProvider.JAVAMAIL_CREDENTIALS_ATTRIBUTE, authenticator, RequestAttributes.SCOPE_REQUEST); }
From source file:com.tjport.common.spring.SpringMVCHolder.java
/** * ?spring mvcServletWebRequest/*from ww w .j av a 2 s.c o m*/ * * @return {@link ServletWebRequest} */ public static ServletWebRequest getServletWebRequest() { return ((ServletWebRequest) RequestContextHolder.getRequestAttributes()); }
From source file:org.esupportail.portlet.filemanager.services.auth.cas.UserCasAuthenticatorServiceRoot.java
public void initialize(SharedUserPortletParameters userParameters) { if (userParameters.getReceipt() == null) { if (proxyTicketService != null) { // Using userParameters.getUserInfos() - we can have a tool old PT which can be expired // So we get here the PortletRequest to get a new PT from Portal. //Map userInfos = userParameters.getUserInfos(); RequestAttributes attrs = RequestContextHolder.getRequestAttributes(); PortletRequest portletRequest = ((PortletRequestAttributes) attrs).getRequest(); Map userInfos = (Map) portletRequest.getAttribute(PortletRequest.USER_INFO); String ticket = (String) userInfos.get(this.userInfoTicketProperty); if (ticket != null) { try { log.debug("ticket from portal = " + ticket); CASReceipt receipt = proxyTicketService.getProxyTicket(ticket); userParameters.setReceipt(receipt); log.debug("CASReceipt = " + receipt); } catch (IOException e) { log.error(e);//from w w w.ja v a 2s .c o m } catch (SAXException e) { log.error(e); } catch (ParserConfigurationException e) { log.error(e); } } else { log.debug("no CAS ticket received from portal"); } } else { log.debug("CAS ticket already received from portal"); } } }
From source file:com.jaspersoft.jasperserver.api.security.externalAuth.sso.SsoTicketValidatorImpl.java
protected URI constructValidationUrl(final String ticket) throws AuthenticationServiceException { final Map<String, String> urlParameters = new HashMap<String, String>(); try {/*from ww w. ja v a 2 s . c o m*/ logger.debug("Constructing SSO token validation URL (ticket: " + ticket + ")"); final ExternalAuthProperties externalAuthProperties = getExternalAuthProperties(); String ticketParamName = externalAuthProperties.getTicketParameterName(); urlParameters.put(ticketParamName, ticket); String serviceParameterName = externalAuthProperties.getServiceParameterName(); if (serviceParameterName != null && serviceParameterName.length() > 0) { // in case of SOAP the service does not have to match the request. in that case we will specify the service if (getService() != null && getService().length() > 0) { urlParameters.put(serviceParameterName, getService()); } else { HttpServletRequest req = ((ServletRequestAttributes) RequestContextHolder .getRequestAttributes()).getRequest(); StringBuffer requestURL = req.getRequestURL(); urlParameters.put(serviceParameterName, requestURL.toString()); } } URIBuilder uriBuilder = new URIBuilder(externalAuthProperties.getSsoServerTicketValidationUrl()); for (Map.Entry<String, String> param : urlParameters.entrySet()) { uriBuilder.setParameter(param.getKey(), param.getValue()); } return uriBuilder.build(); } catch (URISyntaxException e) { logger.error("Failed to construct the token validation URL (ticket: " + ticket + ")", e); throw new AuthenticationServiceException(e.getMessage(), e); } }
From source file:br.com.caelum.vraptor.ioc.spring.SpringProvider.java
private boolean springListenerAlreadyCalled() { return RequestContextHolder.getRequestAttributes() != null; }
From source file:aode.lx.service.impl.BaseServiceImpl.java
/** * ??// w w w .j av a 2 s. com * * ??? * @return */ @Override public Page<T> findAllPaginated() { RequestAttributes ar = RequestContextHolder.getRequestAttributes(); HttpServletRequest request = ((ServletRequestAttributes) ar).getRequest(); PageRequest pageRequest = PageRequestBulider.getPageRequest(request); return getRepository().findAll(pageRequest); }
From source file:it.reply.orchestrator.resource.DeploymentResourceAssembler.java
private boolean isInHttpRequest() { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes != null && requestAttributes instanceof ServletRequestAttributes) { HttpServletRequest servletRequest = ((ServletRequestAttributes) requestAttributes).getRequest(); return servletRequest != null; }//from www .j a v a 2s . co m return false; }
From source file:org.magnum.dataup.CopyOfMyVideoController.java
private String getUrlBaseForLocalServer() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest();//from ww w. j a va 2s. com String base = "http://" + request.getServerName() + ((request.getServerPort() != 80) ? ":" + request.getServerPort() : ""); //System.out.println(base); return base; }