类com.vaadin.server.VaadinService源码实例Demo

下面列出了怎么用com.vaadin.server.VaadinService的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: cuba   文件: LinkHandler.java
/**
 * Called to handle the link.
 */
public void handle() {
    try {
        ExternalLinkContext linkContext = new ExternalLinkContext(requestParams, action, app);
        for (LinkHandlerProcessor processor : processors) {
            if (processor.canHandle(linkContext)) {
                processor.handle(linkContext);
                break;
            }
        }
    } finally {
        VaadinRequest request = VaadinService.getCurrentRequest();
        WrappedSession wrappedSession = request.getWrappedSession();
        wrappedSession.removeAttribute(AppUI.LAST_REQUEST_PARAMS_ATTR);
        wrappedSession.removeAttribute(AppUI.LAST_REQUEST_ACTION_ATTR);
    }
}
 
源代码2 项目: hawkbit   文件: UserDetailsFormatter.java
public static UserDetails getCurrentUser() {
    final SecurityContext context = (SecurityContext) VaadinService.getCurrentRequest().getWrappedSession()
            .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
    Authentication authentication = context.getAuthentication();
    if (authentication instanceof OAuth2AuthenticationToken) {
        OidcUser oidcUser = (OidcUser) authentication.getPrincipal();
        Object details = authentication.getDetails();
        String tenant = "DEFAULT";
        if (details instanceof TenantAwareAuthenticationDetails) {
            tenant = ((TenantAwareAuthenticationDetails) details).getTenant();
        }
        return new UserPrincipal(oidcUser.getPreferredUsername(), "***", oidcUser.getGivenName(),
                oidcUser.getFamilyName(), oidcUser.getPreferredUsername(), oidcUser.getEmail(), tenant,
                oidcUser.getAuthorities());
    } else {
        return (UserDetails) authentication.getPrincipal();
    }
}
 
源代码3 项目: cia   文件: LogoutClickListener.java
@Override
public final void buttonClick(final ClickEvent event) {
	final ServiceResponse response = getApplicationManager().service(logoutRequest);


	if (ServiceResult.SUCCESS == response.getResult()) {
		UI.getCurrent().getNavigator().navigateTo(CommonsViews.MAIN_VIEW_NAME);
		UI.getCurrent().getSession().close();
		VaadinService.getCurrentRequest().getWrappedSession().invalidate();
	} else {
		showNotification(LOGOUT_FAILED,
                  ERROR_MESSAGE,
                  Notification.Type.WARNING_MESSAGE);
		LOGGER.info(LOG_MSG_LOGOUT_FAILURE,logoutRequest.getSessionId());
	}
}
 
源代码4 项目: jdal   文件: VaadinAccessDeniedHandler.java
/**
 * 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;
}
 
源代码5 项目: cuba   文件: ConnectionImpl.java
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;
}
 
源代码6 项目: cuba   文件: WebHttpSessionUrlsHolder.java
@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;
    }
}
 
源代码7 项目: cuba   文件: WebHttpSessionUrlsHolder.java
@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);
        }
    }
}
 
源代码8 项目: usergrid   文件: MainView.java
private void redirectToMainView() {
    // Close the VaadinServiceSession
    getUI().getSession().close();

    // Invalidate underlying session instead if login info is stored there
    VaadinService.getCurrentRequest().getWrappedSession().invalidate();
    getUI().getPage().setLocation( "/VAADIN" );
}
 
源代码9 项目: jdal   文件: VaadinUtils.java
/**
 * Exit application
 */
public static void exit() {
	VaadinSession.getCurrent().getSession().removeAttribute(
			HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
	UI.getCurrent().close();
	VaadinSession.getCurrent().close();
	Page page = Page.getCurrent();
	page.setLocation(VaadinService.getCurrentRequest().getContextPath() + "/logout"); 
}
 
源代码10 项目: vertx-vaadin   文件: SockJSPushHandler.java
private static void sendRefreshAndDisconnect(PushSocket socket) {
    sendNotificationAndDisconnect(socket, VaadinService
        .createCriticalNotificationJSON(null, null, null, null));
}
 
static String getUINotFoundErrorJSON(VaadinService service, VaadinRequest vaadinRequest) {
    return UidlRequestHandler.getUINotFoundErrorJSON(service, vaadinRequest);
}
 
源代码12 项目: cuba   文件: ConnectionImpl.java
@Nullable
protected String getUserRemoteAddress() {
    VaadinRequest currentRequest = VaadinService.getCurrentRequest();
    return currentRequest != null ? currentRequest.getRemoteAddr() : null;
}
 
源代码13 项目: cuba   文件: TestVaadinRequest.java
@Override
public VaadinService getService() {
    return null;
}
 
源代码14 项目: chipster   文件: Icon.java
private static String removePathEnd() {
	return VaadinService.getCurrent().getBaseDirectory().getAbsolutePath().replace(getPathEnd(), "");
}
 
源代码15 项目: jdal   文件: LoginUI.java
/**
 * @return
 */
private String getApplicationUrl() {
	return VaadinService.getCurrentRequest().getContextPath() + successUrl;
}
 
源代码16 项目: RDFUnit   文件: RDFUnitDemoSession.java
/**
 * Instantiates a new RDF unit demo session.
 *
 * @param service the service
 */
public RDFUnitDemoSession(VaadinService service) {
    super(service);
}