private void login(String username, String password) { new LoginRestClient(hsConfig).loginWithUser(username, password, deviceName, new SimpleApiCallback<Credentials>() { @Override public void onSuccess(Credentials credentials) { super.onSuccess(credentials); onLogin(credentials); } @Override public void onMatrixError(MatrixError e) { Log.e(TAG, "onLogin MatrixError" + e); } @Override public void onNetworkError(Exception e) { Log.e(TAG, "onLogin Network error" + e); } @Override public void onUnexpectedError(Exception e) { Log.e(TAG, "onLogin Unexpected error" + e); } }); }
@Override public void onRetry() { register(params, callback); } }));
@Override public void onRetry() { getSupportedLoginFlows(callback); } }) {
final HomeServerConnectionConfig hs = createHomeServerConfig(null); final LoginRestClient loginRestClient = new LoginRestClient(hs); loginRestClient.register(registrationParams, new TestApiCallback<Credentials>(lock, false) { @Override public void onMatrixError(MatrixError e) { loginRestClient.register(registrationParams, new TestApiCallback<Credentials>(lock) { @Override public void onSuccess(Credentials credentials) {
/** * Attempt to login with username/password * * @param user the username * @param password the password * @param callback the callback success and failure callback */ public void loginWithUser(final String user, final String password, final ApiCallback<Credentials> callback) { loginWithUser(user, password, null, null, callback); }
mAccountDataRestClient = new AccountDataRestClient(hsConfig); mCryptoRestClient = new CryptoRestClient(hsConfig); mLoginRestClient = new LoginRestClient(hsConfig); mGroupsRestClient = new GroupsRestClient(hsConfig); mMediaScanRestClient = new MediaScanRestClient(hsConfig);
/** * Make a login request. * * @param params custom login params * @param callback the asynchronous callback */ public void login(LoginParams params, final ApiCallback<Credentials> callback) { login(params, callback, "login with a " + params.getClass().getSimpleName() + " object"); }
@Override public void onRetry() { loginWithToken(user, token, txn_id, callback); } }));
/** * Attempt to login with 3pid/password * * @param medium the medium of the 3pid * @param address the address of the 3pid * @param password the password * @param callback the callback success and failure callback */ public void loginWith3Pid(final String medium, final String address, final String password, final ApiCallback<Credentials> callback) { loginWith3Pid(medium, address, password, null, null, callback); }
/** * Attempt to login with phone number/password * * @param phoneNumber the phone number * @param countryCode the ISO country code * @param password the password * @param callback the callback success and failure callback */ public void loginWithPhoneNumber(final String phoneNumber, final String countryCode, final String password, final ApiCallback<Credentials> callback) { loginWithPhoneNumber(phoneNumber, countryCode, password, null, null, callback); }
/** * Ask the home server if the lazy loading of room members is supported. * * @param callback the callback, to be notified if the server actually support the lazy loading. True if supported */ public void canEnableLazyLoading(final ApiCallback<Boolean> callback) { // Check that the server support the lazy loading mLoginRestClient.getVersions(new SimpleApiCallback<Versions>(callback) { @Override public void onSuccess(Versions info) { // Check if we can enable lazyLoading callback.onSuccess(VersionsUtil.supportLazyLoadMembers(info)); } }); }
/** * Attempt to login with username/password * * @param user the username * @param password the password * @param deviceName the device name * @param deviceId the device id, used for e2e encryption * @param callback the callback success and failure callback */ public void loginWithUser(final String user, final String password, final String deviceName, @Nullable final String deviceId, final ApiCallback<Credentials> callback) { final String description = "loginWithUser : " + user; PasswordLoginParams params = new PasswordLoginParams(); params.setUserIdentifier(user, password); params.setDeviceName(deviceName); params.setDeviceId(deviceId); login(params, callback, description); }
/** * Attempt a user/token log in. * * @param user the user name * @param token the token * @param deviceName the device name * @param callback the callback success and failure callback */ public void loginWithToken(final String user, final String token, final String deviceName, final ApiCallback<Credentials> callback) { loginWithToken(user, token, UUID.randomUUID().toString(), deviceName, callback); }
final SessionTestParams sessionTestParams) throws InterruptedException { final HomeServerConnectionConfig hs = createHomeServerConfig(null); LoginRestClient loginRestClient = new LoginRestClient(hs); final Map<String, Object> params = new HashMap<>(); CountDownLatch lock = new CountDownLatch(1); loginRestClient.loginWithUser(userName, password, new TestApiCallback<Credentials>(lock) { @Override public void onSuccess(Credentials credentials) {
/** * Attempt to login with 3pid/password * * @param medium the medium of the 3pid * @param address the address of the 3pid * @param password the password * @param deviceName the device name * @param deviceId the device id, used for e2e encryption * @param callback the callback success and failure callback */ public void loginWith3Pid(final String medium, final String address, final String password, final String deviceName, @Nullable final String deviceId, final ApiCallback<Credentials> callback) { final String description = "loginWith3pid : " + address; PasswordLoginParams params = new PasswordLoginParams(); params.setThirdPartyIdentifier(medium, address, password); params.setDeviceName(deviceName); params.setDeviceId(deviceId); login(params, callback, description); }
/** * Attempt to login with phone number/password * * @param phoneNumber the phone number * @param countryCode the ISO country code * @param password the password * @param deviceName the device name * @param deviceId the device id, used for e2e encryption * @param callback the callback success and failure callback */ public void loginWithPhoneNumber(final String phoneNumber, final String countryCode, final String password, final String deviceName, @Nullable final String deviceId, final ApiCallback<Credentials> callback) { final String description = "loginWithPhoneNumber : " + phoneNumber; PasswordLoginParams params = new PasswordLoginParams(); params.setPhoneIdentifier(phoneNumber, countryCode, password); params.setDeviceName(deviceName); params.setDeviceId(deviceId); login(params, callback, description); }