comparison gwt-client/src/main/java/org/dive4elements/river/client/server/auth/was/Response.java @ 6187:7bc35bbd8b27

Store the SAML ticket in the user object after authentication. The SAML ticket will be needed to allow single sign-on to work for the links into the wiki that are used in several places in the UI. Part of flys/issue1265
author Bernhard Herzog <bh@intevation.de>
date Tue, 04 Jun 2013 17:13:50 +0200
parents ea9eef426962
children 238fc722f87a
comparison
equal deleted inserted replaced
6186:a07521dca5b5 6187:7bc35bbd8b27
8 8
9 package org.dive4elements.river.client.server.auth.was; 9 package org.dive4elements.river.client.server.auth.was;
10 10
11 import java.io.IOException; 11 import java.io.IOException;
12 import java.io.InputStream; 12 import java.io.InputStream;
13 import java.io.StringBufferInputStream;
13 import java.util.List; 14 import java.util.List;
14 15
15 import org.apache.commons.codec.binary.Base64InputStream; 16 import org.apache.commons.codec.binary.Base64InputStream;
16 17
17 import org.apache.http.HttpEntity; 18 import org.apache.http.HttpEntity;
19 import org.apache.http.util.EntityUtils;
18 20
19 import org.apache.log4j.Logger; 21 import org.apache.log4j.Logger;
20 22
21 import org.w3c.dom.Document; 23 import org.w3c.dom.Document;
22 import org.w3c.dom.Element; 24 import org.w3c.dom.Element;
35 public class Response implements Authentication { 37 public class Response implements Authentication {
36 38
37 private static Logger logger = Logger.getLogger(Response.class); 39 private static Logger logger = Logger.getLogger(Response.class);
38 40
39 private Element root; 41 private Element root;
42 private String samlTicketXML;
40 private Assertion assertion; 43 private Assertion assertion;
41 private String username; 44 private String username;
42 private String password; 45 private String password;
43 private Features features; 46 private Features features;
44 private String trustedKeyFile; 47 private String trustedKeyFile;
51 if (entity == null) { 54 if (entity == null) {
52 throw new ServiceException("Invalid response"); 55 throw new ServiceException("Invalid response");
53 } 56 }
54 57
55 String contenttype = entity.getContentType().getValue(); 58 String contenttype = entity.getContentType().getValue();
59 String samlTicketXML = EntityUtils.toString(entity);
56 60
57 InputStream in = entity.getContent(); 61 InputStream in = new StringBufferInputStream(samlTicketXML);
58 62
59 if (!contenttype.equals("application/vnd.ogc.se_xml")) { 63 if (!contenttype.equals("application/vnd.ogc.se_xml")) {
60 // XXX: Assume base64 encoded content. 64 // XXX: Assume base64 encoded content.
61 in = new Base64InputStream(in); 65 in = new Base64InputStream(in);
62 } 66 }
68 if (rname != null && rname.equals("ServiceExceptionReport")) { 72 if (rname != null && rname.equals("ServiceExceptionReport")) {
69 throw new ServiceException(XPathUtils.xpathString(root, 73 throw new ServiceException(XPathUtils.xpathString(root,
70 "ServiceException")); 74 "ServiceException"));
71 } 75 }
72 76
77 this.samlTicketXML = samlTicketXML;
73 this.root = root; 78 this.root = root;
74 this.username = username; 79 this.username = username;
75 this.password = password; 80 this.password = password;
76 this.features = features; 81 this.features = features;
77 this.trustedKeyFile = trustedKeyFile; 82 this.trustedKeyFile = trustedKeyFile;
111 } 116 }
112 List<String> features = this.features.getFeatures( 117 List<String> features = this.features.getFeatures(
113 this.assertion.getRoles()); 118 this.assertion.getRoles());
114 logger.debug("User " + this.username + " with features " + features + 119 logger.debug("User " + this.username + " with features " + features +
115 " successfully authenticated."); 120 " successfully authenticated.");
116 return new User(assertion, features, this.password); 121 return new User(assertion, this.samlTicketXML, features, this.password);
117 } 122 }
118 } 123 }
119 // vim: set si et fileencoding=utf-8 ts=4 sw=4 tw=80: 124 // vim: set si et fileencoding=utf-8 ts=4 sw=4 tw=80:

http://dive4elements.wald.intevation.org