package net.pterodactylus.sone.web;
+import static java.util.logging.Logger.getLogger;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
import net.pterodactylus.sone.web.page.FreenetRequest;
-import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
import freenet.clients.http.ToadletContext;
+import com.google.common.base.Optional;
+
/**
* The login page manages logging the user in.
*
/** The logger. */
@SuppressWarnings("unused")
- private static final Logger logger = Logging.getLogger(LoginPage.class);
+ private static final Logger logger = getLogger("Sone.Web.Login");
/**
* Creates a new login page.
templateContext.set("sones", localSones);
if (request.getMethod() == Method.POST) {
String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone-id", 100);
- Sone selectedSone = webInterface.getCore().getLocalSone(soneId);
- if (selectedSone != null) {
- setCurrentSone(request.getToadletContext(), selectedSone);
+ Optional<LocalSone> selectedSone = webInterface.getCore().getLocalSone(soneId);
+ if (selectedSone.isPresent()) {
+ setCurrentSone(request.getToadletContext(), selectedSone.get());
String target = request.getHttpRequest().getParam("target");
if ((target == null) || (target.length() == 0)) {
target = "index.html";
*/
@Override
protected String getRedirectTarget(FreenetRequest request) {
- if (getCurrentSone(request.getToadletContext(), false) != null) {
+ if (getCurrentSone(request.getToadletContext(), false).isPresent()) {
return "index.html";
}
return null;
if (webInterface.getCore().getPreferences().isRequireFullAccess() && !toadletContext.isAllowedFullAccess()) {
return false;
}
- return getCurrentSone(toadletContext, false) == null;
+ return !getCurrentSone(toadletContext, false).isPresent();
}
}