public Single<Boolean> revokeToken(FullHttpRequest req) throws OAuthException {
        RevokeTokenRequest revokeRequest = new RevokeTokenRequest(req);
        revokeRequest.checkMandatoryParams();
        String clientId = revokeRequest.getClientId();
        // check valid client_id, status does not matter as token of inactive client app could be revoked too
        return isExistingClient(clientId).flatMap(existed -> {
            if (!existed) throw new OAuthException(ResponseBuilder.INVALID_CLIENT_ID, HttpResponseStatus.BAD_REQUEST);
            else {
                String token = revokeRequest.getAccessToken();
                return db.findAccessToken(token)
                        .map(Optional::of)
                        .switchIfEmpty(Single.just(Optional.empty()))
                        .flatMap(accessToken -> {
                            if (accessToken.isPresent()) {
                                if (accessToken.get().tokenExpired()) {
                                    LOG.info(String.format("Access token {%s} has already expired, nothing need to do.", token));
                                    return Single.just(true);
                                }
                                if (clientId.equals(accessToken.get().getClientId())) {
                                    return db.removeAccessToken(accessToken.get().getToken())
                                            .andThen(Single.just(true)
                                                    .doOnSuccess(ignored -> LOG.info(String.format("access token {%s} set status invalid", token))));
                                } else {
                                    LOG.info(String.format("access token {%s} is not obtained for that client {%s}", token, clientId));
                                    return Single.just(false);
                                }
                            } else {
                                LOG.info(String.format("access token {%s} not found", token));
                                return Single.just(false);
                            }
                        })
                        ;
            }
        });
    }
public Single < Boolean > revokeToken ( FullHttpRequest req ) throws OAuthException { RevokeTokenRequest revokeRequest = new RevokeTokenRequest ( req ) ; revokeRequest . checkMandatoryParams ( ) ; String clientId = revokeRequest . getClientId ( ) ; return isExistingClient ( clientId ) . flatMap ( existed -> { if ( ! existed ) throw new OAuthException ( ResponseBuilder . INVALID_CLIENT_ID , HttpResponseStatus . BAD_REQUEST ) ; else { String token = revokeRequest . getAccessToken ( ) ; return db . findAccessToken ( token ) . map ( Optional :: of ) . switchIfEmpty ( Single . just ( Optional . empty ( ) ) ) . flatMap ( accessToken -> { if ( accessToken . isPresent ( ) ) { if ( accessToken . get ( ) . tokenExpired ( ) ) { LOG . info ( String . format ( "Access token {%s} has already expired, nothing need to do." , token ) ) ; return Single . just ( true ) ; } if ( clientId . equals ( accessToken . get ( ) . getClientId ( ) ) ) { return db . removeAccessToken ( accessToken . get ( ) . getToken ( ) ) . andThen ( Single . just ( true ) . doOnSuccess ( ignored -> LOG . info ( String . format ( "access token {%s} set status invalid" , token ) ) ) ) ; } else { LOG . info ( String . format ( "access token {%s} is not obtained for that client {%s}" , token , clientId ) ) ; return Single . just ( false ) ; } } else { LOG . info ( String . format ( "access token {%s} not found" , token ) ) ; return Single . just ( false ) ; } } ) ; } } ) ; }
revoke the given token.  revoke = 撤销

@param req the requested token to be revoked
@return OAuthException if the given client id does not exist.  true if the token exists and has been revoked, false if the token does not exist.