Mercurial > dive4elements > river
changeset 2968:3e0567e02577
Extend Authentication and Response to throw additional exceptions
flys-client/trunk@4964 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 13 Jul 2012 06:46:27 +0000 |
parents | ce07c6a1e96b |
children | 16c71457ed43 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/auth/Authentication.java flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Response.java |
diffstat | 3 files changed, 20 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Fri Jul 13 06:33:48 2012 +0000 +++ b/flys-client/ChangeLog Fri Jul 13 06:46:27 2012 +0000 @@ -1,3 +1,10 @@ +2012-07-13 Björn Ricks <bjoern.ricks@intevation.de> + + * src/main/java/de/intevation/flys/client/server/auth/Authentication.java, + src/main/java/de/intevation/flys/client/server/auth/was/Response.java: + Extend Authentication getUser method to throw an AuthenticationException. + Also the Response constructor now throws an IOException. + 2012-07-13 Björn Ricks <bjoern.ricks@intevation.de> * src/main/java/de/intevation/fly/client/server/auth/was/User.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/server/auth/Authentication.java Fri Jul 13 06:33:48 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/auth/Authentication.java Fri Jul 13 06:46:27 2012 +0000 @@ -1,6 +1,9 @@ package de.intevation.flys.client.server.auth; +import de.intevation.flys.client.server.auth.AuthenticationException; import de.intevation.flys.client.server.auth.User; + + /** Interface to represent user authentications */ public interface Authentication { @@ -11,6 +14,6 @@ /** Returns a new User object */ - public User getUser(); + public User getUser() throws AuthenticationException; }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Response.java Fri Jul 13 06:33:48 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Response.java Fri Jul 13 06:46:27 2012 +0000 @@ -15,6 +15,7 @@ import org.jdom.input.SAXBuilder; import de.intevation.flys.client.server.auth.Authentication; +import de.intevation.flys.client.server.auth.AuthenticationException; public class Response implements Authentication { @@ -26,7 +27,7 @@ private String password; - public Response(HttpEntity entity, String username, String password) throws ServiceException { + public Response(HttpEntity entity, String username, String password) throws AuthenticationException, IOException { if (entity == null) { throw new ServiceException("Invalid response"); @@ -57,10 +58,7 @@ } catch(JDOMException e) { - logger.error(e); - } - catch(IOException e) { - logger.error(e); + throw new AuthenticationException(e); } } @@ -99,8 +97,12 @@ } @Override - public User getUser() { - return new User(this.username, this.password); + public User getUser() throws AuthenticationException { + Assertion assertion = this.getAssertion(); + if (assertion == null) { + throw new AuthenticationException("Response doesn't contain an assertion"); + } + return new User(this.username, this.password, assertion); } } // vim: set si et fileencoding=utf-8 ts=4 sw=4 tw=80: