io.github.eliux.mega.auth.MegaAuthFolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of megacmd4j Show documentation
Show all versions of megacmd4j Show documentation
Java client library that works on top of MEGAcmd to provide access to the services of Mega.nz
The newest version!
package io.github.eliux.mega.auth;
import io.github.eliux.mega.MegaSession;
import io.github.eliux.mega.cmd.MegaCmdLogin;
import io.github.eliux.mega.error.MegaLoginException;
/**
* Authenticates the users into MEGA just for an exported or public folder
*/
public class MegaAuthFolder extends MegaAuth {
private final String folderPath;
public MegaAuthFolder(String folderPath) {
this.folderPath = folderPath;
}
public String getFolderPath() {
return folderPath;
}
@Override
public MegaSession login() throws MegaLoginException {
try {
final MegaCmdLogin megaCmdLogin = new MegaCmdLogin(folderPath);
megaCmdLogin.run();
return new MegaSession(this);
} catch (Throwable cause) {
throw new MegaLoginException(
"You could not access to ".concat(folderPath), cause
);
}
}
}