Exemple #1
0
 /**
  * The method shows a login dialog for a given URI. The user field is taken from the URI if a user
  * is present in the URI. In this case the user is not editable.
  *
  * @param parent
  * @param uri
  * @return credentials, <code>null</code> if the user canceled the dialog.
  */
 public static UserPasswordCredentials login(Shell parent, URIish uri) {
   LoginDialog dialog = new LoginDialog(parent, uri);
   if (dialog.open() == Window.OK) {
     UserPasswordCredentials credentials = dialog.getCredentials();
     if (credentials != null && dialog.getStoreInSecureStore())
       SecureStoreUtils.storeCredentials(credentials, uri);
     return credentials;
   }
   return null;
 }
Exemple #2
0
 /**
  * The method shows a change credentials dialog for a given URI. The user field is taken from the
  * URI if a user is present in the URI. In this case the user is not editable.
  *
  * @param parent
  * @param uri
  * @return credentials, <code>null</code> if the user canceled the dialog.
  */
 public static UserPasswordCredentials changeCredentials(Shell parent, URIish uri) {
   LoginDialog dialog = new LoginDialog(parent, uri);
   dialog.setChangeCredentials(true);
   UserPasswordCredentials oldCredentials = SecureStoreUtils.getCredentials(uri);
   if (oldCredentials != null) dialog.setOldUser(oldCredentials.getUser());
   if (dialog.open() == Window.OK) {
     UserPasswordCredentials credentials = dialog.getCredentials();
     if (credentials != null) SecureStoreUtils.storeCredentials(credentials, uri);
     return credentials;
   }
   return null;
 }
 private void showLoginDialog() {
   String message = "Please sign in with your username and password:"******"Login", message, "john");
   int returnCode = loginDialog.open();
   String resultText = "Result: " + getReturnCodeText(returnCode);
   if (returnCode == Window.OK) {
     String username = loginDialog.getUsername();
     String password = loginDialog.getPassword();
     String pwInfo = password == null ? "n/a" : password.length() + " chars";
     resultText += ", user: "******", password: " + pwInfo;
   }
   loginDlgResLabel.setText(resultText);
   loginDlgResLabel.pack();
 }