当前位置: 首页>>代码示例>>Java>>正文


Java VaadinService.getCurrentRequest方法代码示例

本文整理汇总了Java中com.vaadin.server.VaadinService.getCurrentRequest方法的典型用法代码示例。如果您正苦于以下问题:Java VaadinService.getCurrentRequest方法的具体用法?Java VaadinService.getCurrentRequest怎么用?Java VaadinService.getCurrentRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vaadin.server.VaadinService的用法示例。


在下文中一共展示了VaadinService.getCurrentRequest方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUserRemoteAddress

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
@Nullable
protected String getUserRemoteAddress() {
    VaadinRequest currentRequest = VaadinService.getCurrentRequest();

    String userRemoteAddress = null;

    if (currentRequest != null) {
        String xForwardedFor = currentRequest.getHeader("X_FORWARDED_FOR");
        if (StringUtils.isNotBlank(xForwardedFor)) {
            String[] strings = xForwardedFor.split(",");
            String userAddressFromHeader = StringUtils.trimToEmpty(strings[strings.length - 1]);

            if (StringUtils.isNotEmpty(userAddressFromHeader)) {
                userRemoteAddress = userAddressFromHeader;
            } else {
                userRemoteAddress = currentRequest.getRemoteAddr();
            }
        } else {
            userRemoteAddress = currentRequest.getRemoteAddr();
        }
    }

    return userRemoteAddress;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:ConnectionImpl.java

示例2: isUidlRequest

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
/**
 * Test if current request is an UIDL request
 * @return true if in UIDL request, false otherwise
 */
private boolean isUidlRequest() {
	VaadinRequest request = VaadinService.getCurrentRequest();
	
	if (request == null)
		return false;
	
	 String pathInfo = request.getPathInfo();

	 if (pathInfo == null) {
            return false;
	 }
	 
	 if (pathInfo.startsWith("/" + ApplicationConstants.UIDL_PATH)) {
            return true;
        }

        return false;
}
 
开发者ID:chelu,项目名称:jdal,代码行数:23,代码来源:VaadinAccessDeniedHandler.java

示例3: checkAuthentication

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
/**
 * Check authentication using {@link Authenticate} annotation on given view class or the {@link UI} class to which
 * navigator is bound.
 * @param navigationState Navigation state
 * @param viewConfiguration View configuration
 * @return <code>true</code> if authentication is not required or if it is required and the current
 *         {@link AuthContext} is authenticated, <code>false</code> otherwise
 * @throws ViewNavigationException Missing {@link AuthContext} from context or other unexpected error
 */
protected boolean checkAuthentication(final String navigationState, final ViewConfiguration viewConfiguration)
		throws ViewNavigationException {
	if (!suspendAuthenticationCheck) {
		Authenticate authc = (viewConfiguration != null)
				? viewConfiguration.getAuthentication().orElse(uiAuthenticate) : uiAuthenticate;
		if (authc != null) {

			// check auth context
			final AuthContext authContext = AuthContext.getCurrent().orElseThrow(() -> new ViewNavigationException(
					navigationState,
					"No AuthContext available as Context resource: failed to process Authenticate annotation on View or UI"));

			if (!authContext.getAuthentication().isPresent()) {
				// not authenticated, try to authenticate from request
				final VaadinRequest request = VaadinService.getCurrentRequest();
				if (request != null) {
					try {
						authContext.authenticate(VaadinHttpRequest.create(request));
						// authentication succeded
						return true;
					} catch (@SuppressWarnings("unused") AuthenticationException e) {
						// failed, ignore
					}
				}
				onAuthenticationFailed(authc, navigationState);
				return false;
			}

		}
	}
	return true;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:42,代码来源:NavigatorActuator.java

示例4: ensureInited

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
/**
 * Ensure that a {@link DeviceInfo} is available from given Vaadin <code>session</code>. For successful
 * initialization, a {@link VaadinService#getCurrentRequest()} must be available.
 * @param session Vaadin session (not null)
 */
static void ensureInited(VaadinSession session) {
	ObjectUtils.argumentNotNull(session, "VaadinSession must be not null");
	synchronized (session) {
		if (session.getAttribute(SESSION_ATTRIBUTE_NAME) == null && VaadinService.getCurrentRequest() != null) {
			session.setAttribute(SESSION_ATTRIBUTE_NAME, create(VaadinService.getCurrentRequest()));
		}
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:14,代码来源:DeviceInfo.java

示例5: getRememberMeCookie

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
private Cookie getRememberMeCookie()
{
	final VaadinRequest vaadinRequest = VaadinService.getCurrentRequest();
	if(vaadinRequest == null)
	{
		logger.warn("Could not get the VaadinRequest. It might be that we are called from a websocket connection.");
		return null;
	}
	
	//
	// Get the remember me cookie
	final Cookie[] cookies = vaadinRequest.getCookies();
	if (cookies == null)
	{
		return null;
	}

	for (final Cookie cookie : cookies)
	{
		if (COOKIENAME_RememberMe.equals(cookie.getName()))
		{
			return cookie;
		}
	}

	return null;
}
 
开发者ID:metasfresh,项目名称:metasfresh-procurement-webui,代码行数:28,代码来源:LoginRememberMeService.java

示例6: getWebBrowserDetails

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
protected WebBrowser getWebBrowserDetails() {
    // timezone info is passed only on VaadinSession creation
    WebBrowser webBrowser = VaadinSession.getCurrent().getBrowser();
    VaadinRequest currentRequest = VaadinService.getCurrentRequest();
    // update web browser instance if current request is not null
    // it can be null in case of background/async processing of login request
    if (currentRequest != null) {
        webBrowser.updateRequestDetails(currentRequest);
    }
    return webBrowser;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:12,代码来源:ConnectionImpl.java

示例7: onAppStarted

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
@Order(Events.HIGHEST_PLATFORM_PRECEDENCE + 10)
@EventListener
protected void onAppStarted(AppStartedEvent event) throws LoginException {
    Connection connection = event.getApp().getConnection();
    // can be already authenticated by another event listener
    if (webIdpConfig.getIdpEnabled()
            && !connection.isAuthenticated()) {
        VaadinRequest currentRequest = VaadinService.getCurrentRequest();

        if (currentRequest != null) {
            Principal principal = currentRequest.getUserPrincipal();

            if (principal instanceof IdpSessionPrincipal) {
                IdpSession idpSession = ((IdpSessionPrincipal) principal).getIdpSession();

                Locale locale = event.getApp().getLocale();

                ExternalUserCredentials credentials = new ExternalUserCredentials(principal.getName(), locale);
                credentials.setSessionAttributes(
                        ImmutableMap.of(
                                IdpService.IDP_USER_SESSION_ATTRIBUTE,
                                idpSession.getId()
                        ));

                connection.login(credentials);
            }
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:30,代码来源:IdpLoginLifecycleManager.java

示例8: getUrls

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
@Nullable
public List<String> getUrls(String selectorId) {
    VaadinRequest vaadinRequest = VaadinService.getCurrentRequest();
    if (vaadinRequest != null)
        return (List) vaadinRequest.getWrappedSession().getAttribute(getAttributeName(selectorId));
    else {
        HttpSession httpSession = getHttpSession();
        return httpSession != null ? (List<String>) httpSession.getAttribute(getAttributeName(selectorId)) : null;
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:13,代码来源:WebHttpSessionUrlsHolder.java

示例9: setUrls

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
@Override
public void setUrls(String selectorId, List<String> urls) {
    VaadinRequest vaadinRequest = VaadinService.getCurrentRequest();
    if (vaadinRequest != null)
        vaadinRequest.getWrappedSession().setAttribute(getAttributeName(selectorId), urls);
    else {
        HttpSession httpSession = getHttpSession();
        if (httpSession != null) {
            httpSession.setAttribute(getAttributeName(selectorId), urls);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:13,代码来源:WebHttpSessionUrlsHolder.java

示例10: userSessionLoggedIn

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
@Override
public void userSessionLoggedIn(UserSession session) {
    VaadinRequest currentRequest = VaadinService.getCurrentRequest();

    if (currentRequest != null) {
        Principal principal = currentRequest.getUserPrincipal();

        if (principal instanceof IdpSessionPrincipal) {
            IdpSession idpSession = ((IdpSessionPrincipal) principal).getIdpSession();
            session.setAttribute(IdpService.IDP_USER_SESSION_ATTRIBUTE, idpSession.getId());
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:14,代码来源:IdpAuthProvider.java

示例11: getCurrentRequest

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
private static VaadinRequest getCurrentRequest() {
    VaadinRequest request = VaadinService.getCurrentRequest();
    if (request == null) {
        throw new IllegalStateException(
                "No request bound to current thread");
    }
    return request;
}
 
开发者ID:jvalenciag,项目名称:VaadinSpringShiroMongoDB,代码行数:9,代码来源:CurrentUser.java

示例12: getCurrentRequest

import com.vaadin.server.VaadinService; //导入方法依赖的package包/类
private static VaadinRequest getCurrentRequest() {
    VaadinRequest request = VaadinService.getCurrentRequest();
    if (request == null) {
        throw new IllegalStateException("No request bound to current thread");
    }
    return request;
}
 
开发者ID:peholmst,项目名称:vaadin-mockapp,代码行数:8,代码来源:CurrentUser.java


注:本文中的com.vaadin.server.VaadinService.getCurrentRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。