comparison flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Response.java @ 3486:23095983c249

Implement Features handling for WAS authentication flys-client/trunk@5184 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 10 Aug 2012 08:17:52 +0000
parents d700f6492386
children 6f36f79676a7
comparison
equal deleted inserted replaced
3485:71ba3cf3ec5e 3486:23095983c249
1 package de.intevation.flys.client.server.auth.was; 1 package de.intevation.flys.client.server.auth.was;
2 2
3 import java.io.IOException; 3 import java.io.IOException;
4 import java.io.InputStream; 4 import java.io.InputStream;
5 import java.util.List;
5 6
6 import org.apache.commons.codec.binary.Base64InputStream; 7 import org.apache.commons.codec.binary.Base64InputStream;
7 8
8 import org.apache.http.HttpEntity; 9 import org.apache.http.HttpEntity;
9 10
15 import org.jdom.input.SAXBuilder; 16 import org.jdom.input.SAXBuilder;
16 17
17 import de.intevation.flys.client.server.auth.Authentication; 18 import de.intevation.flys.client.server.auth.Authentication;
18 import de.intevation.flys.client.server.auth.AuthenticationException; 19 import de.intevation.flys.client.server.auth.AuthenticationException;
19 20
21 import de.intevation.flys.client.server.features.Features;
22
20 public class Response implements Authentication { 23 public class Response implements Authentication {
21 24
22 private static Logger logger = Logger.getLogger(Response.class); 25 private static Logger logger = Logger.getLogger(Response.class);
23 26
24 private Element root; 27 private Element root;
25 private Assertion assertion; 28 private Assertion assertion;
26 private String username; 29 private String username;
27 private String password; 30 private String password;
31 private Features features;
28 32
29 33
30 public Response(HttpEntity entity, String username, String password) throws AuthenticationException, IOException { 34 public Response(HttpEntity entity, String username, String password, Features features) throws AuthenticationException, IOException {
31 35
32 if (entity == null) { 36 if (entity == null) {
33 throw new ServiceException("Invalid response"); 37 throw new ServiceException("Invalid response");
34 } 38 }
35 39
53 } 57 }
54 58
55 this.root = root; 59 this.root = root;
56 this.username = username; 60 this.username = username;
57 this.password = password; 61 this.password = password;
62 this.features = features;
58 63
59 } 64 }
60 catch(JDOMException e) { 65 catch(JDOMException e) {
61 throw new AuthenticationException(e); 66 throw new AuthenticationException(e);
62 } 67 }
100 public User getUser() throws AuthenticationException { 105 public User getUser() throws AuthenticationException {
101 Assertion assertion = this.getAssertion(); 106 Assertion assertion = this.getAssertion();
102 if (assertion == null) { 107 if (assertion == null) {
103 throw new AuthenticationException("Response doesn't contain an assertion"); 108 throw new AuthenticationException("Response doesn't contain an assertion");
104 } 109 }
105 return new User(this.username, this.password, this.assertion.getRoles(), assertion); 110 List<String> features = this.features.getFeatures(
111 this.assertion.getRoles());
112 return new User(this.username, this.password,
113 this.assertion.getRoles(), assertion, features);
106 } 114 }
107 } 115 }
108 // vim: set si et fileencoding=utf-8 ts=4 sw=4 tw=80: 116 // vim: set si et fileencoding=utf-8 ts=4 sw=4 tw=80:

http://dive4elements.wald.intevation.org