Ejemplo n.º 1
0
  public void run(final RootPanel rp, final String nick) {

    if (Cookies.getCookie(nick) == null) Cookies.setCookie(nick, "" + 0);

    cl.setPageSize(500);

    final Button sendMessage =
        new Button(
            "sendMessage",
            new ClickHandler() {

              public void onClick(ClickEvent event) {

                if (!message.getText().equals("")) {
                  new Post().postJson(SERVERURL, nick.toString(), message.getText());
                  message.setText("");
                }
              }
            });

    rp.get("mainDiv2").setVisible(true);
    message.getElement().setAttribute("placeholder", "Introduce your message");
    message.getElement().setAttribute("id", "message");

    cl.getElement().setAttribute("id", "chatBox");

    sendMessage.getElement().setAttribute("id", "sendMessage");
    sendMessage.setText("Send");

    vp.getElement().setAttribute("id", "verticalPanel");
    hp.getElement().setAttribute("id", "horizontalPanel");

    panel.getElement().setAttribute("id", "scroller");

    hp.add(message);
    hp.add(sendMessage);
    panel.add(cl);
    vp.add(panel);

    vp.add(hp);
    rp.get("mainDiv2").add(vp);

    Timer t =
        new Timer() {
          @Override
          public void run() {
            getMessages();

            if (chatList != null && Integer.parseInt(Cookies.getCookie(nick)) < chatList.size()) {
              cl.setRowCount(chatList.size() + 1, true);
              cl.setRowData(
                  Integer.parseInt(Cookies.getCookie(nick)),
                  chatList.subList(Integer.parseInt(Cookies.getCookie(nick)), chatList.size()));
              panel.setVerticalScrollPosition(panel.getMaximumVerticalScrollPosition() - 1);
              Cookies.setCookie(nick, "" + chatList.size());
            }
          }
        };
    t.scheduleRepeating(1000);
  }
Ejemplo n.º 2
0
  /** Authenticates a user. */
  public void authenticate(User user) {

    if (user != null) {

      if (Cookies.isCookieEnabled()) {
        Cookies.setCookie(
            CoreConstants.COOKIES_USER,
            user.getEmail(),
            CoreConstants.COOKIES_EXPIRATION_DATE,
            null,
            "/",
            false);
        Cookies.setCookie(
            CoreConstants.COOKIES_SESSION,
            user.getSession(),
            CoreConstants.COOKIES_EXPIRATION_DATE,
            null,
            "/",
            false);

        if (user.isConfirmed()) {
          Modules.getInstance().initializeModules(user);

        } else {
          addTab(new ActivationTab());
        }
      } else {
        setWarningMessage("Unable to sign in: cookies must be enabled.");
        addTab(new SignInTab());
      }
    } else {
      addTab(new SignInTab());
    }
  }
Ejemplo n.º 3
0
  private boolean rememberMe() {
    final String accountName = Cookies.getCookie(COOKIE_RM_ACCOUNT);
    final String token = Cookies.getCookie(COOKIE_RM_TOKEN);

    if (accountName != null && token != null) {
      RPC.getAccountManagementRPC()
          .login(
              accountName,
              token,
              new AsyncCallback<LoginResponse>() {
                @Override
                public void onSuccess(LoginResponse result) {
                  handleLoginResponse(result, accountName, true);
                }

                @Override
                public void onFailure(Throwable caught) {
                  throw new IllegalStateException(caught);
                }
              });
      return true;
    } else {
      return false;
    }
  }
Ejemplo n.º 4
0
 public void refreshWebDAVPassword() {
   Configuration conf = (Configuration) GWT.create(Configuration.class);
   String domain = Window.Location.getHostName();
   String path = Window.Location.getPath();
   String cookie = conf.webdavCookie();
   webDAVPassword = Cookies.getCookie(cookie);
   Cookies.setCookie(cookie, "", null, domain, path, false);
 }
