Mercurial > dive4elements > river
annotate 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 |
rev | line source |
---|---|
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt f�r Gew�sserkunde |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
3 * |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
7 */ |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
8 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
9 package org.dive4elements.river.client.client.ui; |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
10 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
11 import com.smartgwt.client.widgets.grid.CellFormatter; |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
12 import com.smartgwt.client.widgets.grid.ListGridRecord; |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
13 import com.google.gwt.safehtml.shared.SafeHtmlUtils; |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
14 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
15 import org.dive4elements.river.client.client.FLYS; |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
16 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
17 public class WikiLinks |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
18 { |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
19 public static String linkHTML(FLYS flys, String url, String text) { |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
20 String saml = flys.getCurrentUser().getSamlXMLBase64(); |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
21 String quotedUrl = SafeHtmlUtils.htmlEscape(url); |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
22 String quotedText = SafeHtmlUtils.htmlEscape(text); |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
23 if (saml != null) { |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
24 return "<form method=\"POST\" target=\"_blank\" action=\"" |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
25 + quotedUrl + "\">" |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
26 + "<input type=\"hidden\" name=\"saml\" value=\"" |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
27 + SafeHtmlUtils.htmlEscape(saml) + "\">" |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
28 + "<input type=\"submit\" value=\"" + quotedText + "\">" |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
29 + "</form>"; |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
30 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
31 else { |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
32 return "<a href=\"" + quotedUrl + "\">" + quotedText + "</a>"; |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
33 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
34 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
35 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
36 public static CellFormatter cellFormatter(final FLYS flys) { |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
37 return new CellFormatter() { |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
38 public String format(Object value, ListGridRecord record, |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
39 int rowNum, int colNum) { |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
40 return linkHTML(flys, (String)value, record.getLinkText()); |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
41 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
42 }; |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
43 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
44 } |