X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FTrustPage.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FTrustPage.java;h=ef64d627549e96092ac4d4373ca8e4369510cebd;hb=46006ac564cc3efb833fb31ccf5a01cf113927f8;hp=0000000000000000000000000000000000000000;hpb=2b9b72e203fe8b7dae50b79523f0fe95bc42bacb;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/web/TrustPage.java b/src/main/java/net/pterodactylus/sone/web/TrustPage.java
new file mode 100644
index 0000000..ef64d62
--- /dev/null
+++ b/src/main/java/net/pterodactylus/sone/web/TrustPage.java
@@ -0,0 +1,68 @@
+/*
+ * Sone - TrustPage.java - Copyright © 2011 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.pterodactylus.sone.web;
+
+import net.pterodactylus.sone.core.Core;
+import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * Page that lets the user trust another Sone. This will assign a configurable
+ * amount of trust to an identity.
+ *
+ * @see Core#trustSone(Sone, Sone)
+ * @author David âBombeâ Roden
+ */
+public class TrustPage extends SoneTemplatePage {
+
+ /**
+ * Creates a new âtrust Soneâ page.
+ *
+ * @param template
+ * The template to render
+ * @param webInterface
+ * The Sone web interface
+ */
+ public TrustPage(Template template, WebInterface webInterface) {
+ super("trust.html", template, "Page.Trust.Title", webInterface, true);
+ }
+
+ //
+ // SONETEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void processTemplate(Request request, Template template) throws RedirectException {
+ super.processTemplate(request, template);
+ if (request.getMethod() == Method.POST) {
+ String returnPath = request.getHttpRequest().getPartAsStringFailsafe("returnPath", 256);
+ String identity = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
+ Sone currentSone = getCurrentSone(request.getToadletContext());
+ Sone sone = webInterface.getCore().getSone(identity, false);
+ if (sone != null) {
+ webInterface.getCore().trustSone(currentSone, sone);
+ }
+ throw new RedirectException(returnPath);
+ }
+ }
+
+}