# HG changeset patch # User casties # Date 1332349965 -3600 # Node ID 6c7c4140630d6908ef09f95df3e01d51cb91a8e9 # Parent 0f64de5fff5a027318ca14b7ed765bb6dce40830 on the way to updating annotations. diff -r 0f64de5fff5a -r 6c7c4140630d src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorAnnotations.java --- a/src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorAnnotations.java Wed Mar 21 16:38:50 2012 +0100 +++ b/src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorAnnotations.java Wed Mar 21 18:12:45 2012 +0100 @@ -52,11 +52,15 @@ @Get("json") public Representation doGetJSON(Representation entity) { logger.debug("AnnotatorAnnotations doGetJSON!"); - doOptions(entity); + setCorsHeaders(); + // id from URI /annotations/{id} + String id = (String) getRequest().getAttributes().get("id"); + logger.debug("annotation-id="+id); + // TODO: what to do with authentication? boolean authenticated = isAuthenticated(entity); logger.debug("request authenticated=" + authenticated); - + // TODO: Annotator read request does not use parameters Form form = getRequest().getResourceRef().getQueryAsForm(); String uri = form.getFirstValue("uri"); diff -r 0f64de5fff5a -r 6c7c4140630d src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorResourceImpl.java --- a/src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorResourceImpl.java Wed Mar 21 16:38:50 2012 +0100 +++ b/src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorResourceImpl.java Wed Mar 21 18:12:45 2012 +0100 @@ -144,9 +144,10 @@ String computedToken = getSha256Digest(consumerSecret + userId + issueTime); // compare to the token we got String authToken = requestHeaders.getFirstValue("x-annotator-auth-token", true); - logger.debug(String.format("got: authToken=%s consumerSecret=%s userId=%s issueTime=%s", authToken, consumerSecret, userId, - issueTime)); - if (!computedToken.equals(authToken)) { + logger.debug(String.format("got: authToken=%s consumerSecret=%s userId=%s issueTime=%s computedToken=%s", + authToken, consumerSecret, userId, issueTime, computedToken)); + if (!computedToken.equalsIgnoreCase(authToken)) { + logger.warn("authToken differ!"); return null; } // check token lifetime @@ -164,10 +165,13 @@ } catch (NumberFormatException e) { e.printStackTrace(); } - if (tokenValidity == null || tokenValidity.isAfterNow() || tokenExpiry.isBeforeNow()) { - return null; + if (tokenValidity == null || tokenValidity.isAfterNow() || tokenExpiry == null || tokenExpiry.isBeforeNow()) { + logger.warn(String.format("authToken invalid! tokenValidity=%s tokenExpiry=%s now=%s", tokenValidity, tokenExpiry, DateTime.now())); + // we dont care about validity right now + //return null; } // must be ok then + logger.debug("auth OK! user="+userId); return userId; } diff -r 0f64de5fff5a -r 6c7c4140630d src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorSearch.java --- a/src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorSearch.java Wed Mar 21 16:38:50 2012 +0100 +++ b/src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorSearch.java Wed Mar 21 18:12:45 2012 +0100 @@ -47,8 +47,8 @@ */ @Get("json") public Representation doGetJSON(Representation entity) { - - doOptions(entity); + logger.debug("AnnotatorSearch doGetJSON!"); + setCorsHeaders(); //TODO: what to do with authentication? boolean authenticated = isAuthenticated(entity); logger.debug("request authenticated="+authenticated); @@ -110,7 +110,7 @@ */ @Get("html") public Representation doGetHTML(Representation entity) { - + logger.debug("AnnotatorSearch doGetHTML!"); doOptions(entity); Form form = getRequest().getResourceRef().getQueryAsForm(); String uri = form.getFirstValue("uri"); diff -r 0f64de5fff5a -r 6c7c4140630d src/de/mpiwg/itgroup/annotationManager/restlet/RestServer.java --- a/src/de/mpiwg/itgroup/annotationManager/restlet/RestServer.java Wed Mar 21 16:38:50 2012 +0100 +++ b/src/de/mpiwg/itgroup/annotationManager/restlet/RestServer.java Wed Mar 21 18:12:45 2012 +0100 @@ -187,12 +187,9 @@ Router router = new Router(getContext()); router.attach("/annotator/annotations", AnnotatorAnnotations.class); - router.attach("/annotator/search", AnnotatorSearch.class); // annotator api askes - // for different uris - // for search and - // adding - // router.attach("/search",SearchAnnotations.class); // annotator api - // askes for different uris for search and adding + router.attach("/annotator/annotations/{id}", AnnotatorAnnotations.class); + router.attach("/annotator/search", AnnotatorSearch.class); + router.attach("/dummy", Dummy.class); // router.attach("",redirector);