[PATCH 1 of 2] Add SAML authentication to Info-Button
Wald Commits
scm-commit at wald.intevation.org
Mon Jul 8 14:51:10 CEST 2013
# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1373284764 -7200
# Node ID 7106f9b75004dd489329f78002aa52cb059e2e2a
# Parent b24dc0320b750f068fb0007d103924769ff3ce25
Add SAML authentication to Info-Button.
Not yet working, the saml POST variable is cleared somewhere before submitting.
diff -r b24dc0320b75 -r 7106f9b75004 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 Mon Jul 08 11:41:10 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSHeader.java Mon Jul 08 13:59:24 2013 +0200
@@ -21,6 +21,7 @@
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;
@@ -137,7 +138,13 @@
public void onClick(ClickEvent event) {
GWT.log("Clicked 'info' button.");
String wikiLink = Config.getInstance().getWikiUrl() + "/Info";
- Window.open(wikiLink, "_blank", null);
+
+ // Create a dynamic 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
}
});
init();
diff -r b24dc0320b75 -r 7106f9b75004 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java Mon Jul 08 11:41:10 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java Mon Jul 08 13:59:24 2013 +0200
@@ -99,7 +99,7 @@
MSG.gauge_river_url() + number :
MSG.gauge_river_url();
String wikiBaseUrl = Config.getInstance().getWikiUrl();
- DynamicForm infoLink = WikiLinks.linkHTML(this.flys, wikiBaseUrl + url,
+ DynamicForm infoLink = WikiLinks.linkDynamicForm(this.flys, wikiBaseUrl + url,
MSG.gauge_river_info_link());
infoLink.setTop(5);
LinkItem item = (LinkItem)infoLink.getField("saml");
diff -r b24dc0320b75 -r 7106f9b75004 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 Mon Jul 08 11:41:10 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiImgLink.java Mon Jul 08 13:59:24 2013 +0200
@@ -24,7 +24,7 @@
@Override
protected void update() {
- setContents(WikiLinks.imageLinkHTML(instance, href, imgUrl));
+ setContents(WikiLinks.imageLinkForm(instance, href, imgUrl));
setWidth(width);
setHeight(height);
setOverflow(Overflow.VISIBLE);
diff -r b24dc0320b75 -r 7106f9b75004 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 Mon Jul 08 11:41:10 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WikiLinks.java Mon Jul 08 13:59:24 2013 +0200
@@ -8,18 +8,21 @@
package org.dive4elements.river.client.client.ui;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import com.smartgwt.client.types.FormMethod;
import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
-import com.google.gwt.safehtml.shared.SafeHtmlUtils;
import org.dive4elements.river.client.client.FLYS;
+import org.dive4elements.river.client.shared.model.User;
public class WikiLinks
{
- public static String imageLinkHTML(FLYS instance, String url, String imageUrl) {
+ public static String imageLinkForm(FLYS instance, String url, String imageUrl) {
String saml = null;
if (instance != null && instance.getCurrentUser() != null) {
saml = instance.getCurrentUser().getSamlXMLBase64();
@@ -40,11 +43,13 @@
}
}
- public static DynamicForm linkHTML(FLYS flys, String url, String text) {
- String saml = flys.getCurrentUser().getSamlXMLBase64();
+ public static DynamicForm linkDynamicForm(FLYS flys, String url, String text) {
+ User currentUser = flys.getCurrentUser();
String quotedUrl = SafeHtmlUtils.htmlEscape(url);
String quotedText = SafeHtmlUtils.htmlEscape(text);
- if (saml != null) {
+
+ if (currentUser != null) {
+ String saml = currentUser.getSamlXMLBase64();
final DynamicForm form = new DynamicForm();
form.setMethod(FormMethod.POST);
form.setTarget("_blank");
@@ -71,4 +76,31 @@
return form;
}
}
+
+ public static DynamicForm dynamicForm(FLYS flys, String url) {
+ User currentUser = flys.getCurrentUser();
+ String quotedUrl = SafeHtmlUtils.htmlEscape(url);
+
+ if (currentUser != null) {
+ String saml = currentUser.getSamlXMLBase64();
+ saml = SafeHtmlUtils.htmlEscape(saml);
+ GWT.log("saml=" + saml);
+ DynamicForm form = new DynamicForm();
+ form.setMethod(FormMethod.POST);
+ form.setTarget("_blank");
+ form.setAction(quotedUrl);
+ form.setCanSubmit(true);
+ HiddenItem item = new HiddenItem("saml");
+ item.setDefaultValue(saml);
+ form.setFields(item);
+ form.setValue("saml", saml);
+ return form;
+ }
+ else {
+ DynamicForm form = new DynamicForm();
+ form.setTarget("_blank");
+ form.setAction(quotedUrl);
+ return form;
+ }
+ }
}
diff -r b24dc0320b75 -r 7106f9b75004 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java Mon Jul 08 11:41:10 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/InfoListGrid.java Mon Jul 08 13:59:24 2013 +0200
@@ -46,7 +46,7 @@
) {
String name = this.getFieldName(colNum);
if (name.equals("infolink")) {
- return WikiLinks.linkHTML(
+ return WikiLinks.linkDynamicForm(
flys,
record.getAttribute("link"),
record.getLinkText());
More information about the Dive4elements-commits
mailing list