Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 6189:4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
If a SAML ticket is known for the current user, a HTML form is generated
so tha the Ticket is used to authenticate the Wiki access, otherwise a
plain Link is generated similar to what the UI used before the SSO
links.
Part of flys/issue1265
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Tue, 04 Jun 2013 17:33:55 +0200 |
parents | |
children | cefad5546373 |
comparison
equal
deleted
inserted
replaced
6188:733c32da04b8 | 6189:4365320750bb |
---|---|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.client.client.ui; | |
10 | |
11 import com.smartgwt.client.widgets.grid.CellFormatter; | |
12 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
13 import com.google.gwt.safehtml.shared.SafeHtmlUtils; | |
14 | |
15 import org.dive4elements.river.client.client.FLYS; | |
16 | |
17 public class WikiLinks | |
18 { | |
19 public static String linkHTML(FLYS flys, String url, String text) { | |
20 String saml = flys.getCurrentUser().getSamlXMLBase64(); | |
21 String quotedUrl = SafeHtmlUtils.htmlEscape(url); | |
22 String quotedText = SafeHtmlUtils.htmlEscape(text); | |
23 if (saml != null) { | |
24 return "<form method=\"POST\" target=\"_blank\" action=\"" | |
25 + quotedUrl + "\">" | |
26 + "<input type=\"hidden\" name=\"saml\" value=\"" | |
27 + SafeHtmlUtils.htmlEscape(saml) + "\">" | |
28 + "<input type=\"submit\" value=\"" + quotedText + "\">" | |
29 + "</form>"; | |
30 } | |
31 else { | |
32 return "<a href=\"" + quotedUrl + "\">" + quotedText + "</a>"; | |
33 } | |
34 } | |
35 | |
36 public static CellFormatter cellFormatter(final FLYS flys) { | |
37 return new CellFormatter() { | |
38 public String format(Object value, ListGridRecord record, | |
39 int rowNum, int colNum) { | |
40 return linkHTML(flys, (String)value, record.getLinkText()); | |
41 } | |
42 }; | |
43 } | |
44 } |