aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2015-07-17 22:51:36 +0200
committerDanny van Heumen <danny@dannyvanheumen.nl>2015-07-20 22:29:45 +0200
commitd0e0b7b34e6f7727b0c3226c06f9c65cc5e23278 (patch)
treedf4c7d851a7c91cadc0efc5d8d500e8754833771 /src/net/java/sip/communicator/impl
parentad8c636dcc0bfc7cd88c98a246453a550a9b26d5 (diff)
downloadjitsi-d0e0b7b34e6f7727b0c3226c06f9c65cc5e23278.zip
jitsi-d0e0b7b34e6f7727b0c3226c06f9c65cc5e23278.tar.gz
jitsi-d0e0b7b34e6f7727b0c3226c06f9c65cc5e23278.tar.bz2
Tweaked the Google OAuth 2 approval dialog and added Eclipse classpath modifications.
Diffstat (limited to 'src/net/java/sip/communicator/impl')
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java46
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/UserResponseType.java33
2 files changed, 71 insertions, 8 deletions
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java b/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java
index 8f1a619..dda1041 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java
@@ -189,10 +189,22 @@ public class OAuth2TokenStore
final OAuthApprovalDialog dialog =
new OAuthApprovalDialog(identity);
dialog.setVisible(true);
- final String approvalCode = dialog.getApprovalCode();
- LOGGER.debug("Approval code from user: " + approvalCode);
- token = requestAuthenticationToken(approvalCode);
- saveRefreshToken(token, identity);
+ switch (dialog.getResponse())
+ {
+ case CONFIRMED:
+ // dialog is confirmed, so process entered approval code
+ final String approvalCode = dialog.getApprovalCode();
+ LOGGER.debug("Approval code from user: " + approvalCode);
+ token = requestAuthenticationToken(approvalCode);
+ saveRefreshToken(token, identity);
+ break;
+ case CANCELLED:
+ default:
+ // user one time cancellation
+ // let token remain null, as we do not have new information yet
+ token = null;
+ break;
+ }
}
else
{
@@ -408,6 +420,8 @@ public class OAuth2TokenStore
private final SIPCommTextField code = new SIPCommTextField("");
+ private UserResponseType response = UserResponseType.CANCELLED;
+
public OAuthApprovalDialog(final String identity)
{
this.setModal(true);
@@ -429,16 +443,21 @@ public class OAuth2TokenStore
this.add(this.label, BorderLayout.NORTH);
this.add(new JLabel("Code"), BorderLayout.WEST);
this.add(this.code, BorderLayout.CENTER);
- final JButton button = new JButton("Done");
- button.addActionListener(new ActionListener() {
+ // buttons panel
+ final JPanel buttonPanel = new JPanel(new BorderLayout());
+ final JButton doneButton = new JButton("Done");
+ doneButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
+ OAuthApprovalDialog.this.response =
+ UserResponseType.CONFIRMED;
OAuthApprovalDialog.this.dispose();
}
});
- this.add(button, BorderLayout.SOUTH);
+ buttonPanel.add(doneButton, BorderLayout.EAST);
+ this.add(buttonPanel, BorderLayout.SOUTH);
this.pack();
}
@@ -447,9 +466,20 @@ public class OAuth2TokenStore
*
* @return Returns the approval code.
*/
- public String getApprovalCode() {
+ public String getApprovalCode()
+ {
return this.code.getText();
}
+
+ /**
+ * Is approval dialog confirmed with "Done" button.
+ *
+ * @return Returns whether or not the dialog is confirmed.
+ */
+ public UserResponseType getResponse()
+ {
+ return this.response;
+ }
}
/**
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/UserResponseType.java b/src/net/java/sip/communicator/impl/googlecontacts/UserResponseType.java
new file mode 100644
index 0000000..bf7e928
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/googlecontacts/UserResponseType.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright @ 2015 Atlassian Pty Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.java.sip.communicator.impl.googlecontacts;
+
+/**
+ * Response type for OAuth 2 approval code dialog.
+ *
+ * @author Danny van Heumen
+ */
+public enum UserResponseType
+{
+ /**
+ * Dialog cancelled.
+ */
+ CANCELLED,
+ /**
+ * Dialog confirmed.
+ */
+ CONFIRMED;
+}