Ejemplo n.º 5
0
 public static void displayCookies() {
   StringBuilder cookies = new StringBuilder();
   for (String name : Cookies.getCookieNames()) {
     String value = Cookies.getCookie(name);
     cookies.append(name).append(" = ").append(value).append("<br/>");
   }
   Info.display("Cookies", cookies.toString());
 }
 public adresses_dispo() {
   initWidget(uiBinder.createAndBindUi(this));
   charger_plage();
   MonNom.setText(
       "Vous etes :"
           + Cookies.getCookie("nomutilisateur")
           + "   "
           + Cookies.getCookie("prenomutilisateur"));
 }
Ejemplo n.º 7
0
 public int getPeriod() {
   String speriod = Cookies.getCookie(Heliostat.REFRESH_PERIOD);
   if (speriod == null) {
     speriod = "1000";
     Cookies.setCookie(Heliostat.REFRESH_PERIOD, speriod);
   }
   int period = Integer.parseInt(speriod);
   return period;
 }
Ejemplo n.º 8
0
  public User() {
    // load info from cookie
    Username = Cookies.getCookie("USER_NAME");
    Password = Cookies.getCookie("USER_PASSWORD");

    // check values
    if (Username == null) {
      Username = "";
    }
    if (Password == null) {
      Password = "";
    }
  }
Ejemplo n.º 9
0
        private void sendEvent() {
          // Delete cookies: this should actually happen on
          // the server and NOT on the client. However, I
          // (rodrigo) was unable to get it to work. For some
          // unknown reason, the cookies aren't clearing when
          // cleared on the server! This is a temporary solution
          // TODO: fix it
          if (Cookies.getCookie("uid") != null) {
            GWT.log("LogoutHandler - Cookie didn't clear on the server!!", null);
          }
          Cookies.removeCookie("uid");

          GWT.log("LogoutHandler - Logging out, sending GotUserEvent with null user", null);
          BooksPicker.eventBus.fireEvent(new GotUserEvent(null));
        }
Ejemplo n.º 10
0
  private void userChanged() {
    if (users == null) {
      return;
    }
    ClientUser user = null;
    if (users.getSelectedIndex() > 0) {
      final String email = users.getValue(users.getSelectedIndex());
      if (userInfo.containsKey(email)) {
        user = userInfo.get(email);
      }

      Cookies.setCookie(
          "email",
          users.getValue(users.getSelectedIndex()),
          ParamSetSelectionController.getCookieExpirationDate(),
          null,
          "/",
          false);
    }

    // Figure out whether this user can edit parameters or not
    final boolean editorEnabled = user != null && user.isParameterEditorEnabled();
    if (paramsEditor != null) {
      paramsEditor.setEditorEnabled(editorEnabled, user);
    }
    setOutputPathChangeEnabled(user != null && user.isOutputPathChangeEnabled());
  }
