@Override public Link link() { return new Link( "rexsl:facebook", UriBuilder .fromUri("https://www.facebook.com/dialog/oauth") // @checkstyle MultipleStringLiterals (2 lines) .queryParam("client_id", "{client_id}") .queryParam("redirect_uri", "{redirect_uri}") .build(this.app, this.redirectUri()) ); }
@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; }
/** * Authentication inset. * @return The inset */ @Inset.Runtime public final AuthInset auth() { return new AuthInset(this, Manifests.read("Stateful-SecurityKey")) .with(new Auth(this, this.base())) // @checkstyle LineLength (3 lines) .with(new Facebook(this, Manifests.read("Stateful-FbId"), Manifests.read("Stateful-FbSecret"))) .with(new Google(this, Manifests.read("Stateful-GoogleId"), Manifests.read("Stateful-GoogleSecret"))) .with(new Github(this, Manifests.read("Stateful-GithubId"), Manifests.read("Stateful-GithubSecret"))) .with(BaseRs.TESTER); }
.build( this.app, this.redirectUri(), this.key, code