@Override public Identity identity() throws IOException { Identity identity = Identity.ANONYMOUS; if (this.resource.uriInfo().getQueryParameters() .containsKey(Facebook.FLAG)) { final List<String> code = this.resource.uriInfo() // @checkstyle MultipleStringLiterals (1 line) .getQueryParameters().get("code"); if (code == null || code.isEmpty()) { throw new WebApplicationException( new IllegalArgumentException( "HTTP query parameter 'code' is mandatory" ), HttpURLConnection.HTTP_BAD_REQUEST ); } final User fbuser = this.fetch(this.token(code.get(0))); identity = new Identity.Simple( URN.create(String.format("urn:facebook:%s", fbuser.getId())), fbuser.getName(), UriBuilder.fromUri("https://graph.facebook.com/") .path("/{id}/picture") .build(fbuser.getId()) ); } return identity; }