Ejemplo n.º 11
0
  /**
   * Creates the center view in viewport by the user role, if the role is building modeler, then
   * show the building modeler view, else show the ui designer view.
   *
   * @param authority the authority
   */
  private void createCenter(Authority authority) {
    List<String> roles = authority.getRoles();
    modelerContainer = new LayoutContainer();
    modelerContainer.setLayout(new FitLayout());
    WidgetSelectionUtil widgetSelectionUtil = new WidgetSelectionUtil(eventBus);
    if (roles.contains(Role.ROLE_ADMIN)
        || (roles.contains(Role.ROLE_DESIGNER) && roles.contains(Role.ROLE_MODELER))) {
      this.buildingModelerView = new BuildingModelerView(eventBus);
      this.uiDesignerView = new UIDesignerView(widgetSelectionUtil);
      this.uiDesignerPresenter =
          new UIDesignerPresenter(eventBus, this.uiDesignerView, widgetSelectionUtil);
      if (Role.ROLE_DESIGNER.equals(Cookies.getCookie(Constants.CURRETN_ROLE))) {
        modelerContainer.add(uiDesignerView);
      } else {
        modelerContainer.add(buildingModelerView);
      }
    } else if (roles.contains(Role.ROLE_MODELER) && !roles.contains(Role.ROLE_DESIGNER)) {
      this.buildingModelerView = new BuildingModelerView(eventBus);
      modelerContainer.add(buildingModelerView);
    } else if (roles.contains(Role.ROLE_DESIGNER) && !roles.contains(Role.ROLE_MODELER)) {
      this.uiDesignerView = new UIDesignerView(widgetSelectionUtil);
      this.uiDesignerPresenter =
          new UIDesignerPresenter(eventBus, this.uiDesignerView, widgetSelectionUtil);
      modelerContainer.add(uiDesignerView);
    }

    BorderLayoutData data = new BorderLayoutData(Style.LayoutRegion.CENTER);
    data.setMargins(new Margins(0, 5, 0, 5));
    viewport.add(modelerContainer, data);
  }
 private void registerSessionCookie(String sessionId) {
   String sessionID = sessionId /*(Get sessionID from server's response to your login request.)*/;
   final long DURATION =
       1000 * 60 * 60 * 24 * 14; // duration remembering login. 2 weeks in this example.
   Date expires = new Date(System.currentTimeMillis() + DURATION);
   Cookies.setCookie("sid", sessionID, expires, null, "/", false);
 }
Ejemplo n.º 13
0
  /**
   * ************************************* Performs the login with the data from the input fields.
   */
  protected void login() {
    aLoginButton.setEnabled(false);

    String sUserName = bReauthenticate ? Cookies.getCookie(sUserCookie) : aUserField.getText();

    String sPassword = aPasswordField.getText();

    setUserNameCookie(sUserName);

    ServiceRegistry.getCommandService()
        .executeCommand(
            AuthenticatedService.LOGIN,
            createLoginData(sUserName, sPassword),
            new AsyncCallback<DataElementList>() {
              @Override
              public void onFailure(Throwable rCaught) {
                handleLoginFailure(rCaught);
              }

              @Override
              public void onSuccess(DataElementList rResult) {
                handleLoginSuccess(rResult);
              }
            });
  }
Ejemplo n.º 14
0
  /** Parse and store the user credentials to the appropriate fields. */
  private void parseUserCredentials() {
    Configuration conf = (Configuration) GWT.create(Configuration.class);
    String cookie = conf.authCookie();
    String auth = Cookies.getCookie(cookie);
    if (auth == null) {
      authenticateUser();
      // Redundant, but silences warnings about possible auth NPE, below.
      return;
    }
    int sepIndex = auth.indexOf(conf.cookieSeparator());
    if (sepIndex == -1) authenticateUser();
    token = auth.substring(sepIndex + 1);
    final String username = auth.substring(0, sepIndex);
    if (username == null) authenticateUser();

    refreshWebDAVPassword();

    DeferredCommand.addCommand(
        new Command() {

          @Override
          public void execute() {
            fetchUser(username);
          }
        });
  }
Ejemplo n.º 15
0
  public RecordChangeEvent(String val) {
    this.recordValue = val;
    Cookies.setCookie("user", val);

    if (recordValue != "ALL") {
      LogBookConstant.TABLE_PAGE_SIZE = Integer.parseInt(this.recordValue);
    }
  }
  public void start(AcceptsOneWidget container, EventBus eventBus) {

    display.setListener(this);
    display.setLoginErrorMessage("");
    sessionID = Cookies.getCookie("sid");

    container.setWidget(display.asWidget());
  }
