Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/server/auth/plain/Authenticator.java @ 3485:71ba3cf3ec5e
Refactor Authentication to allow to pass the Freatures to the user class
The Features class can be used to receive the allowed features for the users
roles.
flys-client/trunk@5183 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 10 Aug 2012 07:06:18 +0000 |
parents | 1f64ee424f92 |
children | 04977c883369 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/auth/plain/Authenticator.java Thu Aug 09 08:22:04 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/auth/plain/Authenticator.java Fri Aug 10 07:06:18 2012 +0000 @@ -14,6 +14,8 @@ import org.apache.log4j.Logger; +import de.intevation.flys.client.server.features.Features; + public class Authenticator implements de.intevation.flys.client.server.auth.Authenticator { @@ -26,15 +28,18 @@ protected String user; protected String password; protected List<String> roles; + protected Features features; public Authentication( String user, String password, - List<String> roles + List<String> roles, + Features features ) { this.user = user; this.password = password; this.roles = roles; + this.features = features; } @Override @@ -45,7 +50,7 @@ @Override public User getUser() { return isSuccess() - ? new DefaultUser(user, password, false, roles) + ? new DefaultUser(user, password, false, roles, this.features.getFeatures(roles)) : null; } } // class Authentication @@ -70,14 +75,15 @@ public de.intevation.flys.client.server.auth.Authentication auth( String username, String password, - String encoding + String encoding, + Features features ) throws AuthenticationException, IOException { File file = credentialsFile(); if (!file.canRead() || !file.isFile()) { log.error("cannot find user file '" + file + "'"); - return new Authentication(null, null, new ArrayList<String>(0)); + return new Authentication(null, null, new ArrayList<String>(0), features); } BufferedReader reader = @@ -105,7 +111,7 @@ } log.debug("success"); - return new Authentication(username, password, roles); + return new Authentication(username, password, roles, features); } // Stop: user found, wrong password break; @@ -116,7 +122,7 @@ reader.close(); } log.debug("failed"); - return new Authentication(null, null, new ArrayList<String>(0)); + return new Authentication(null, null, new ArrayList<String>(0), features); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :