Surviving attemps to log in with invalid loginID
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 14 Sep 2009 16:11:39 +0200
changeset 853574b08dc3c3
parent 84 824d66048bac
child 86 8c9969f89021
Surviving attemps to log in with invalid loginID
freemarkerdor/pom.xml
freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java
webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java
     1.1 --- a/freemarkerdor/pom.xml	Mon Sep 14 12:03:12 2009 +0200
     1.2 +++ b/freemarkerdor/pom.xml	Mon Sep 14 16:11:39 2009 +0200
     1.3 @@ -10,6 +10,7 @@
     1.4    <groupId>org.apidesign</groupId>
     1.5    <artifactId>freemarkerdor</artifactId>
     1.6    <name>freemarkerdor</name>
     1.7 +  <version>1.8</version>
     1.8    <url>http://maven.apache.org</url>
     1.9    <dependencies>
    1.10      <dependency>
    1.11 @@ -100,7 +101,6 @@
    1.12      </plugin>
    1.13    </plugins>
    1.14    </build>
    1.15 -  <version>1.7</version>
    1.16  </project>
    1.17  
    1.18  
     2.1 --- a/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java	Mon Sep 14 12:03:12 2009 +0200
     2.2 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/UI.java	Mon Sep 14 16:11:39 2009 +0200
     2.3 @@ -76,8 +76,14 @@
     2.4      private Viewable checkLogin() {
     2.5          if (headers.getCookies().containsKey("login")) {
     2.6              String id = headers.getCookies().get("login").getValue();
     2.7 -            String us = base.path("login").queryParam("id", id).
     2.8 -                accept(MediaType.TEXT_PLAIN).get(String.class);
     2.9 +            String us;
    2.10 +            try {
    2.11 +                us = base.path("login").queryParam("id", id).
    2.12 +                    accept(MediaType.TEXT_PLAIN).get(String.class);
    2.13 +            } catch (UniformInterfaceException ex) {
    2.14 +                ex.printStackTrace();
    2.15 +                us = "";
    2.16 +            }
    2.17              if (us.length() > 0) {
    2.18                  user = us;
    2.19                  uuid = id;
     3.1 --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java	Mon Sep 14 12:03:12 2009 +0200
     3.2 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java	Mon Sep 14 16:11:39 2009 +0200
     3.3 @@ -105,11 +105,15 @@
     3.4      public String isLoggedIn(
     3.5          @QueryParam("id") String id
     3.6      ) {
     3.7 +        String ret = null;
     3.8          try {
     3.9 -            return id == null ? "" : loggedIn.get(UUID.fromString(id));
    3.10 +            if (id != null) {
    3.11 +                ret = loggedIn.get(UUID.fromString(id));
    3.12 +            }
    3.13          } catch (IllegalArgumentException ex) {
    3.14 -            return "";
    3.15 +            // OK, happens for invalid ids
    3.16          }
    3.17 +        return ret == null ? "" : ret;
    3.18      }
    3.19  
    3.20      //