master
Lasantha Dharmakeerthi 7 months ago
commit 7876d87c51

@ -44,13 +44,14 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class ExServer {
private static final Log logger = LogFactory.getLog(ExServer.class.getName());
private static Map<String, String> accessTokenMap = new HashMap<>();
private static Map<String, String> authorizedScopeMap = new HashMap<>();
private static Map<String, String> accessTokenMap = new ConcurrentHashMap<>();
private static Map<String, String> authorizedScopeMap = new ConcurrentHashMap<>();
private Server server;
public ExServer() {
@ -177,6 +178,7 @@ public class ExServer {
if (request.getResultCode().equals("success")) {
String accessToken = accessTokenMap.get(request.getConninfo().getClientid());
String scopeString = authorizedScopeMap.get(accessToken);
if (!StringUtils.isEmpty(scopeString)) {
String[] scopeArray = scopeString.split(" ");
String deviceType = null;
String deviceId = null;
@ -199,6 +201,7 @@ public class ExServer {
}
}
}
}
EmptySuccess reply = EmptySuccess.newBuilder().build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
@ -315,12 +318,15 @@ public class ExServer {
if (StringUtils.isEmpty(accessToken) || !accessToken.startsWith(request.getClientinfo().getUsername())) {
logger.info("Valid access token not found");
responseObserver.onError(new Exception("not authorized"));
return;
}
String authorizedScopeList = authorizedScopeMap.get(accessToken);
boolean isFound = false;
if (!StringUtils.isEmpty(authorizedScopeList)) {
String[] scopeArray = authorizedScopeList.split(" ");
List<String> scopeList = Arrays.asList(scopeArray);
boolean isFound = false;
String tempScope = null;
String requestTopic = request.getTopic();
@ -365,6 +371,7 @@ public class ExServer {
}
}
}
}
if (isFound) {
ValuedResponse reply = ValuedResponse.newBuilder()

Loading…
Cancel
Save