Java 类com.vaadin.server.VaadinServletRequest 实例源码

项目:holon-vaadin7    文件:AbstractVaadinSpringTest.java   
@SuppressWarnings("serial")
@Override
protected VaadinServletRequest buildVaadinRequest(String location) {
    return new SpringVaadinServletRequest(request, (VaadinServletService) vaadinSession.getService(), false) {

        /*
         * (non-Javadoc)
         * @see javax.servlet.ServletRequestWrapper#getParameter(java.lang.String)
         */
        @Override
        public String getParameter(String name) {
            if ("v-loc".equals(name)) {
                return location;
            }
            return super.getParameter(name);
        }
    };
}
项目:holon-vaadin7    文件:AbstractVaadinTest.java   
/**
 * Build VaadinServletRequest using a location
 * @param location Page location
 * @return VaadinServletRequest
 */
@SuppressWarnings("serial")
protected VaadinServletRequest buildVaadinRequest(final String location) {
    return new VaadinServletRequest(buildHttpServletRequest(), (VaadinServletService) vaadinSession.getService()) {

        /*
         * (non-Javadoc)
         * @see javax.servlet.ServletRequestWrapper#getParameter(java.lang.String)
         */
        @Override
        public String getParameter(String name) {
            if ("v-loc".equals(name)) {
                return location;
            }
            return super.getParameter(name);
        }

    };
}
项目:osc-core    文件:UiServlet.java   
/**
 * Every incoming request should set the current user context
 */
@Override
protected VaadinServletRequest createVaadinRequest(HttpServletRequest request) {
    VaadinServletRequest vaadinRequest = super.createVaadinRequest(request);

    VaadinSession vaadinSession;
    try {
        vaadinSession = getService().findVaadinSession(vaadinRequest);
    } catch (Exception e) {
        // This exception will be handled later when we try to service
        // the request
        vaadinSession = null;
    }

    if(vaadinSession != null) {
        this.userContext.setUser((String) vaadinSession.getAttribute("user"));
    } else {
        this.userContext.setUser(null);
    }

    return vaadinRequest;
}
项目:holon-vaadin    文件:AbstractVaadinSpringTest.java   
@SuppressWarnings("serial")
@Override
protected VaadinServletRequest buildVaadinRequest(String location) {
    return new SpringVaadinServletRequest(request, (VaadinServletService) vaadinSession.getService(), false) {

        /*
         * (non-Javadoc)
         * @see javax.servlet.ServletRequestWrapper#getParameter(java.lang.String)
         */
        @Override
        public String getParameter(String name) {
            if ("v-loc".equals(name)) {
                return location;
            }
            return super.getParameter(name);
        }
    };
}
项目:holon-vaadin    文件:AbstractVaadinTest.java   
/**
 * Build VaadinServletRequest using a location
 * @param location Page location
 * @return VaadinServletRequest
 */
@SuppressWarnings("serial")
protected VaadinServletRequest buildVaadinRequest(final String location) {
    return new VaadinServletRequest(buildHttpServletRequest(), (VaadinServletService) vaadinSession.getService()) {

        /*
         * (non-Javadoc)
         * @see javax.servlet.ServletRequestWrapper#getParameter(java.lang.String)
         */
        @Override
        public String getParameter(String name) {
            if ("v-loc".equals(name)) {
                return location;
            }
            return super.getParameter(name);
        }

    };
}
项目:cherry-web    文件:ControlServlet.java   
@Override
protected boolean isStaticResourceRequest(HttpServletRequest request) {
    // set user and trace ...

    boolean ret = super.isStaticResourceRequest(request);
    if (!ret) {
        try {
            VaadinServletRequest vs = createVaadinRequest(request);
            VaadinSession vaadinSession = getService().findVaadinSession(vs);
            request.setAttribute("__vs", vaadinSession);
            for (UI ui : vaadinSession.getUIs()) {
                if (ui instanceof ControlUi)
                    ((ControlUi)ui).requestBegin(request);
            }
        } catch (Throwable t) {

        }
    }
    return ret;
   }
