Exemple #1
0
 @Override
 public Identity identity() throws IOException {
   final MultivaluedMap<String, String> headers = this.resource.httpHeaders().getRequestHeaders();
   Identity identity = Identity.ANONYMOUS;
   if (headers.containsKey(Auth.HEADER_URN) && headers.containsKey(Auth.HEADER_TOKEN)) {
     final URN urn = URN.create(headers.getFirst(Auth.HEADER_URN));
     final User user = this.base.user(urn);
     if (!user.exists()) {
       throw new WebApplicationException(
           Response.status(HttpURLConnection.HTTP_UNAUTHORIZED).build());
     }
     final String token = headers.getFirst(Auth.HEADER_TOKEN);
     if (!user.token().equals(token)) {
       throw new WebApplicationException(
           Response.status(HttpURLConnection.HTTP_UNAUTHORIZED).build());
     }
     identity = new Identity.Simple(urn, "http", URI.create("#"));
   }
   return identity;
 }
Exemple #2
0
 @Override
 public URN identity() {
   return URN.create("urn:anonymous:0");
 }
Exemple #3
0
 @Override
 public URN urn() {
   return URN.create("urn:rexsl:anonymous");
 }
Exemple #4
0
 /** Public ctor for a test identity, with default coordinates. */
 public Simple() {
   this(URN.create("urn:test:0"), "John Doe", URI.create("#"));
 }