[PATCH] Fix for SAML authentication in FLYSHeader's Info button (#702)
Wald Commits
scm-commit at wald.intevation.org
Thu Jul 18 13:25:35 CEST 2013
# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1374146729 -7200
# Node ID 244beb29418e1d88ab654cc2996b0fde2bfde43c
# Parent 5ecc6d4d73f263c7c58c87bd8d33db998706ce60
Fix for SAML authentication in FLYSHeader's Info button (#702).
diff -r 5ecc6d4d73f2 -r 244beb29418e gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java Thu Jul 18 13:16:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java Thu Jul 18 13:25:29 2013 +0200
@@ -12,6 +12,7 @@
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.HTML;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.util.BooleanCallback;
@@ -21,7 +22,6 @@
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.layout.HLayout;
import org.dive4elements.river.client.client.Config;
@@ -136,20 +136,30 @@
info.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- GWT.log("Clicked 'info' button.");
String wikiLink = Config.getInstance().getWikiUrl() + "/Info";
- // Create a dynamic form which contains the SAML session
+ // Create a form which contains the SAML session
// for the user which is currently logged in
- DynamicForm df = WikiLinks.dynamicForm(getFlys(), wikiLink);
- info.addChild(df); // add the form somewhere
- df.submitForm(); // submit the form to go to the wiki
- info.removeChild(df); // and remove the dynamic form
+ String html = WikiLinks.imageLinkForm(
+ getFlys(), wikiLink, "", "wikiLinkForm");
+ HTML htmlObj = new HTML(html);
+ info.addChild(htmlObj);
+ fireWikiLinkSubmit();
+ htmlObj.removeFromParent();
}
});
init();
}
+ /**
+ * Calls the JS submit() function on the dynamically added
+ * wikiLinkForm. This is a workaround for a SmartGWT issue(?) that
+ * clears all form fields when using DynamicForm.submit() or .submitForm().
+ */
+ protected native void fireWikiLinkSubmit() /*-{
+ $doc.wikiLinkForm.submit();
+ }-*/;
+
public void init() {
setStyleName("header");
setWidth100();
@@ -210,9 +220,7 @@
right.addMember(userText);
right.addMember(logout);
right.addMember(language);
- // TEMPORARILY DEACTIVATED: The info button to link in wiki.
- // TODO (issue702)
- //right.addMember(info);
+ right.addMember(info);
right.addMember(bfg);
addMember(left);
diff -r 5ecc6d4d73f2 -r 244beb29418e gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java Thu Jul 18 13:16:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java Thu Jul 18 13:25:29 2013 +0200
@@ -24,7 +24,7 @@
@Override
protected void update() {
- setContents(WikiLinks.imageLinkForm(instance, href, imgUrl));
+ setContents(WikiLinks.imageLinkForm(instance, href, imgUrl, "wikiImgLink" + toString()));
setWidth(width);
setHeight(height);
setOverflow(Overflow.VISIBLE);
diff -r 5ecc6d4d73f2 -r 244beb29418e gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java Thu Jul 18 13:16:33 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java Thu Jul 18 13:25:29 2013 +0200
@@ -22,7 +22,7 @@
public class WikiLinks
{
- public static String imageLinkForm(FLYS instance, String url, String imageUrl) {
+ public static String imageLinkForm(FLYS instance, String url, String imageUrl, String formName) {
String saml = null;
if (instance != null && instance.getCurrentUser() != null) {
saml = instance.getCurrentUser().getSamlXMLBase64();
@@ -32,7 +32,7 @@
if (saml != null) {
return "<form method=\"POST\" target=\"_blank\" action=\""
- + quotedUrl + "\">"
+ + quotedUrl + "\" " + "name=\"" + formName + "\">"
+ "<input type=\"hidden\" name=\"saml\" value=\""
+ SafeHtmlUtils.htmlEscape(saml) + "\">"
+ "<input type=\"image\" src=\""+ quotedImage + "\">"
@@ -86,14 +86,16 @@
saml = SafeHtmlUtils.htmlEscape(saml);
GWT.log("saml=" + saml);
DynamicForm form = new DynamicForm();
+ form.setID("wikiDynamicForm");
form.setMethod(FormMethod.POST);
form.setTarget("_blank");
form.setAction(quotedUrl);
form.setCanSubmit(true);
HiddenItem item = new HiddenItem("saml");
item.setDefaultValue(saml);
+ item.setValue(saml);
form.setFields(item);
- form.setValue("saml", saml);
+ //form.setValue("saml", saml);
return form;
}
else {
More information about the Dive4elements-commits
mailing list