mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Fix NPE
This commit is contained in:
commit
7876d87c51
@ -44,13 +44,14 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ExServer {
|
public class ExServer {
|
||||||
private static final Log logger = LogFactory.getLog(ExServer.class.getName());
|
private static final Log logger = LogFactory.getLog(ExServer.class.getName());
|
||||||
|
|
||||||
private static Map<String, String> accessTokenMap = new HashMap<>();
|
private static Map<String, String> accessTokenMap = new ConcurrentHashMap<>();
|
||||||
private static Map<String, String> authorizedScopeMap = new HashMap<>();
|
private static Map<String, String> authorizedScopeMap = new ConcurrentHashMap<>();
|
||||||
private Server server;
|
private Server server;
|
||||||
|
|
||||||
public ExServer() {
|
public ExServer() {
|
||||||
@ -177,6 +178,7 @@ public class ExServer {
|
|||||||
if (request.getResultCode().equals("success")) {
|
if (request.getResultCode().equals("success")) {
|
||||||
String accessToken = accessTokenMap.get(request.getConninfo().getClientid());
|
String accessToken = accessTokenMap.get(request.getConninfo().getClientid());
|
||||||
String scopeString = authorizedScopeMap.get(accessToken);
|
String scopeString = authorizedScopeMap.get(accessToken);
|
||||||
|
if (!StringUtils.isEmpty(scopeString)) {
|
||||||
String[] scopeArray = scopeString.split(" ");
|
String[] scopeArray = scopeString.split(" ");
|
||||||
String deviceType = null;
|
String deviceType = null;
|
||||||
String deviceId = null;
|
String deviceId = null;
|
||||||
@ -199,6 +201,7 @@ public class ExServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
EmptySuccess reply = EmptySuccess.newBuilder().build();
|
EmptySuccess reply = EmptySuccess.newBuilder().build();
|
||||||
responseObserver.onNext(reply);
|
responseObserver.onNext(reply);
|
||||||
responseObserver.onCompleted();
|
responseObserver.onCompleted();
|
||||||
@ -315,12 +318,15 @@ public class ExServer {
|
|||||||
if (StringUtils.isEmpty(accessToken) || !accessToken.startsWith(request.getClientinfo().getUsername())) {
|
if (StringUtils.isEmpty(accessToken) || !accessToken.startsWith(request.getClientinfo().getUsername())) {
|
||||||
logger.info("Valid access token not found");
|
logger.info("Valid access token not found");
|
||||||
responseObserver.onError(new Exception("not authorized"));
|
responseObserver.onError(new Exception("not authorized"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String authorizedScopeList = authorizedScopeMap.get(accessToken);
|
String authorizedScopeList = authorizedScopeMap.get(accessToken);
|
||||||
|
boolean isFound = false;
|
||||||
|
if (!StringUtils.isEmpty(authorizedScopeList)) {
|
||||||
String[] scopeArray = authorizedScopeList.split(" ");
|
String[] scopeArray = authorizedScopeList.split(" ");
|
||||||
List<String> scopeList = Arrays.asList(scopeArray);
|
List<String> scopeList = Arrays.asList(scopeArray);
|
||||||
boolean isFound = false;
|
|
||||||
|
|
||||||
String tempScope = null;
|
String tempScope = null;
|
||||||
String requestTopic = request.getTopic();
|
String requestTopic = request.getTopic();
|
||||||
@ -365,6 +371,7 @@ public class ExServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isFound) {
|
if (isFound) {
|
||||||
ValuedResponse reply = ValuedResponse.newBuilder()
|
ValuedResponse reply = ValuedResponse.newBuilder()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user