Example #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;
 }
Example #2
0
File: User.java Project: LHN/s3auth
 @Override
 public URN identity() {
   return URN.create("urn:anonymous:0");
 }
Example #3
0
 @Override
 public URN urn() {
   return URN.create("urn:rexsl:anonymous");
 }
Example #4
0
 /** Public ctor for a test identity, with default coordinates. */
 public Simple() {
   this(URN.create("urn:test:0"), "John Doe", URI.create("#"));
 }