aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2015-07-20 21:27:51 +0200
committerDanny van Heumen <danny@dannyvanheumen.nl>2015-07-20 22:29:45 +0200
commitaa5eeee24a5a546bd1f5b83696a231bfe71fc0f9 (patch)
tree94d8dd2a1a5a54173fc666654cfe9f3d7c1f4868
parentd0e0b7b34e6f7727b0c3226c06f9c65cc5e23278 (diff)
downloadjitsi-aa5eeee24a5a546bd1f5b83696a231bfe71fc0f9.zip
jitsi-aa5eeee24a5a546bd1f5b83696a231bfe71fc0f9.tar.gz
jitsi-aa5eeee24a5a546bd1f5b83696a231bfe71fc0f9.tar.bz2
Removed notion of a 'password' from Google Contacts implementation.
Removed all references to using/requesting/storing a password, since client login authentication is now deprecated and there is no reason to believe that this is coming back any time soon. + a bit of fine-tuning in exception handling
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java9
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java47
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java23
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java11
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java10
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java39
-rw-r--r--src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java14
-rw-r--r--src/net/java/sip/communicator/service/googlecontacts/GoogleContactsService.java12
8 files changed, 38 insertions, 127 deletions
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
index a0ffdcd..c993339 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
@@ -273,14 +273,12 @@ public class GoogleContactsActivator implements BundleActivator
className = className.substring(0, className.lastIndexOf('.'));
String acc = ProtocolProviderFactory.findAccountPrefix(
bundleContext, provider.getAccountID(), className);
- String password = getCredentialsService().loadPassword(acc);
if(configService.getBoolean(acc + ".GOOGLE_CONTACTS_ENABLED",
true))
{
enableContactSource(
provider.getAccountID().getAccountAddress(),
- password,
provider.getProtocolDisplayName().equals(
"Google Talk"));
}
@@ -341,16 +339,15 @@ public class GoogleContactsActivator implements BundleActivator
* <tt>GoogleContactsConnection</tt>.
*
* @param login login
- * @param password password
* @param googleTalk if the provider service is GoogleTalk
* @return a <tt>GoogleContactsSourceService</tt> instance
*/
public static GoogleContactsSourceService enableContactSource(
- String login, String password,
+ String login,
boolean googleTalk)
{
- GoogleContactsSourceService css = new GoogleContactsSourceService(
- login, password);
+ GoogleContactsSourceService css =
+ new GoogleContactsSourceService(login);
ServiceRegistration<?> cssServiceRegistration = null;
css.setGoogleTalk(googleTalk);
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java
index 52d03da..350d638 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java
@@ -43,11 +43,6 @@ public class GoogleContactsConnectionImpl
private String login = null;
/**
- * Password.
- */
- private String password = null;
-
- /**
* If the connection is enabled.
*/
private boolean enabled = false;
@@ -67,12 +62,10 @@ public class GoogleContactsConnectionImpl
* Constructor.
*
* @param login the login to connect to the service
- * @param password the password to connect to the service
*/
- public GoogleContactsConnectionImpl(String login, String password)
+ public GoogleContactsConnectionImpl(String login)
{
this.login = login;
- this.password = password;
googleService.useSsl();
}
@@ -97,16 +90,6 @@ public class GoogleContactsConnectionImpl
}
/**
- * get password.
- *
- * @return password to connect to the service
- */
- public String getPassword()
- {
- return password;
- }
-
- /**
* Set login.
*
* @param login login to connect to the service
@@ -117,16 +100,6 @@ public class GoogleContactsConnectionImpl
}
/**
- * Set password.
- *
- * @param password password to connect to the service
- */
- public void setPassword(String password)
- {
- this.password = password;
- }
-
- /**
* Initialize connection.
*
* @return connection status
@@ -169,12 +142,22 @@ public class GoogleContactsConnectionImpl
{
return this.googleService.query(query, ContactFeed.class);
}
+ catch (NullPointerException e)
+ {
+ // Don't include a stack trace, since this is will happen at start
+ // of Jitsi, as we do not have a valid access token available yet.
+ logger.info("Executing query failed with NPE. "
+ + "Refreshing access token and trying again.");
+ // Maybe we should request an access token immediately after loading
+ // the refresh token from the credentials store?
+ this.store.refresh();
+ }
catch (Exception e)
{
- // FIXME if possible narrow down the exceptions on which to
- // refresh token
- logger.info("Failed to execute query. Going to refresh token"
- + " and try again.", e);
+ // Catch all and retry with refreshed token. We may need to let this
+ // case go through.
+ logger.warn("Query failed with unexpected exception. Going to try "
+ + "refreshing token anyways ...", e);
this.store.refresh();
}
try
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java
index adcd198..8804bfc 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java
@@ -12,7 +12,6 @@ import java.util.*;
import java.util.regex.*;
import net.java.sip.communicator.impl.googlecontacts.configform.*;
-import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.googlecontacts.*;
import net.java.sip.communicator.util.*;
@@ -103,8 +102,6 @@ public class GoogleContactsServiceImpl
{
ConfigurationService configService =
GoogleContactsActivator.getConfigService();
- CredentialsStorageService credentialsService =
- GoogleContactsActivator.getCredentialsService();
List<String> list = configService.getPropertyNamesByPrefix(
CONFIGURATION_PATH, true);
@@ -124,10 +121,8 @@ public class GoogleContactsServiceImpl
if(prefix == null)
prefix = "";
- String password = credentialsService.loadPassword(path);
-
GoogleContactsConnectionImpl cnx = (GoogleContactsConnectionImpl)
- getConnection(login, password);
+ getConnection(login);
cnx.setEnabled(enabled);
cnx.setPrefix(prefix);
@@ -188,9 +183,6 @@ public class GoogleContactsServiceImpl
ConfigurationService configService =
GoogleContactsActivator.getConfigService();
- CredentialsStorageService credentialsService =
- GoogleContactsActivator.getCredentialsService();
-
String login = cnx.getLogin();
String path = CONFIGURATION_PATH + ".acc" + Math.abs(login.hashCode());
@@ -207,8 +199,6 @@ public class GoogleContactsServiceImpl
configService.setProperty(
path + ".prefix",
((GoogleContactsConnectionImpl)cnx).getPrefix());
-
- credentialsService.storePassword(path, cnx.getPassword());
}
/**
@@ -411,15 +401,13 @@ public class GoogleContactsServiceImpl
* Get a <tt>GoogleContactsConnection</tt>.
*
* @param login login to connect to the service
- * @param password password to connect to the service
* @return <tt>GoogleContactsConnection</tt>.
*/
- public GoogleContactsConnection getConnection(String login,
- String password)
+ public GoogleContactsConnection getConnection(String login)
{
try
{
- return new GoogleContactsConnectionImpl(login, password);
+ return new GoogleContactsConnectionImpl(login);
}
catch(Exception e)
{
@@ -447,11 +435,10 @@ public class GoogleContactsServiceImpl
* <tt>GoogleContactsConnection</tt>.
*
* @param login login
- * @param password password
*/
- public void addContactSource(String login, String password)
+ public void addContactSource(String login)
{
- GoogleContactsActivator.enableContactSource(login, password, false);
+ GoogleContactsActivator.enableContactSource(login, false);
}
/**
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
index 6207676..c4ca332 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
@@ -40,11 +40,6 @@ public class GoogleContactsSourceService
private final String login;
/**
- * Password.
- */
- private final String password;
-
- /**
* The prefix for all google contact phone numbers.
*/
private String phoneNumberprefix;
@@ -71,11 +66,10 @@ public class GoogleContactsSourceService
* @param login login
* @param password password
*/
- public GoogleContactsSourceService(String login, String password)
+ public GoogleContactsSourceService(String login)
{
super();
this.login = login;
- this.password = password;
}
/**
@@ -88,7 +82,6 @@ public class GoogleContactsSourceService
super();
this.cnx = cnx;
this.login = cnx.getLogin();
- this.password = cnx.getPassword();
this.phoneNumberprefix = cnx.getPrefix();
}
@@ -219,7 +212,7 @@ public class GoogleContactsSourceService
{
if(cnx == null)
{
- cnx = new GoogleContactsConnectionImpl(login, password);
+ cnx = new GoogleContactsConnectionImpl(login);
if(cnx.connect() ==
GoogleContactsConnection.ConnectionStatus.
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java b/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java
index dda1041..9a503f4 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/OAuth2TokenStore.java
@@ -208,7 +208,7 @@ public class OAuth2TokenStore
}
else
{
- token = new TokenData("TOKEN_NOT_AVAILABLE", refreshToken, 0);
+ token = new TokenData(null, refreshToken, 0);
}
store.set(createCredential(store, token));
}
@@ -508,16 +508,12 @@ public class OAuth2TokenStore
* Constructor for TokenData container.
*
* @param accessToken the access token
- * @param refreshToken the refresh token
- * @param expirationTime the expiration time
+ * @param refreshToken the refresh token (cannot be null)
+ * @param expirationTime the expiration time (must be >= 0)
*/
private TokenData(final String accessToken, final String refreshToken,
final long expirationTime)
{
- if (accessToken == null)
- {
- throw new NullPointerException("access token cannot be null");
- }
this.accessToken = accessToken;
if (refreshToken == null)
{
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java b/src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java
index 9b3d083..7dd5799 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java
@@ -36,11 +36,6 @@ public class AccountSettingsForm
private JTextField nameField;
/**
- * the component holding the password
- */
- private JPasswordField passwordField;
-
- /**
* The prefix field.
*/
private JTextField prefixField;
@@ -133,29 +128,6 @@ public class AccountSettingsForm
c.anchor = GridBagConstraints.LINE_START;
basePanel.add(nameExampleLabel, c);
- JLabel passwordLabel = new JLabel(
- Resources.getString("impl.googlecontacts.PASSWORD"));
- this.passwordField = new JPasswordField();
- nameLabel.setLabelFor(passwordField);
- c.gridx = 0;
- c.gridy = 2;
- c.weightx = 0;
- c.weighty = 0;
- c.gridwidth = 1;
- c.insets = new Insets(2, 50, 0, 5);
- c.fill = GridBagConstraints.HORIZONTAL;
- c.anchor = GridBagConstraints.LINE_START;
- basePanel.add(passwordLabel, c);
- c.gridx = 1;
- c.gridy = 2;
- c.weightx = 1;
- c.weighty = 0;
- c.gridwidth = GridBagConstraints.REMAINDER;
- c.insets = new Insets(2, 5, 0, 50);
- c.fill = GridBagConstraints.HORIZONTAL;
- c.anchor = GridBagConstraints.LINE_END;
- basePanel.add(passwordField, c);
-
JLabel prefixLabel = new JLabel(
Resources.getString("service.gui.PREFIX"));
this.prefixField = new JTextField();
@@ -184,7 +156,6 @@ public class AccountSettingsForm
/* listeners */
this.nameField.addActionListener(this);
- this.passwordField.addActionListener(this);
this.saveBtn.addActionListener(this);
this.cancelBtn.addActionListener(this);
@@ -207,14 +178,12 @@ public class AccountSettingsForm
if(cnx != null)
{
this.nameField.setText(cnx.getLogin());
- this.passwordField.setText(cnx.getPassword());
this.prefixField.setText(cnx.getPrefix());
this.cnx = (GoogleContactsConnectionImpl) cnx;
}
else
{
this.nameField.setText("");
- this.passwordField.setText("");
this.cnx = null;
}
}
@@ -231,19 +200,17 @@ public class AccountSettingsForm
if(src == saveBtn)
{
String login = nameField.getText();
- String password = new String(passwordField.getPassword());
String prefix = prefixField.getText();
if(cnx == null)
{
- cnx = (GoogleContactsConnectionImpl) GoogleContactsActivator
- .getGoogleContactsService()
- .getConnection(login, password);
+ cnx =
+ (GoogleContactsConnectionImpl) GoogleContactsActivator
+ .getGoogleContactsService().getConnection(login);
}
else
{
cnx.setLogin(login);
- cnx.setPassword(password);
}
cnx.setPrefix(prefix);
diff --git a/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java b/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java
index bc618e8..f8a0788 100644
--- a/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java
+++ b/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java
@@ -43,13 +43,6 @@ public interface GoogleContactsConnection
public String getLogin();
/**
- * Get password.
- *
- * @return password to connect to the service
- */
- public String getPassword();
-
- /**
* Set login.
*
* @param login login to connect to the service
@@ -57,13 +50,6 @@ public interface GoogleContactsConnection
public void setLogin(String login);
/**
- * Set password.
- *
- * @param password password to connect to the service
- */
- public void setPassword(String password);
-
- /**
* Initialize connection.
*
* @return connection status
diff --git a/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsService.java b/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsService.java
index cee0588..4e5d352 100644
--- a/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsService.java
+++ b/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsService.java
@@ -31,12 +31,15 @@ public interface GoogleContactsService
/**
* Get a <tt>GoogleContactsConnection</tt>.
*
+ * Get a connection to Google Contacts. Only the login name may be provided.
+ * Passwords are not supported anymore. Authorization is acquired by
+ * requesting the user to go to Google and acquire an OAuth 2 approval for
+ * Jitsi.
+ *
* @param login login to connect to the service
- * @param password password to connect to the service
* @return <tt>GoogleContactsConnection</tt>.
*/
- public GoogleContactsConnection getConnection(String login,
- String password);
+ public GoogleContactsConnection getConnection(String login);
/**
* Get the full contacts list.
@@ -50,9 +53,8 @@ public interface GoogleContactsService
* <tt>GoogleContactsConnection</tt>.
*
* @param login login
- * @param password password
*/
- public void addContactSource(String login, String password);
+ public void addContactSource(String login);
/**
* Add a contact source service with the specified