Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
*
* Copyright 2008-2021 Kinotic and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kinotic.continuum.gateway.internal.endpoints;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.vertx.core.Promise;
import io.vertx.core.eventbus.ReplyException;
import io.vertx.core.eventbus.ReplyFailure;
import org.apache.commons.lang3.Validate;
import org.kinotic.continuum.api.exceptions.AuthenticationException;
import org.kinotic.continuum.api.exceptions.AuthorizationException;
import org.kinotic.continuum.api.exceptions.RpcMissingServiceException;
import org.kinotic.continuum.api.security.ConnectedInfo;
import org.kinotic.continuum.api.security.SecurityService;
import org.kinotic.continuum.core.api.event.CRI;
import org.kinotic.continuum.core.api.event.Event;
import org.kinotic.continuum.core.api.event.EventConstants;
import org.kinotic.continuum.core.api.security.Session;
import org.kinotic.continuum.gateway.internal.api.security.CliSecurityService;
import org.kinotic.continuum.internal.utils.EventUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Mono;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiFunction;
/**
* Generic class to perform {@link Event} handling coming from various endpoints
*
*
* Created by Navid Mitchell on 11/3/20
*/
public class EndpointConnectionHandler {
private static final Logger log = LoggerFactory.getLogger(EndpointConnectionHandler.class);
private final SecurityService securityService;
private final Services services;
private final Map>> subscriptions = new HashMap<>();
private Session session;
private long sessionTimer = -1;
public EndpointConnectionHandler(Services services) {
this.services = services;
if(services.continuumGatewayProperties.isEnableCLIConnections()){
this.securityService = new CliSecurityService(services.securityService);
}else{
this.securityService = services.securityService;
}
}
/**
* Requests authentication for the given credentials
* @param connectHeaders all the headers provided with the CONNECT frame. This will include the login and passcode headers.
* @return a {@link Promise} completed normally to authenticate or failed to represent a failed authentication
* The promise must contain a Map that will provide any additional headers to be returned to the client with the CONNECTED frame
*/
public CompletableFuture