예제 #1
0
파일: Header.java 프로젝트: Vugario/FitWare
  /** Update the user info */
  public final void updateUserInfo() {

    // Check if a user is logged in
    User user = Session.get().getLoggedInUser();

    if (user == null) {
      // There is no logged in user, so hide the user info
      this.showUserInfo(false);
    } else {
      // Update the user info to the currently logged in user
      this.jLabelUsername.setText(user.getFullName());
      // And show the user info
      this.showUserInfo(true);
    }
  }
  private static void startSession() {
    Session session = Session.getInstance(true);

    Pair<BigInteger, BigInteger> privateKeys = session.getPrivateKey();

    System.out.println("");
    System.out.println("Private key x: " + privateKeys.getFirst());
    System.out.println("Private key y: " + privateKeys.getSecond());
    System.out.println("");

    System.out.println("Please introduce message to sign:");
    String text = null;
    while (text == null) {
      try {
        text = (new BufferedReader(new InputStreamReader(System.in))).readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    Pair<BigInteger, BigInteger> signature =
        DSA.sign(
            true,
            text,
            session.getGlobalKeyG(),
            session.getGlobalKeyP(),
            session.getGlobalKeyQ(),
            privateKeys.getFirst());
    System.out.println(
        "Signature (r,s): (" + signature.getFirst() + ", " + signature.getSecond() + ")");
    System.out.println("");
    System.out.println("Do you want to verify a message?");
    System.out.println("  1.Yes (y)");
    System.out.println("  2.No (press enter)");
    String alg = null;
    try {
      alg = (new BufferedReader(new InputStreamReader(System.in))).readLine();
    } catch (IOException e) {
      e.printStackTrace();
    }

    switch (alg) {
      case "y":
        verifyMessage();
        break;
      default:
        System.out.println("Bye!");
        System.exit(1);
        break;
    }
  }
예제 #3
0
파일: Header.java 프로젝트: Vugario/FitWare
 private void jLabelLogoutMouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jLabelLogoutMouseClicked
   Session.get().logOut();
   Application.getInstance().showPanel(new view.Login());
 } // GEN-LAST:event_jLabelLogoutMouseClicked