Revert "Use ha1 instead of plain text passwords by default but still use plain text password for legacy support"

This reverts commit 49c3e1f02c.

Conflicts:
	res/values/non_localizable_custom.xml
	src/org/linphone/LinphonePreferences.java
This commit is contained in:
Simon Morlat 2014-08-12 09:48:46 +02:00
parent 625fc50529
commit d5b71ff05b
5 changed files with 6 additions and 64 deletions

View file

@ -70,7 +70,6 @@
<bool name="auto_answer_calls">false</bool>
<bool name="intercept_outgoing_gsm_calls">false</bool>
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool>
<bool name="store_ha1_passwords">true</bool>
<bool name="use_linphonecore_ringing">false</bool>
<!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->

View file

@ -82,13 +82,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
OnPreferenceChangeListener passwordChangedListener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (getResources().getBoolean(R.bool.store_ha1_passwords)
&& mPrefs.getAccountPassword(n) == null) {
String ha1 = LinphoneUtils.md5Hash(mPrefs.getAccountUsername(n), newValue.toString(), mPrefs.getAccountDomain(n));
mPrefs.setAccountHa1(n, ha1);
} else {
mPrefs.setAccountPassword(n, newValue.toString());
}
mPrefs.setAccountPassword(n, newValue.toString());
return true;
}
};
@ -220,7 +214,7 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
userid.setSummary(userid.getText());
EditTextPreference password = (EditTextPreference) account.getPreference(2);
password.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
password.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
password.setText(mPrefs.getAccountPassword(n));
password.setOnPreferenceChangeListener(passwordChangedListener);

View file

@ -166,7 +166,6 @@ public class LinphonePreferences {
private String tempDisplayName;
private String tempUserId;
private String tempPassword;
private String tempHa1;
private String tempDomain;
private String tempProxy;
private boolean tempOutboundProxy;
@ -206,11 +205,6 @@ public class LinphonePreferences {
return this;
}
public AccountBuilder setHa1(String ha1) {
tempHa1 = ha1;
return this;
}
public AccountBuilder setDomain(String domain) {
tempDomain = domain;
return this;
@ -323,7 +317,7 @@ public class LinphonePreferences {
prxCfg.setQualityReportingInterval(tempQualityReportingInterval);
prxCfg.setRealm("sip.linphone.org");
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, tempHa1, null, tempDomain);
LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(tempUsername, tempUserId, tempPassword, null, null, tempDomain);
lc.addProxyConfig(prxCfg);
lc.addAuthInfo(authInfo);
@ -474,18 +468,6 @@ public class LinphonePreferences {
LinphoneAuthInfo authInfo = getAuthInfo(n);
return authInfo == null ? null : authInfo.getPassword();
}
public void setAccountHa1(int n, String ha1) {
LinphoneAuthInfo info = getClonedAuthInfo(n);
info.setHa1(ha1);
saveAuthInfo(info);
}
public String getAccountHa1(int n) {
LinphoneAuthInfo authInfo = getAuthInfo(n);
return authInfo == null ? null : authInfo.getHa1();
}
public void setAccountDomain(int n, String domain) {
String identity = "sip:" + getAccountUsername(n) + "@" + domain;

View file

@ -23,14 +23,13 @@ import static android.view.View.VISIBLE;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -404,32 +403,5 @@ public final class LinphoneUtils {
e.printStackTrace();
}
}
public static String md5Hash(String username, String password, String domain) {
String passwordToHash = username + ":" + domain + ":" + password;
byte messageDigest[] = null;
try {
MessageDigest digest;
digest = java.security.MessageDigest.getInstance("MD5");
digest.update(passwordToHash.getBytes());
messageDigest = digest.digest();
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < messageDigest.length; i++) {
String h = Integer.toHexString(0xFF & messageDigest[i]);
while (h.length() < 2) {
h = "0" + h;
}
hexString.append(h);
}
String hash = hexString.toString();
return hash;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
}
}

View file

@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.LinphoneUtils;
import org.linphone.LinphonePreferences.AccountBuilder;
import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedListener;
import org.linphone.R;
@ -293,12 +292,8 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
boolean useLinphoneDotOrgCustomPorts = getResources().getBoolean(R.bool.use_linphone_server_ports);
AccountBuilder builder = new AccountBuilder(LinphoneManager.getLc())
.setUsername(username)
.setDomain(domain);
if (getResources().getBoolean(R.bool.store_ha1_passwords)) {
builder = builder.setHa1(LinphoneUtils.md5Hash(username, password, domain));
} else {
builder = builder.setPassword(password);
}
.setDomain(domain)
.setPassword(password);
if (isMainAccountLinphoneDotOrg && useLinphoneDotOrgCustomPorts) {
if (getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {