mirror of
https://github.com/Rogiel/httpchannel
synced 2025-12-06 07:32:50 +00:00
Implement AccountDetails object that provides account information
This commit is contained in:
@@ -28,10 +28,13 @@ import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
import com.rogiel.httpchannel.service.AbstractAccountDetails;
|
||||
import com.rogiel.httpchannel.service.AbstractAuthenticator;
|
||||
import com.rogiel.httpchannel.service.AbstractHttpDownloader;
|
||||
import com.rogiel.httpchannel.service.AbstractHttpService;
|
||||
import com.rogiel.httpchannel.service.AbstractUploader;
|
||||
import com.rogiel.httpchannel.service.AccountDetails;
|
||||
import com.rogiel.httpchannel.service.AccountDetails.PremiumAccountDetails;
|
||||
import com.rogiel.httpchannel.service.AuthenticationService;
|
||||
import com.rogiel.httpchannel.service.Authenticator;
|
||||
import com.rogiel.httpchannel.service.AuthenticatorCapability;
|
||||
@@ -198,7 +201,12 @@ public class MegaUploadService extends AbstractHttpService implements Service,
|
||||
|
||||
@Override
|
||||
public CapabilityMatrix<AuthenticatorCapability> getAuthenticationCapability() {
|
||||
return new CapabilityMatrix<AuthenticatorCapability>();
|
||||
return new CapabilityMatrix<AuthenticatorCapability>(AuthenticatorCapability.ACCOUNT_DETAILS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountDetails getAccountDetails() {
|
||||
return account;
|
||||
}
|
||||
|
||||
protected class UploaderImpl extends
|
||||
@@ -312,7 +320,7 @@ public class MegaUploadService extends AbstractHttpService implements Service,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void login() throws IOException {
|
||||
public AccountDetails login() throws IOException {
|
||||
logger.debug("Starting login to megaupload.com");
|
||||
final HTMLPage page = post("http://www.megaupload.com/?c=login")
|
||||
.parameter("login", true)
|
||||
@@ -322,7 +330,7 @@ public class MegaUploadService extends AbstractHttpService implements Service,
|
||||
String username = page.findScript(LOGIN_USERNAME_PATTERN, 1);
|
||||
if (username == null)
|
||||
throw new AuthenticationInvalidCredentialException();
|
||||
serviceMode = ServiceMode.NON_PREMIUM;
|
||||
return (account = new AccountDetailsImpl(credential.getUsername()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -333,6 +341,23 @@ public class MegaUploadService extends AbstractHttpService implements Service,
|
||||
}
|
||||
}
|
||||
|
||||
private class AccountDetailsImpl extends AbstractAccountDetails implements
|
||||
PremiumAccountDetails {
|
||||
/**
|
||||
* @param username
|
||||
* the username
|
||||
*/
|
||||
public AccountDetailsImpl(String username) {
|
||||
super(MegaUploadService.this, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPremium() {
|
||||
// TODO implement this
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getClass().getSimpleName() + " " + getMajorVersion() + "."
|
||||
|
||||
Reference in New Issue
Block a user