项目:hypothesis    文件:PublicPacksPresenter.java   
private String constructStartUrl(String uid, boolean returnBack) {
    StringBuilder builder = new StringBuilder();
    String contextUrl = ServletUtil.getContextURL((VaadinServletRequest) VaadinService.getCurrentRequest());
    builder.append(contextUrl);
    builder.append("/process/?");

    // client debug
    // builder.append("gwt.codesvr=127.0.0.1:9997&");

    builder.append("token=");
    builder.append(uid);
    builder.append("&fs");
    if (returnBack) {
        builder.append("&bk=true");
    }

    String lang = ControlledUI.getCurrentLanguage();
    if (lang != null) {
        builder.append("&lang=");
        builder.append(lang);
    }

    return builder.toString();
}
项目:minimal-j    文件:MjVaadinServlet.java   
@Override
protected VaadinServletRequest createVaadinRequest(HttpServletRequest request) {
    VaadinServletRequest vaadinServletRequest = super.createVaadinRequest(request);
    Subject.setCurrent((Subject) vaadinServletRequest.getWrappedSession().getAttribute("subject"));
    // System.out.println("Set subject to " + (Subject.getCurrent() != null ? Subject.getCurrent().getName() : "-"));
    return vaadinServletRequest;
}
项目:ilves    文件:OpenIdUtil.java   
/**
 * Gets verification result based on session and request parameters. This should be called when
 * processing the OpenId return request.
 * @param siteUrl the site URL
 * @param returnViewName the return view name
 *
 * @return the verification result
 * @throws DiscoveryException if discovery exception occurs.
 * @throws MessageException if message exception occurs.
 * @throws AssociationException if association exception occurs.
 */
public static VerificationResult getVerificationResult(final String siteUrl
        , final String returnViewName) throws MessageException, DiscoveryException,
        AssociationException {
    final ConsumerManager consumerManager = UI.getCurrent().getSession().getAttribute(ConsumerManager.class);
    final DiscoveryInformation discovered = UI.getCurrent().getSession().getAttribute(
            DiscoveryInformation.class);
    UI.getCurrent().getSession().setAttribute(ConsumerManager.class, null);
    UI.getCurrent().getSession().setAttribute(DiscoveryInformation.class, null);

    final HttpServletRequest request = ((VaadinServletRequest) VaadinService.getCurrentRequest())
            .getHttpServletRequest();

    final StringBuffer urlBuilder = new StringBuffer(siteUrl + returnViewName);
    final String queryString = request.getQueryString();
    if (queryString != null) {
        urlBuilder.append('?');
        urlBuilder.append(queryString);
    }
    final String requestUrl = urlBuilder.toString();

    final ParameterList openidResp = new ParameterList(request.getParameterMap());

    // verify the response
    return consumerManager.verify(requestUrl,
            openidResp, discovered);
}
项目:hypothesis    文件:PublicPacksPresenter.java   
private String constructStartJnlp(String uid) {
    StringBuilder builder = new StringBuilder();
    String contextUrl = ServletUtil.getContextURL((VaadinServletRequest) VaadinService.getCurrentRequest());
    builder.append(contextUrl);
    builder.append("/resource/browserapplication.jnlp?");
    builder.append("jnlp.app_url=");
    builder.append(contextUrl);
    builder.append("/process/");
    builder.append("&jnlp.close_key=");
    builder.append("close.html");
    builder.append("&jnlp.token=");
    builder.append(uid);

    return builder.toString();
}
项目:holon-vaadin7    文件:AbstractVaadinSpringTest.java   
@Override
protected VaadinServletRequest buildVaadinRequest() {
    return new SpringVaadinServletRequest(request, (VaadinServletService) vaadinSession.getService(), false);
}
项目:holon-vaadin    文件:AbstractVaadinSpringTest.java   
@Override
protected VaadinServletRequest buildVaadinRequest() {
    return new SpringVaadinServletRequest(request, (VaadinServletService) vaadinSession.getService(), false);
}
项目:minimal-j    文件:MjSpringVaadinServlet.java   
@Override
protected VaadinServletRequest createVaadinRequest(HttpServletRequest request) {
    VaadinServletRequest vaadinServletRequest = super.createVaadinRequest(request);
    Subject.setCurrent((Subject) vaadinServletRequest.getWrappedSession().getAttribute("subject"));
    return vaadinServletRequest;
}
项目:ilves    文件:OpenIdLoginViewlet.java   
/**
 * SiteView constructSite occurred.
 */
