List of usage examples for io.vertx.core.json JsonObject toString
@Override
public String toString()
From source file:org.pac4j.vertx.OAuth2ProviderMimic.java
License:Apache License
private Handler<RoutingContext> tokenRequestHandler() { return rc -> { // Extract parameters from request body - body handler should make these accessible from params collection final Optional<String> grantType = Optional.ofNullable(rc.request().getParam("grant_type")); final String code = rc.request().getParam("code"); final String redirectUri = rc.request().getParam("redirect_uri"); final String clientId = rc.request().getParam("client_id"); Optional<String> token = grantType.flatMap(s -> { if (code == null || redirectUri == null || clientId == null) { return Optional.empty(); }/*from w w w . j a v a 2 s . c o m*/ return Optional.of(s.equals("authorization_code")) .flatMap(b -> b ? accessToken(clientId, redirectUri, code) : Optional.empty()); }); if (token.isPresent()) { JsonObject responseBody = new JsonObject().put("access_token", token.get()) .put("token_type", "Bearer").put("expires_in", 5000); rc.response().setStatusCode(200).end(responseBody.toString()); } else { rc.fail(401); // We couldn't resolve to a token } }; }
From source file:org.pac4j.vertx.OAuth2ProviderMimic.java
License:Apache License
private Handler<RoutingContext> profileHandler() { return rc -> { final JsonObject responseBody = new JsonObject().put("id", userIdToReturn); rc.response().setStatusCode(200).end(responseBody.toString()); };//from www. j a va2s. c o m }