Java Code Examples for io.reactivex.Maybe#empty()
The following examples show how to use
io.reactivex.Maybe#empty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UMATokenGranter.java From graviteeio-access-management with Apache License 2.0 | 6 votes |
@Override protected Maybe<User> resolveResourceOwner(TokenRequest tokenRequest, Client client) { if(StringUtils.isEmpty(tokenRequest.getClaimToken())) { return Maybe.empty(); } return jwtService.decodeAndVerify(tokenRequest.getClaimToken(), client) .flatMapMaybe(jwt -> userAuthenticationManager.loadUserByUsername(jwt.getSub())) .switchIfEmpty(Maybe.error(UserInvalidException::new)) .onErrorResumeNext(ex -> { //If user return Maybe.error(UmaException.needInfoBuilder(tokenRequest.getTicket()) .requiredClaims(Arrays.asList( new RequiredClaims(CLAIM_TOKEN).setFriendlyName("Malformed or expired claim_token") )) .build()); }); }
Example 2
Source File: JWKServiceImpl.java From graviteeio-access-management with Apache License 2.0 | 6 votes |
@Override public Maybe<JWK> getKey(JWKSet jwkSet, String kid) { if(jwkSet==null || jwkSet.getKeys().isEmpty() || kid==null || kid.trim().isEmpty()) { return Maybe.empty(); } //Else return matching key Optional<JWK> jwk = jwkSet.getKeys().stream().filter(key -> kid.equals(key.getKid())).findFirst(); if(jwk.isPresent()) { return Maybe.just(jwk.get()); } //No matching key found in JWKs... return Maybe.empty(); }
Example 3
Source File: RedisSessionManager.java From kyoko with MIT License | 6 votes |
@Override public Maybe<Session> exchangeCode(String code, String redirectUri, String scope) { if (code == null || code.isBlank()) { return Maybe.empty(); } return DiscordOAuth2API.api.exchangeToken( getAuthorization(), Main.getCatnip().clientId(), Settings.instance().apiKeys().get("discord_client"), "authorization_code", code, redirectUri, scope) .doOnError(e -> logger.error("Code exchange failed", e)) .onErrorResumeNext(Maybe.empty()) .flatMap(Session::from) .doOnSuccess(session -> sessionMap .fastPut(session.sessionId(), session) .doOnError(e -> logger.error("Error saving session", e)) .subscribe()); }
Example 4
Source File: AuthorizationRequestParseRequestObjectHandler.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
private Maybe<JWT> handleRequestObjectValue(RoutingContext context) { final String request = context.request().getParam(Parameters.REQUEST); if (request != null) { // Ensure that the request_uri is not propagated to the next authorization flow step context.request().params().remove(Parameters.REQUEST); return requestObjectService .readRequestObject(request, context.get(CLIENT_CONTEXT_KEY)) .toMaybe(); } else { return Maybe.empty(); } }
Example 5
Source File: CertificateManagerImpl.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
@Override public Maybe<CertificateProvider> get(String id) { if (id == null) { return Maybe.empty(); } CertificateProvider certificateProvider = certificateProviderManager.get(id); return certificateProvider != null ? Maybe.just(certificateProvider) : Maybe.empty(); }
Example 6
Source File: ClientAssertionServiceImpl.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
private Maybe<JWKSet> getClientJwkSet(Client client) { if(client.getJwksUri()!=null && !client.getJwksUri().trim().isEmpty()) { return jwkService.getKeys(client.getJwksUri()); } else if(client.getJwks()!=null) { return Maybe.just(client.getJwks()); } return Maybe.empty(); }
Example 7
Source File: RecorderControllerImpl.java From science-journal with Apache License 2.0 | 5 votes |
private MaybeSource<SensorSnapshot> makeSnapshot(String sensorId, SensorRegistry sensorRegistry) throws Exception { BehaviorSubject<ScalarReading> subject = latestValues.get(sensorId); if (subject == null) { return Maybe.empty(); } final GoosciSensorSpec.SensorSpec spec = getSensorSpec(sensorId, sensorRegistry); return subject.firstElement().map(value -> generateSnapshot(spec, value)); }
Example 8
Source File: ProtoInterfaceImpl.java From ocraft-s2client with MIT License | 5 votes |
@Override public <T extends Request> Maybe<Response> sendRequest(T requestData) { require("request", requestData); if (!requestData.responseType().equals(ResponseType.PING) && responseQueue.peek(requestData.responseType())) { // TODO p.picheta to test onError.accept(ClientError.RESPONSE_NOT_CONSUMED, Collections.emptyList()); return Maybe.empty(); } Maybe<Response> responseMaybe = s2Client.waitForResponse(requestData.responseType()); s2Client.request(requestData); countUses.compute(requestData.responseType(), (responseType, count) -> count != null ? ++count : 1); responseQueue.offer(requestData.responseType(), responseMaybe); return responseMaybe; }
Example 9
Source File: MainActivity.java From Reactive-Android-Programming with MIT License | 5 votes |
private void demo5() { Completable completable = Completable.fromAction(() -> { log("Let's do something"); }); completable.subscribe(() -> { log("Finished"); }, throwable -> { log(throwable); }); Single.just("One item") .subscribe((item) -> { log(item); }, (throwable) -> { log(throwable); }); Maybe.empty(); Maybe.just("Item") .subscribe(s -> { log("On Success: " + s); }); Maybe.just("Item") .subscribe(s -> { log("On Success: " + s); }, throwable -> log("error")); Maybe.just("Item") .subscribe( s -> log("success: " + s), throwable -> log("error"), () -> log("onComplete") ); }
Example 10
Source File: UserServiceImpl.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
private Maybe<Application> checkClient(String domain, String client) { if (client == null) { return Maybe.empty(); } return applicationService.findById(client) .switchIfEmpty(Maybe.defer(() -> applicationService.findByDomainAndClientId(domain, client))) .switchIfEmpty(Maybe.error(new ClientNotFoundException(client))) .map(app1 -> { if (!domain.equals(app1.getDomain())) { throw new ClientNotFoundException(client); } return app1; }); }
Example 11
Source File: IdentityProviderManagerImpl.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
@Override public Maybe<IdentityProvider> getIdentityProvider(String id) { IdentityProvider identityProvider = identities.get(id); return (identityProvider != null) ? Maybe.just(identityProvider) : Maybe.empty(); }
Example 12
Source File: UserManagerImpl.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
@Override public Maybe<User> get(String userId) { return userStore.get(userId) != null ? Maybe.just(userStore.get(userId)) : Maybe.empty(); }
Example 13
Source File: RxWebsocket.java From rxWebSocket with Apache License 2.0 | 4 votes |
public Open() { this.response = Maybe.empty(); }
Example 14
Source File: HttpAuthenticationProvider.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
@Override public Maybe<User> loadUserByUsername(String username) { return Maybe.empty(); }
Example 15
Source File: ImpressionStorageClient.java From firebase-android-sdk with Apache License 2.0 | 4 votes |
private void clearInMemCache() { cachedImpressionsMaybe = Maybe.empty(); }
Example 16
Source File: UserStorage.java From mvvm-starter with MIT License | 4 votes |
@Override public Maybe<List<User>> getList () { List<User> users = isCacheValid() ? Hawk.get(K.USER_LIST, new ArrayList<User>()) : null; return users == null ? Maybe.<List<User>>empty() : Maybe.just(users).subscribeOn(Schedulers.io()); }
Example 17
Source File: OAuth2GenericAuthenticationProvider.java From graviteeio-access-management with Apache License 2.0 | 4 votes |
@Override public Maybe<User> loadUserByUsername(String username) { return Maybe.empty(); }
Example 18
Source File: ProductGatewayClientFallback.java From micronaut-microservices-poc with Apache License 2.0 | 4 votes |
@Override public Maybe<ProductDto> get(String productCode) { return Maybe.empty(); }
Example 19
Source File: RxUserServiceImpl.java From alibaba-rsocket-broker with Apache License 2.0 | 4 votes |
@Override public Maybe<Void> job1() { return Maybe.empty(); }
Example 20
Source File: UserStorage.java From mvvm-starter with MIT License | 4 votes |
@Override public Maybe<User> get (Integer id) { User user = isCacheValid() ? Hawk.get(String.format(K.USER_DETAIL, id), new User(0, "", "")) : null; return user == null ? Maybe.<User>empty() : Maybe.just(user).subscribeOn(Schedulers.io()); }