@Override
public void enter(final String parameterString) {

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    final Company company = getSite().getSiteContext().getObject(Company.class);
    final HttpServletRequest request = ((VaadinServletRequest) VaadinService.getCurrentRequest())
            .getHttpServletRequest();

    try {
        final VerificationResult verification = OpenIdUtil.getVerificationResult(company.getUrl(), "openidlogin");
        final Identifier identifier = verification.getVerifiedId();

        if (identifier == null) {
            ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
                    getSite().localize("message-login-failed")
                            + ":" + verification.getStatusMsg(),
                    Notification.Type.ERROR_MESSAGE
            );
        }

        final User user = UserDao.getUserByOpenIdIdentifier(entityManager, company, identifier.getIdentifier());

        if (user == null) {
            LOGGER.warn("User OpenID login failed due to not registered Open ID identifier: "
                    + identifier.getIdentifier()
                    + " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")");
            ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
                    getSite().localize("message-login-failed"),
                    Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (user.isLockedOut()) {
            LOGGER.warn("User login failed due to user being locked out: " + user.getEmailAddress()
                    + " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")");
            ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
                    getSite().localize("message-login-failed"),
                    Notification.Type.WARNING_MESSAGE);
            return;
        }

        LOGGER.info("User login: " + user.getEmailAddress()
                + " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")");
        AuditService.log(getSite().getSiteContext(), "openid password login");

        final List<Group> groups = UserDao.getUserGroups(entityManager, company, user);

        SecurityService.updateUser(getSite().getSiteContext(), user);

        ((SecurityProviderSessionImpl) getSite().getSecurityProvider()).setUser(user, groups);

        ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(),
                getSite().getCurrentNavigationVersion().getDefaultPageName(),
                getSite().localize("message-login-success") + " (" + user.getEmailAddress() + ")",
                Notification.Type.HUMANIZED_MESSAGE);

    } catch (final Exception exception) {
        LOGGER.error("Error logging in OpenID user.", exception);
        ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
                getSite().localize("message-login-error"),
                Notification.Type.ERROR_MESSAGE);
    }
}
项目:holon-vaadin7    文件:AbstractVaadinTest.java   
/**
 * Build the UICreateEvent to pass to UIProvider
 * @param uiClass UI class
 * @param location Optional Page location
 * @return UICreateEvent
 */
protected UICreateEvent buildUiCreateEvent(Class<? extends UI> uiClass, String location) {
    VaadinServletRequest request = (location != null) ? buildVaadinRequest(location) : buildVaadinRequest();

    CurrentInstance.set(VaadinRequest.class, request);

    CurrentInstance.set(VaadinSession.class, vaadinSession);

    return new UICreateEvent(request, uiClass, TEST_UIID);
}
项目:holon-vaadin    文件:AbstractVaadinTest.java   
/**
 * Build the UICreateEvent to pass to UIProvider
 * @param uiClass UI class
 * @param location Optional Page location
 * @return UICreateEvent
 */
protected UICreateEvent buildUiCreateEvent(Class<? extends UI> uiClass, String location) {
    VaadinServletRequest request = (location != null) ? buildVaadinRequest(location) : buildVaadinRequest();

    CurrentInstance.set(VaadinRequest.class, request);

    CurrentInstance.set(VaadinSession.class, vaadinSession);

    return new UICreateEvent(request, uiClass, TEST_UIID);
}
项目:holon-vaadin7    文件:AbstractVaadinTest.java   
/**
 * Build VaadinServletRequest
 * @return VaadinServletRequest
 */
protected VaadinServletRequest buildVaadinRequest() {
    return new VaadinServletRequest(buildHttpServletRequest(), (VaadinServletService) vaadinSession.getService());
}
项目:holon-vaadin    文件:AbstractVaadinTest.java   
/**
 * Build VaadinServletRequest
 * @return VaadinServletRequest
 */
protected VaadinServletRequest buildVaadinRequest() {
    return new VaadinServletRequest(buildHttpServletRequest(), (VaadinServletService) vaadinSession.getService());
}