com.github.eliux.mega.auth.MegaAuthSessionID 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
package com.github.eliux.mega.auth;
import com.github.eliux.mega.Mega;
import com.github.eliux.mega.MegaSession;
import com.github.eliux.mega.error.MegaException;
import java.util.Optional;
public class MegaAuthSessionID extends MegaAuth {
private final String sessionID;
public MegaAuthSessionID(String sessionID) {
this.sessionID = sessionID;
}
public String getSessionID() {
return sessionID;
}
@Override
public MegaSession login(){
return new MegaSession(this);
}
public static final MegaAuthCredentials createFromEnvVariables(){
String username = Optional.ofNullable(System.getenv(Mega.USERNAME_ENV_VAR))
.orElseThrow(() -> MegaException.nonExistingEnvVariable(
Mega.USERNAME_ENV_VAR
));
String password = Optional.ofNullable(System.getenv(Mega.PASSWORD_ENV_VAR))
.orElseThrow(() -> MegaException.nonExistingEnvVariable(
Mega.PASSWORD_ENV_VAR
));
return new MegaAuthCredentials(username, password);
}
}