Beispiel #1
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);
              }
            });
  }
Beispiel #2
0
 /** ************************************* Sets the focus to the first input field. */
 public void requestFocus() {
   if (aUserField != null && aUserField.getText().length() == 0) {
     aUserField.requestFocus();
   } else {
     aPasswordField.requestFocus();
   }
 }
Beispiel #3
0
  /**
   * ************************************* Adds the components for the user input.
   *
   * @param rBuilder The builder to create the components with
   * @param sUserName The user name preset
   * @param bReauthenticate TRUE for a re-authentication of the current user
   * @return The user input field or NULL if no user input is needed (in the case of
   *     re-authentication)
   */
  protected TextField addUserComponents(
      ContainerBuilder<?> rBuilder, String sUserName, boolean bReauthenticate) {
    TextField aUserInputField = null;

    rBuilder.addLabel(
        StyleData.DEFAULT.setFlags(StyleFlag.HORIZONTAL_ALIGN_RIGHT), "$lblLoginName", null);

    if (bReauthenticate) {
      rBuilder.addLabel(StyleData.DEFAULT, sUserName, null);
    } else {
      aUserInputField = rBuilder.addTextField(StyleData.DEFAULT, "");
      aUserInputField.setText(sUserName);
    }

    return aUserInputField;
  }
Beispiel #4
0
 /**
  * ************************************* Handles events in the login components.
  *
  * @param rEvent The event that occurred
  */
 @Override
 public void handleEvent(EWTEvent rEvent) {
   if (rEvent.getSource() == aUserField) {
     aPasswordField.requestFocus();
   } else // return in password field or login button
   {
     login();
   }
 }
Beispiel #5
0
  /** ************************************* {@inheritDoc} */
  @Override
  protected void addComponents() {
    ContainerBuilder<Panel> aBuilder = createLoginComponentsPanel(AlignedPosition.CENTER);

    String sUserName = Cookies.getCookie(sUserCookie);

    addLoginPanelHeader(aBuilder, AlignedPosition.TOP);

    aUserField = addUserComponents(aBuilder, sUserName, bReauthenticate);
    aPasswordField = addPasswortComponents(aBuilder);
    aFailureMessage = addFailureMessageComponents(aBuilder);
    aLoginButton = addSubmitLoginComponents(aBuilder);

    if (aUserField != null) {
      aUserField.addEventListener(EventType.ACTION, this);
    }

    aPasswordField.addEventListener(EventType.ACTION, this);
    aLoginButton.addEventListener(EventType.ACTION, this);
    aFailureMessage.setVisible(false);
  }
Beispiel #6
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);
  }