Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/javaswift/cloudie/CloudiePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public void onError(CommandException ex) {
loginPanel.setOwner(loginDialog);
loginDialog.getContentPane().add(loginPanel);
loginDialog.setModal(true);
loginDialog.setSize(480, 340);
loginDialog.setSize(480, 380);
loginDialog.setResizable(false);
loginDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
center(loginDialog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public static class Credentials {
public String tenantName;
public String username;
public char[] password;

public String preferredRegion;

@Override
public boolean equals(Object obj) {
if (obj instanceof Credentials) {
Expand Down Expand Up @@ -69,6 +70,7 @@ public AccountConfig toAccountConfig() {
account.setTenantName(tenantName);
account.setUsername(username);
account.setPassword(new String(password));
account.setPreferredRegion(preferredRegion);
return account;
}
}
Expand Down Expand Up @@ -108,6 +110,7 @@ private Credentials toCredentials(Preferences node) {
cr.tenantId = node.get("tenantId", "");
cr.username = node.get("username", "");
cr.password = garble(node.get("password", ""));
cr.preferredRegion = node.get("preferredRegion", "");
return cr;
}

Expand Down Expand Up @@ -146,6 +149,7 @@ private void saveCredentials(Preferences node, Credentials cr) {
node.put("tenantName", cr.tenantName);
node.put("username", cr.username);
node.put("password", String.valueOf(garble(cr.password)));
node.put("preferredRegion", cr.preferredRegion);
}

//
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/javaswift/cloudie/login/LoginPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public interface LoginCallback {
private JTextField tenantName = new JTextField();
private JTextField username = new JTextField();
private JPasswordField password = new JPasswordField();
private JTextField preferredRegion = new JTextField();
private JComboBox authMethod = new JComboBox(AuthenticationMethod.values());
private JLabel warningLabel = new JLabel("Saved Credentials are stored in Plain-Text.", CloudiePanel.getIcon("table_error.png"), JLabel.CENTER);

Expand Down Expand Up @@ -102,6 +103,7 @@ public LoginPanel(LoginCallback callback, CredentialsStore credentialsStore) {
box.add(new LabelComponentPanel("Username", username));
box.add(new LabelComponentPanel("Password", password));
box.add(new LabelComponentPanel("Tenant Id", tenantId));
box.add(new LabelComponentPanel("Preferred Region (Optional)", preferredRegion));
//
outer.add(box);
outer.add(warn);
Expand Down Expand Up @@ -142,6 +144,7 @@ public void actionPerformed(ActionEvent e) {
authMethod.setSelectedIndex(cr.method.ordinal());
username.setText(cr.username);
password.setText(String.valueOf(cr.password));
preferredRegion.setText(cr.preferredRegion);
enableDisable();
}
}
Expand All @@ -156,6 +159,7 @@ private void clearLoginForm() {
tenantName.setText("");
username.setText("");
password.setText("");
preferredRegion.setText("");
authMethod.setSelectedIndex(0);
enableDisable();
}
Expand All @@ -175,6 +179,7 @@ private void refreshCredentials() {
credentials.username = "";
credentials.password = new char[0];
credentials.authUrl = "";
credentials.preferredRegion = "";
model.insertElementAt(credentials, 0);
savedCredentials.setSelectedIndex(0);
}
Expand Down Expand Up @@ -205,6 +210,7 @@ public void changedUpdate(DocumentEvent e) {
tenantName.getDocument().addDocumentListener(lst);
username.getDocument().addDocumentListener(lst);
password.getDocument().addDocumentListener(lst);
preferredRegion.getDocument().addDocumentListener(lst);
}

private void enableDisable() {
Expand Down Expand Up @@ -240,6 +246,7 @@ public void onOk() {
config.setTenantId(tenantId.getText());
config.setTenantName(tenantName.getText());
config.setUsername(username.getText());
config.setPreferredRegion(preferredRegion.getText());
//
callback.doLogin(config);
}
Expand All @@ -256,6 +263,7 @@ public void onSave() {
cr.tenantId = tenantId.getText().trim();
cr.username = username.getText().trim();
cr.password = password.getPassword();
cr.preferredRegion = preferredRegion.getText().trim();
credentialsStore.save(cr);
refreshCredentials();
savedCredentials.setSelectedItem(cr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public LabelComponentPanel(String label, JComponent comp) {
setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
JLabel lbl = new JLabel(label, JLabel.RIGHT);
lbl.setLabelFor(comp);
lbl.setPreferredSize(new Dimension(128, 24));
lbl.setPreferredSize(new Dimension(200, 24));
this.add(lbl, BorderLayout.WEST);
this.add(comp, BorderLayout.CENTER);
}
Expand Down