Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/auth/plain/Authenticator.java @ 3696:a050cb5f303f
Cosmetics
flys-client/trunk@5395 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sat, 08 Sep 2012 11:26:30 +0000 |
parents | 04977c883369 |
children | 2e12518ff5b4 |
comparison
equal
deleted
inserted
replaced
3695:5e4d91304484 | 3696:a050cb5f303f |
---|---|
14 | 14 |
15 import org.apache.log4j.Logger; | 15 import org.apache.log4j.Logger; |
16 | 16 |
17 import de.intevation.flys.client.server.features.Features; | 17 import de.intevation.flys.client.server.features.Features; |
18 | 18 |
19 /** | |
20 * Authenticator that uses a local file as user backend. | |
21 */ | |
19 public class Authenticator | 22 public class Authenticator |
20 implements de.intevation.flys.client.server.auth.Authenticator | 23 implements de.intevation.flys.client.server.auth.Authenticator |
21 { | 24 { |
22 private static final Logger log = | 25 private static final Logger log = |
23 Logger.getLogger(Authenticator.class); | 26 Logger.getLogger(Authenticator.class); |
91 new BufferedReader( | 94 new BufferedReader( |
92 new FileReader(file)); | 95 new FileReader(file)); |
93 try { | 96 try { |
94 String line; | 97 String line; |
95 while ((line = reader.readLine()) != null) { | 98 while ((line = reader.readLine()) != null) { |
96 if ((line = line.trim()).length() == 0 | 99 if (line.startsWith("#")) { |
97 || line.startsWith("#")) { | |
98 continue; | 100 continue; |
99 } | 101 } |
100 String [] parts = line.split("\\s+"); | 102 |
103 String[] parts = line.split("\\s+"); | |
101 if (parts.length < 2) { | 104 if (parts.length < 2) { |
102 continue; | 105 continue; |
103 } | 106 } |
107 | |
104 if (parts[0].equals(username)) { | 108 if (parts[0].equals(username)) { |
105 log.debug("user '" + username + "' found."); | 109 log.debug("user '" + username + "' found."); |
106 if (parts[1].equals(password)) { | 110 if (parts[1].equals(password)) { |
107 List<String> roles = | 111 List<String> roles = |
108 new ArrayList<String>(parts.length - 2); | 112 new ArrayList<String>(parts.length - 2); |
121 } | 125 } |
122 finally { | 126 finally { |
123 reader.close(); | 127 reader.close(); |
124 } | 128 } |
125 log.debug("failed"); | 129 log.debug("failed"); |
126 return new Authentication(null, null, new ArrayList<String>(0), features); | 130 return null; |
127 } | 131 } |
128 } | 132 } |
129 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 133 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |