Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/auth/AuthenticationFactory.java @ 4488:5041105d2edd
Check if response code from GGInA is 200 OK
Only parse the GGInA response if the status code is 200 OK. This improves the
error message if GGInA is not available and shows the real reason instead of a
JDOM error while parsing the response.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Wed, 14 Nov 2012 10:36:21 +0100 |
parents | 2e12518ff5b4 |
children |
rev | line source |
---|---|
2956
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server.auth; |
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
2 |
2985
1f64ee424f92
Corrected broken web.xml
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2959
diff
changeset
|
3 import org.apache.log4j.Logger; |
2956
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
4 |
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
5 public class AuthenticationFactory { |
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
6 |
2985
1f64ee424f92
Corrected broken web.xml
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2959
diff
changeset
|
7 private static final Logger log = |
1f64ee424f92
Corrected broken web.xml
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2959
diff
changeset
|
8 Logger.getLogger(AuthenticationFactory.class); |
1f64ee424f92
Corrected broken web.xml
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2959
diff
changeset
|
9 |
2956
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
10 public static Authenticator getInstance(String name) |
3696 | 11 throws IllegalArgumentException |
12 { | |
13 if (name == null) { | |
14 throw new IllegalArgumentException("Authentication type name is null"); | |
15 } | |
3697
2e12518ff5b4
Removed trailing whitespace. Reverted functional change in parsing plain user file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3696
diff
changeset
|
16 |
3696 | 17 if (name.equalsIgnoreCase("was") || |
18 name.equalsIgnoreCase("ggina")) { | |
2985
1f64ee424f92
Corrected broken web.xml
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2959
diff
changeset
|
19 log.debug("Using GGinA authenticator."); |
2959
5ba0a6efdf3b
Auth: added simple file based authentication.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2956
diff
changeset
|
20 return |
5ba0a6efdf3b
Auth: added simple file based authentication.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2956
diff
changeset
|
21 new de.intevation.flys.client.server.auth.was.Authenticator(); |
5ba0a6efdf3b
Auth: added simple file based authentication.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2956
diff
changeset
|
22 } |
3696 | 23 else if (name.equalsIgnoreCase("plain")) { |
2985
1f64ee424f92
Corrected broken web.xml
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2959
diff
changeset
|
24 log.debug("Using plain authenticator."); |
2959
5ba0a6efdf3b
Auth: added simple file based authentication.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2956
diff
changeset
|
25 return |
5ba0a6efdf3b
Auth: added simple file based authentication.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2956
diff
changeset
|
26 new de.intevation.flys.client.server.auth.plain.Authenticator(); |
2956
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 } |
3697
2e12518ff5b4
Removed trailing whitespace. Reverted functional change in parsing plain user file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3696
diff
changeset
|
28 |
2956
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 throw new IllegalArgumentException("Unkown Authentication " + name); |
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
30 } |
d7f76f197d89
Refactor GGInA authentication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
31 } |