Ejemplo n.º 17
0
 /** Clear the cookie and redirect the user to the logout page. */
 void logout() {
   Configuration conf = (Configuration) GWT.create(Configuration.class);
   String cookie = conf.authCookie();
   String domain = Window.Location.getHostName();
   String path = Window.Location.getPath();
   Cookies.setCookie(cookie, "", null, domain, path, false);
   String baseUrl = GWT.getModuleBaseURL();
   String homeUrl = baseUrl.substring(0, baseUrl.indexOf(path));
   Window.Location.assign(homeUrl + conf.logoutUrl());
 }
Ejemplo n.º 18
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.client.cookies.CookiesManager#setAnonCookie(java.lang.Boolean)
  */
 @Override
 public void setAnonCookie(final Boolean userRegister) {
   final Date expires =
       new Date(
           System.currentTimeMillis()
               + (userRegister
                   ? SessionConstants.ANON_SESSION_DURATION_AFTER_REG
                   : SessionConstants.ANON_SESSION_DURATION));
   Cookies.setCookie(ANON, userRegister.toString(), expires, CookieUtils.getDomain(), "/", false);
 }
Ejemplo n.º 19
0
  /** Clear all cookies provided by federation IDP in user's browser. */
  public static void clearFederationCookies() {

    final String SHIBBOLETH_COOKIE_FORMAT = "^_shib.+$";

    // retrieves all the cookies
    Collection<String> cookies = Cookies.getCookieNames();

    // regexp
    RegExp regExp = RegExp.compile(SHIBBOLETH_COOKIE_FORMAT);

    for (String cookie : cookies) {
      // shibboleth cookie?
      MatchResult matcher = regExp.exec(cookie);
      boolean matchFound = (matcher != null); // equivalent to regExp.test(inputStr);
      if (matchFound) {
        // remove it
        Cookies.removeCookieNative(cookie, "/");
      }
    }
  }
Ejemplo n.º 20
0
 /*
  * (non-Javadoc)
  *
  * @see
  * cc.kune.core.client.cookies.CookiesManager#setAuthCookie(java.lang.String)
  */
 @Override
 public void setAuthCookie(final String userHash) {
   // http://code.google.com/p/google-web-toolkit-incubator/wiki/LoginSecurityFAQ
   final Date expires = new Date(System.currentTimeMillis() + SessionConstants.SESSION_DURATION);
   Cookies.setCookie(
       SessionConstants.USERHASH,
       userHash,
       expires,
       CookieUtils.getDomain(),
       "/",
       WindowUtils.isHttps());
   Cookies.setCookie(
       SessionConstants.JSESSIONID,
       userHash,
       expires,
       CookieUtils.getDomain(),
       "/",
       WindowUtils.isHttps());
   Log.info("Received hash: " + userHash, null);
 }
Ejemplo n.º 21
0
 private void selectLastTab() {
   try {
     int tab = Integer.valueOf(Cookies.getCookie("UniTime:CourseFinderCourses"));
     if (tab >= 0
         || tab < iCourseDetailsTabPanel.getTabCount()
             && tab != iCourseDetailsTabPanel.getSelectedTab())
       iCourseDetailsTabPanel.selectTab(tab);
     else iCourseDetailsTabPanel.selectTab(0);
   } catch (Exception e) {
     iCourseDetailsTabPanel.selectTab(0);
   }
 }
Ejemplo n.º 22
0
  /**
   * ************************************* Creates a new data element containing the login data. The
   * default implementation creates a string data element with the user name as it's name and the
   * password as it's value. It also adds the user info created by {@link #createLoginUserInfo()} as
   * a property with the property name {@link AuthenticatedService#LOGIN_USER_INFO} and an existing
   * session ID (from the session cookie) with the property {@link AuthenticatedService#SESSION_ID}.
   *
   * @param sUserName The login user name
   * @param sPassword The login password
   * @return The login data object
   */
  protected StringDataElement createLoginData(String sUserName, String sPassword) {
    String sSessionId = Cookies.getCookie(sSessionCookie);
    StringDataElement aLoginData = new StringDataElement(sUserName, sPassword);

    aLoginData.setProperty(AuthenticatedService.LOGIN_USER_INFO, createLoginUserInfo());

    if (sSessionId != null) {
      aLoginData.setProperty(AuthenticatedService.SESSION_ID, sSessionId);
    }

    return aLoginData;
  }
