Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 6602:244beb29418e
Fix for SAML authentication in FLYSHeader's Info button (#702).
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Thu, 18 Jul 2013 13:25:29 +0200 |
parents | 7106f9b75004 |
children | e562a9a42495 |
rev | line source |
---|---|
6197
cefad5546373
Fix Non-UTF8 Umlaut characters.
Christian Lins <christian.lins@intevation.de>
parents:
6189
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
6189
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 |
6546
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
11 import com.google.gwt.core.client.GWT; |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
12 import com.google.gwt.safehtml.shared.SafeHtmlUtils; |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
13 import com.smartgwt.client.types.FormMethod; |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
14 import com.smartgwt.client.widgets.form.DynamicForm; |
6546
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
15 import com.smartgwt.client.widgets.form.fields.HiddenItem; |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
16 import com.smartgwt.client.widgets.form.fields.LinkItem; |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
17 import com.smartgwt.client.widgets.form.fields.events.ClickEvent; |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
18 import com.smartgwt.client.widgets.form.fields.events.ClickHandler; |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
19 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
20 import org.dive4elements.river.client.client.FLYS; |
6546
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
21 import org.dive4elements.river.client.shared.model.User; |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
22 |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
23 public class WikiLinks |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
24 { |
6602
244beb29418e
Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents:
6546
diff
changeset
|
25 public static String imageLinkForm(FLYS instance, String url, String imageUrl, String formName) { |
6230
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
26 String saml = null; |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
27 if (instance != null && instance.getCurrentUser() != null) { |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
28 saml = instance.getCurrentUser().getSamlXMLBase64(); |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
29 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
30 String quotedUrl = SafeHtmlUtils.htmlEscape(url); |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
31 String quotedImage = SafeHtmlUtils.htmlEscape(imageUrl); |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
32 |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
33 if (saml != null) { |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
34 return "<form method=\"POST\" target=\"_blank\" action=\"" |
6602
244beb29418e
Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents:
6546
diff
changeset
|
35 + quotedUrl + "\" " + "name=\"" + formName + "\">" |
6230
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
36 + "<input type=\"hidden\" name=\"saml\" value=\"" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
37 + SafeHtmlUtils.htmlEscape(saml) + "\">" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
38 + "<input type=\"image\" src=\""+ quotedImage + "\">" |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
39 + "</form>"; |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
40 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
41 else { |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
42 return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>"; |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
43 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
44 } |
954dbb0806f3
Add imageLinkHTML function to WikiLinks class
Andre Heinecke <aheinecke@intevation.de>
parents:
6197
diff
changeset
|
45 |
6546
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
46 public static DynamicForm linkDynamicForm(FLYS flys, String url, String text) { |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
47 User currentUser = flys.getCurrentUser(); |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
48 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
|
49 String quotedText = SafeHtmlUtils.htmlEscape(text); |
6546
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
50 |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
51 if (currentUser != null) { |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
52 String saml = currentUser.getSamlXMLBase64(); |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
53 final DynamicForm form = new DynamicForm(); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
54 form.setMethod(FormMethod.POST); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
55 form.setTarget("_blank"); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
56 form.setAction(quotedUrl); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
57 form.setCanSubmit(true); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
58 LinkItem item = new LinkItem("saml"); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
59 item.setShowTitle(false); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
60 item.setLinkTitle(quotedText); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
61 item.setValue(SafeHtmlUtils.htmlEscape(saml)); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
62 item.addClickHandler(new ClickHandler() { |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
63 @Override |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
64 public void onClick(ClickEvent event) { |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
65 form.submitForm(); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
66 } |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
67 }); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
68 form.setFields(item); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
69 return form; |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
70 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
71 else { |
6272
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
72 DynamicForm form = new DynamicForm(); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
73 LinkItem item = new LinkItem(quotedText); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
74 item.setShowTitle(false); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
75 item.setTarget(quotedUrl); |
24be0cc1c67c
Replaced the 'old school' wiki link buttons with default links.
Raimund Renkert <rrenkert@intevation.de>
parents:
6230
diff
changeset
|
76 return form; |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
77 } |
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
78 } |
6546
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
79 |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
80 public static DynamicForm dynamicForm(FLYS flys, String url) { |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
81 User currentUser = flys.getCurrentUser(); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
82 String quotedUrl = SafeHtmlUtils.htmlEscape(url); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
83 |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
84 if (currentUser != null) { |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
85 String saml = currentUser.getSamlXMLBase64(); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
86 saml = SafeHtmlUtils.htmlEscape(saml); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
87 GWT.log("saml=" + saml); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
88 DynamicForm form = new DynamicForm(); |
6602
244beb29418e
Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents:
6546
diff
changeset
|
89 form.setID("wikiDynamicForm"); |
6546
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
90 form.setMethod(FormMethod.POST); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
91 form.setTarget("_blank"); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
92 form.setAction(quotedUrl); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
93 form.setCanSubmit(true); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
94 HiddenItem item = new HiddenItem("saml"); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
95 item.setDefaultValue(saml); |
6602
244beb29418e
Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents:
6546
diff
changeset
|
96 item.setValue(saml); |
6546
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
97 form.setFields(item); |
6602
244beb29418e
Fix for SAML authentication in FLYSHeader's Info button (#702).
Christian Lins <christian.lins@intevation.de>
parents:
6546
diff
changeset
|
98 //form.setValue("saml", saml); |
6546
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
99 return form; |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
100 } |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
101 else { |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
102 DynamicForm form = new DynamicForm(); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
103 form.setTarget("_blank"); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
104 form.setAction(quotedUrl); |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
105 return form; |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
106 } |
7106f9b75004
Add SAML authentication to Info-Button.
Christian Lins <christian.lins@intevation.de>
parents:
6512
diff
changeset
|
107 } |
6189
4365320750bb
Add helpers for links into the Flys wiki with optional SSO support.
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
108 } |