Package org.eclipse.jgit.transport

Examples of org.eclipse.jgit.transport.CredentialItem$Username


        return components.toArray(new JComponent[components.size()]);
    }

    private static void updateCredentialItems(JComponent[] components) {
        for (JComponent component : components) {
            CredentialItem item = (CredentialItem) component.getClientProperty(CRED_ITEM);
            if (item == null) {
                continue;
            }
            if (item instanceof CredentialItem.Username) {
                JTextField field = (JTextField) component;
                ((CredentialItem.Username) item).setValue(field.getText());
                continue;
            }
            if (item instanceof CredentialItem.Password) {
                JPasswordField field = (JPasswordField) component;
                ((CredentialItem.Password) item).setValue(field.getPassword());
                continue;
            }
            if (item instanceof CredentialItem.StringType) {
                if (item.isValueSecure()) {
                    JPasswordField field = (JPasswordField) component;
                    ((CredentialItem.StringType) item).setValue(new String(field.getPassword()));
                    continue;
                }
                JTextField field = (JTextField) component;
View Full Code Here


      throws UnsupportedCredentialItem {
    if (items.length == 0) {
      return true;

    } else if (items.length == 1) {
      final CredentialItem item = items[0];

      if (item instanceof CredentialItem.InformationalMessage) {
        JOptionPane.showMessageDialog(null, item.getPromptText(),
            UIText.get().warning, JOptionPane.INFORMATION_MESSAGE);
        return true;

      } else if (item instanceof CredentialItem.YesNoType) {
        CredentialItem.YesNoType v = (CredentialItem.YesNoType) item;
View Full Code Here

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    final JTextField[] texts = new JTextField[items.length];
    for (int i = 0; i < items.length; i++) {
      CredentialItem item = items[i];

      if (item instanceof CredentialItem.StringType
          || item instanceof CredentialItem.CharArrayType) {
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridwidth = GridBagConstraints.RELATIVE;
        gbc.gridx = 0;
        panel.add(new JLabel(item.getPromptText()), gbc);

        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridwidth = GridBagConstraints.RELATIVE;
        gbc.gridx = 1;
        if (item.isValueSecure())
          texts[i] = new JPasswordField(20);
        else
          texts[i] = new JTextField(20);
        panel.add(texts[i], gbc);
        gbc.gridy++;

      } else if (item instanceof CredentialItem.InformationalMessage) {
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.gridx = 0;
        panel.add(new JLabel(item.getPromptText()), gbc);
        gbc.gridy++;

      } else {
        throw new UnsupportedCredentialItem(uri, item.getPromptText());
      }
    }

    if (JOptionPane.showConfirmDialog(null, panel,
        UIText.get().authenticationRequired,
        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.OK_OPTION)
      return false; // cancel

    for (int i = 0; i < items.length; i++) {
      CredentialItem item = items[i];
      JTextField f = texts[i];

      if (item instanceof CredentialItem.StringType) {
        CredentialItem.StringType v = (CredentialItem.StringType) item;
        if (f instanceof JPasswordField)
View Full Code Here

  @Override
  public boolean get(URIish uri, CredentialItem... items)
      throws UnsupportedCredentialItem {
    boolean ok = true;
    for (int i = 0; i < items.length && ok; i++) {
      CredentialItem item = items[i];

      if (item instanceof CredentialItem.StringType)
        ok = get((CredentialItem.StringType) item);

      else if (item instanceof CredentialItem.CharArrayType)
        ok = get((CredentialItem.CharArrayType) item);

      else if (item instanceof CredentialItem.YesNoType)
        ok = get((CredentialItem.YesNoType) item);

      else if (item instanceof CredentialItem.InformationalMessage)
        ok = get((CredentialItem.InformationalMessage) item);

      else
        throw new UnsupportedCredentialItem(uri, item.getPromptText());
    }
    return ok;
  }
View Full Code Here

      throws UnsupportedCredentialItem {
    if (items.length == 0) {
      return true;

    } else if (items.length == 1) {
      final CredentialItem item = items[0];

      if (item instanceof CredentialItem.InformationalMessage) {
        JOptionPane.showMessageDialog(null, item.getPromptText(),
            UIText.get().warning, JOptionPane.INFORMATION_MESSAGE);
        return true;

      } else if (item instanceof CredentialItem.YesNoType) {
        CredentialItem.YesNoType v = (CredentialItem.YesNoType) item;
View Full Code Here

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    final JTextField[] texts = new JTextField[items.length];
    for (int i = 0; i < items.length; i++) {
      CredentialItem item = items[i];

      if (item instanceof CredentialItem.StringType
          || item instanceof CredentialItem.CharArrayType) {
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridwidth = GridBagConstraints.RELATIVE;
        gbc.gridx = 0;
        panel.add(new JLabel(item.getPromptText()), gbc);

        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridwidth = GridBagConstraints.RELATIVE;
        gbc.gridx = 1;
        if (item.isValueSecure())
          texts[i] = new JPasswordField(20);
        else
          texts[i] = new JTextField(20);
        panel.add(texts[i], gbc);
        gbc.gridy++;

      } else if (item instanceof CredentialItem.InformationalMessage) {
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.gridx = 0;
        panel.add(new JLabel(item.getPromptText()), gbc);
        gbc.gridy++;

      } else {
        throw new UnsupportedCredentialItem(uri, item.getPromptText());
      }
    }

    if (JOptionPane.showConfirmDialog(null, panel,
        UIText.get().authenticationRequired,
        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.OK_OPTION)
      return false; // cancel

    for (int i = 0; i < items.length; i++) {
      CredentialItem item = items[i];
      JTextField f = texts[i];

      if (item instanceof CredentialItem.StringType) {
        CredentialItem.StringType v = (CredentialItem.StringType) item;
        if (f instanceof JPasswordField)
View Full Code Here

   */
  private void updateValues() {
    for (Control control : editingControls) {
      if (control instanceof Text) {
        Text textControl = (Text) control;
        CredentialItem itemToUpdate = (CredentialItem) textControl.getData(KEY_ITEM);
        String value = textControl.getText();
        updateValue(itemToUpdate, value);
      } else if (control instanceof Button) {
        Button checkBoxControl = (Button) control;
        CredentialItem itemToUpdate = (CredentialItem) checkBoxControl.getData(KEY_ITEM);
        boolean value = checkBoxControl.getSelection();
        updateValue(itemToUpdate, value);
      }
    }
  }
View Full Code Here

      public void run() {
        Shell shell = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getShell();

        if (items.length == 1) {
          CredentialItem item = items[0];
          result[0] = getSingleSpecial(shell, uri, item);
        } else {
          result[0] = getMultiSpecial(shell, uri, items);
        }
      }
View Full Code Here

  @Override
  public boolean get(URIish uri, CredentialItem... items)
      throws UnsupportedCredentialItem {
    boolean ok = true;
    for (int i = 0; i < items.length && ok; i++) {
      CredentialItem item = items[i];

      if (item instanceof CredentialItem.StringType)
        ok = get((CredentialItem.StringType) item);

      else if (item instanceof CredentialItem.CharArrayType)
        ok = get((CredentialItem.CharArrayType) item);

      else if (item instanceof CredentialItem.YesNoType)
        ok = get((CredentialItem.YesNoType) item);

      else if (item instanceof CredentialItem.InformationalMessage)
        ok = get((CredentialItem.InformationalMessage) item);

      else
        throw new UnsupportedCredentialItem(uri, item.getPromptText());
    }
    return ok;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.transport.CredentialItem$Username

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.