Ejemplo n.º 23
0
 private void updateSessionCookieExpiration() {
   if (getState().persistentSessionTimeout != null) {
     String cookie = getSessionCookie();
     if (cookie != null) {
       Date date = new Date();
       date = new Date(date.getTime() + getState().persistentSessionTimeout * 1000L);
       Cookies.setCookie(SESSION_COOKIE, cookie, date);
       persistenCookieSet = true;
     }
     // else httpOnly, noop
   }
 }
  /**
   * Creates combobox used to select molecular viewer.
   *
   * @return viewer selector
   */
  private ComboBox<String> createViewerTypeCombobox() {
    ListStore<String> store =
        new ListStore<String>(
            new ModelKeyProvider<String>() {
              @Override
              public String getKey(String item) {
                return item;
              }
            });

    store.add(AppPropertiesManager.CONSTANTS.viewer_local());
    store.add(AppPropertiesManager.CONSTANTS.viewer_jmol());
    store.add(AppPropertiesManager.CONSTANTS.viewer_pse());

    final ComboBox<String> viewerTypeComboBox =
        new ComboBox<String>(
            store,
            new LabelProvider<String>() {
              @Override
              public String getLabel(String item) {
                return item;
              }
            });

    viewerTypeComboBox.setId("viewercombo");
    viewerTypeComboBox.setTriggerAction(TriggerAction.ALL);
    viewerTypeComboBox.setEditable(false);
    viewerTypeComboBox.setWidth(100);

    viewerTypeComboBox.setToolTipConfig(createViewerTypeComboBoxToolTipConfig());

    String viewerCookie = Cookies.getCookie("crkviewer");
    if (viewerCookie != null) {
      viewerTypeComboBox.setValue(viewerCookie);
    } else {
      viewerTypeComboBox.setValue(AppPropertiesManager.CONSTANTS.viewer_jmol());
    }

    ApplicationContext.setSelectedViewer(viewerTypeComboBox.getValue());

    viewerTypeComboBox.addSelectionHandler(
        new SelectionHandler<String>() {
          @Override
          public void onSelection(SelectionEvent<String> event) {
            Cookies.setCookie("crkviewer", event.getSelectedItem());
            ApplicationContext.setSelectedViewer(event.getSelectedItem());
          }
        });

    return viewerTypeComboBox;
  }
Ejemplo n.º 25
0
  private void handleLoginResponse(
      LoginResponse response, String accountName, boolean persistentLogin) {
    if (response.isSuccessful()) {
      Date expireDate = new Date();
      expireDate.setTime(expireDate.getTime() + COOKIE_EXPIRE_TIME);
      Cookies.setCookie(COOKIE_DATABASE, accountName, expireDate);

      if (persistentLogin) {
        Cookies.setCookie(COOKIE_RM_ACCOUNT, accountName, expireDate);
        Cookies.setCookie(COOKIE_RM_TOKEN, response.getRememberMeToken(), expireDate);
      }

      getAccountSettings();
    } else {
      init();
      loginView.setPasswordError(R.lang.msgPasswordIncorrect());
      loginView.selectPasswordField();
      loginView.setEnableLoginButton(true);

      Cookies.removeCookie(COOKIE_RM_ACCOUNT);
      Cookies.removeCookie(COOKIE_RM_TOKEN);
    }
  }
