Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java @ 6546:7106f9b75004
Add SAML authentication to Info-Button.
Not yet working, the saml POST variable is cleared somewhere before submitting.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 08 Jul 2013 13:59:24 +0200 |
parents | c28f13c80979 |
children | 244beb29418e |
comparison
equal
deleted
inserted
replaced
6544:b24dc0320b75 | 6546:7106f9b75004 |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.client.client.ui; | 9 package org.dive4elements.river.client.client.ui; |
10 | 10 |
11 import com.google.gwt.core.client.GWT; | |
12 import com.google.gwt.safehtml.shared.SafeHtmlUtils; | |
11 import com.smartgwt.client.types.FormMethod; | 13 import com.smartgwt.client.types.FormMethod; |
12 import com.smartgwt.client.widgets.form.DynamicForm; | 14 import com.smartgwt.client.widgets.form.DynamicForm; |
15 import com.smartgwt.client.widgets.form.fields.HiddenItem; | |
13 import com.smartgwt.client.widgets.form.fields.LinkItem; | 16 import com.smartgwt.client.widgets.form.fields.LinkItem; |
14 import com.smartgwt.client.widgets.form.fields.events.ClickEvent; | 17 import com.smartgwt.client.widgets.form.fields.events.ClickEvent; |
15 import com.smartgwt.client.widgets.form.fields.events.ClickHandler; | 18 import com.smartgwt.client.widgets.form.fields.events.ClickHandler; |
16 import com.google.gwt.safehtml.shared.SafeHtmlUtils; | |
17 | 19 |
18 import org.dive4elements.river.client.client.FLYS; | 20 import org.dive4elements.river.client.client.FLYS; |
21 import org.dive4elements.river.client.shared.model.User; | |
19 | 22 |
20 public class WikiLinks | 23 public class WikiLinks |
21 { | 24 { |
22 public static String imageLinkHTML(FLYS instance, String url, String imageUrl) { | 25 public static String imageLinkForm(FLYS instance, String url, String imageUrl) { |
23 String saml = null; | 26 String saml = null; |
24 if (instance != null && instance.getCurrentUser() != null) { | 27 if (instance != null && instance.getCurrentUser() != null) { |
25 saml = instance.getCurrentUser().getSamlXMLBase64(); | 28 saml = instance.getCurrentUser().getSamlXMLBase64(); |
26 } | 29 } |
27 String quotedUrl = SafeHtmlUtils.htmlEscape(url); | 30 String quotedUrl = SafeHtmlUtils.htmlEscape(url); |
38 else { | 41 else { |
39 return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>"; | 42 return "<a href=\"" + quotedUrl + "\"><img src=\"" + quotedImage + "\"></a>"; |
40 } | 43 } |
41 } | 44 } |
42 | 45 |
43 public static DynamicForm linkHTML(FLYS flys, String url, String text) { | 46 public static DynamicForm linkDynamicForm(FLYS flys, String url, String text) { |
44 String saml = flys.getCurrentUser().getSamlXMLBase64(); | 47 User currentUser = flys.getCurrentUser(); |
45 String quotedUrl = SafeHtmlUtils.htmlEscape(url); | 48 String quotedUrl = SafeHtmlUtils.htmlEscape(url); |
46 String quotedText = SafeHtmlUtils.htmlEscape(text); | 49 String quotedText = SafeHtmlUtils.htmlEscape(text); |
47 if (saml != null) { | 50 |
51 if (currentUser != null) { | |
52 String saml = currentUser.getSamlXMLBase64(); | |
48 final DynamicForm form = new DynamicForm(); | 53 final DynamicForm form = new DynamicForm(); |
49 form.setMethod(FormMethod.POST); | 54 form.setMethod(FormMethod.POST); |
50 form.setTarget("_blank"); | 55 form.setTarget("_blank"); |
51 form.setAction(quotedUrl); | 56 form.setAction(quotedUrl); |
52 form.setCanSubmit(true); | 57 form.setCanSubmit(true); |
69 item.setShowTitle(false); | 74 item.setShowTitle(false); |
70 item.setTarget(quotedUrl); | 75 item.setTarget(quotedUrl); |
71 return form; | 76 return form; |
72 } | 77 } |
73 } | 78 } |
79 | |
80 public static DynamicForm dynamicForm(FLYS flys, String url) { | |
81 User currentUser = flys.getCurrentUser(); | |
82 String quotedUrl = SafeHtmlUtils.htmlEscape(url); | |
83 | |
84 if (currentUser != null) { | |
85 String saml = currentUser.getSamlXMLBase64(); | |
86 saml = SafeHtmlUtils.htmlEscape(saml); | |
87 GWT.log("saml=" + saml); | |
88 DynamicForm form = new DynamicForm(); | |
89 form.setMethod(FormMethod.POST); | |
90 form.setTarget("_blank"); | |
91 form.setAction(quotedUrl); | |
92 form.setCanSubmit(true); | |
93 HiddenItem item = new HiddenItem("saml"); | |
94 item.setDefaultValue(saml); | |
95 form.setFields(item); | |
96 form.setValue("saml", saml); | |
97 return form; | |
98 } | |
99 else { | |
100 DynamicForm form = new DynamicForm(); | |
101 form.setTarget("_blank"); | |
102 form.setAction(quotedUrl); | |
103 return form; | |
104 } | |
105 } | |
74 } | 106 } |