예제 #1
0
  /**
   * Try to login a User by its user name and its password.
   *
   * @param username Name of the User
   * @param password Password of the user
   * @param session The Session object used by the gwt session management.
   * @return The User object which is connected to the user name and password combination
   * @throws LoginException If there is no account with the user name and password combination.
   */
  public User login(final String username, final String password, final HttpSession session)
      throws LoginException {
    for (final Account account : this.manager.getAccounts()) {
      if (account.getUser().getName().equals(username) && account.getPassword().equals(password)) {

        if (account.getUser().getPerson() != null && !account.getUser().getPerson().isDeleted()) {
          this.sessionManager.newSession(account.getUser(), session);
          return account.getUser();
        } else {
          throw new LoginException(
              "Account ist ungültig! Die Person zum Account existiert nicht mehr!");
        }
      }
    }

    throw new LoginException("Kombination von Name und Passwort existiert nicht!");
  }
예제 #2
0
 /**
  * getter of all users the accountManager manages.
  *
  * @return all current users
  */
 public List<User> getUsers() {
   final List<Account> accounts = this.manager.getAccounts();
   final List<User> result = new ArrayList<User>();
   for (final Account account : accounts) {
     result.add(account.getUser());
   }
   return result;
 }
예제 #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      id = extras.getString("id");
    }

    acc = new AccDAO(this).getAcc(Long.valueOf(id));
    user = (TextView) findViewById(R.id.textView2);
    user.setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, 26);
    user.setText(acc.getUser());
    pass = (TextView) findViewById(R.id.textView4);
    pass.setText(acc.getPass());
  }
예제 #4
0
  @Override
  public void start(Stage stage) throws Exception {
    primaryStage = stage;
    setUserAgentStylesheet(STYLESHEET_MODENA);

    config = initDiContainer();

    SceneAntialiasing aa = SceneAntialiasing.BALANCED;
    primaryStage
        .getIcons()
        .setAll(
            new javafx.scene.image.Image(getClass().getResourceAsStream("/logo-invert_small.png")));
    Scene scene;

    Platform.setImplicitExit(false);
    primaryStage.setTitle(TITLE);
    scene = new Scene(new LoginView().getView(), 370, 550, true, aa);
    primaryStage.setScene(scene);

    config.addObserver(
        (o, arg) -> {
          Platform.runLater(
              () -> {
                if (arg instanceof Account) {
                  try {
                    ClientConfiguration configuration =
                        (ClientConfiguration) customProperties.get("clientConfiguration");
                    Account acc = (Account) arg;
                    AccountingServer server =
                        new AccountingServer(
                            new URI(acc.getProvider()), acc.getUser(), acc.getAuth());
                    AccountingHTTP accountingHTTP =
                        new AccountingHTTP(server, new AccountingProfile());

                    BoxVolumeFactory factory =
                        new BlockBoxVolumeFactory(
                            configuration.getDeviceId().getBytes(),
                            accountingHTTP,
                            identityRepository);
                    boxVolumeFactory = new CachedBoxVolumeFactory(factory);
                    customProperties.put("boxVolumeFactory", boxVolumeFactory);
                    sharingService = new BlockSharingService(dropMessageRepository, dropConnector);
                    customProperties.put("sharingService", sharingService);

                    new Thread(getSyncDaemon(config)).start();
                    new Thread(getDropDaemon(config)).start();
                    view = new LayoutView();
                    Parent view = this.view.getView();
                    Scene layoutScene = new Scene(view, 800, 600, true, aa);
                    Platform.runLater(() -> primaryStage.setScene(layoutScene));

                    if (config.getSelectedIdentity() != null) {
                      addShareMessageRenderer(config.getSelectedIdentity());
                    }
                  } catch (Exception e) {
                    logger.error("failed to init background services: " + e.getMessage(), e);
                    // TODO to something with the fault
                  }
                } else if (arg instanceof Identity) {
                  addShareMessageRenderer((Identity) arg);
                }
              });
        });

    dropMessageRepository.addObserver(new ShareNotificationHandler(config));

    setTrayIcon(primaryStage);

    Runtime.getRuntime()
        .addShutdownHook(
            new Thread() {
              public void run() {
                Platform.exit();
              }
            });
    primaryStage.show();
  }