Ejemplo n.º 26
0
 /**
  * Creates the button that can convert to building modeler view.
  *
  * @return the toggle button
  */
 private ToggleButton createBMButton() {
   final ToggleButton bmButton = new ToggleButton();
   bmButton.setToolTip("Building Modeler");
   bmButton.setIcon(icons.bmIcon());
   bmButton.addSelectionListener(
       new SelectionListener<ButtonEvent>() {
         public void componentSelected(ButtonEvent ce) {
           if (!bmButton.isPressed()) {
             bmButton.toggle(true);
           } else {
             modelerContainer.remove(uiDesignerView);
             modelerContainer.add(buildingModelerView);
             Cookies.setCookie(Constants.CURRETN_ROLE, Role.ROLE_MODELER);
             modelerContainer.layout();
           }
         }
       });
   bmButton.setToggleGroup("modeler-switch");
   if (Cookies.getCookie(Constants.CURRETN_ROLE) == null
       || Role.ROLE_MODELER.equals(Cookies.getCookie(Constants.CURRETN_ROLE))) {
     bmButton.toggle(true);
   }
   return bmButton;
 }
Ejemplo n.º 27
0
 /*
  * (non-Javadoc)
  *
  * @see cc.kune.core.client.cookies.CookiesManager#removeAuthCookie()
  */
 @Override
 public void removeAuthCookie() {
   // FIXME: Remove cookie doesn't works in all browsers, know
   // issue:
   // http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/ded86778ee56690/515dc513c7d085eb?lnk=st&q=remove+cookie#515dc513c7d085eb
   // http://code.google.com/p/google-web-toolkit/issues/detail?id=1735&q=removeCookie
   Cookies.removeCookie(SessionConstants.USERHASH);
   Cookies.removeCookie(SessionConstants.JSESSIONID);
   // Workaround:
   Cookies.setCookie(
       SessionConstants.USERHASH,
       null,
       new Date(0),
       CookieUtils.getDomain(),
       "/",
       WindowUtils.isHttps());
   Cookies.setCookie(
       SessionConstants.JSESSIONID,
       null,
       new Date(0),
       CookieUtils.getDomain(),
       "/",
       WindowUtils.isHttps());
 }
Ejemplo n.º 28
0
  @Override
  public void onRequestStarting(RequestStartingEvent e) {
    if (!applicationStarted) {
      applicationStarted = true;
    } else if (persistenCookieSet && getSessionCookie() == null) {
      // Session expired, add fake id -> server side visit will cause
      // normal session expired message instead of disabled cookies
      // warning. See #11420 && VaadinServlet.ensureCookiesEnabled...
      // method
      Cookies.setCookie(SESSION_COOKIE, "invalidateme");
    }

    if (offlineTimeoutMillis >= 0) {
      requestTimeoutTracker.schedule(offlineTimeoutMillis);
    }
  }
 public UploadJob_BeforeAddingOverwrite(int tab) {
   String sessionID = Cookies.getCookie("sid");
   if (sessionID != null) {
     this.tab = tab;
     initWidget(vPanel);
     userCtx = (ClientContext) RPCClientContext.get();
     if (userCtx != null) {
       currentUser = userCtx.getCurrentUser();
       if (currentUser != null) {
         setProjects();
       }
     }
   } else {
     Login login = new Login();
     login.displayLoginBox();
   }
 }
Ejemplo n.º 30
0
  /**
   * ************************************* Handles a successful authentication by invoking the login
   * method {@link LoginHandler#loginSuccessful(DataElementList)}.
   *
   * @param rUserData The user data instance returned by the service
   */
  protected void handleLoginSuccess(DataElementList rUserData) {
    String sSessionID = rUserData.getProperty(AuthenticatedService.SESSION_ID, null);

    if (sSessionID == null) {
      throw new IllegalArgumentException("No Session ID in user data");
    }

    if (aPasswordField != null) {
      aPasswordField.setText("");
      aFailureMessage.setVisible(false);

      aUserField = null;
      aPasswordField = null;
    }

    Cookies.setCookie(sSessionCookie, sSessionID);
    rLoginHandler.loginSuccessful(rUserData);
  }