コード例 #1
0
 @Override
 public void handleConfiguredContextRequest(
     UUID requestId, String contextInfoType, Bundle scanConfig) {
   if (contextInfoType.equals(
       "org.ambientdynamix.contextplugins.context.info.access.accesspermissions")) {
     if (scanConfig.containsKey("action_type")) {
       String actionType = scanConfig.getString("action_type");
       if (actionType.equals("check_sessionkey")) {
         if (scanConfig.containsKey("service_id")) {
           if (unknownService(scanConfig.getString("service_id"))) {
             SecuredContextInfo aci =
                 new SecuredContextInfo(new RemoteAccessContextInfo(), PrivacyRiskLevel.LOW);
             sendContextEvent(requestId, aci);
           } else {
             String newKey = getKey(scanConfig.getString("service_id"));
             SecuredContextInfo aci =
                 new SecuredContextInfo(
                     new RemoteAccessContextInfo(scanConfig.getString("service_id"), newKey),
                     PrivacyRiskLevel.LOW);
             sendContextEvent(requestId, aci);
           }
         }
       }
     }
   }
   if (contextInfoType.equals(
       "org.ambientdynamix.contextplugins.context.action.access.accesspermissions")) {
     if (scanConfig.containsKey("action_type")) {
       String actionType = scanConfig.getString("action_type");
       if (actionType.equals("request_sessionkey")) {
         if (scanConfig.containsKey("service_id")) {
           if (unknownService(scanConfig.getString("service_id"))) {
             String newKey = newKey();
             settings.put(scanConfig.getString("service_id"), newKey);
             SecuredContextInfo aci =
                 new SecuredContextInfo(
                     new RemoteAccessContextInfo(scanConfig.getString("service_id"), newKey),
                     PrivacyRiskLevel.LOW);
             sendContextEvent(requestId, aci);
           } else {
             String newKey = getKey(scanConfig.getString("service_id"));
             SecuredContextInfo aci =
                 new SecuredContextInfo(
                     new RemoteAccessContextInfo(scanConfig.getString("service_id"), newKey),
                     PrivacyRiskLevel.LOW);
             sendContextEvent(requestId, aci);
           }
         }
       }
     }
   }
   context = this;
 }
コード例 #2
0
 private static String getKey(String serviceID) {
   return settings.get(serviceID);
 }
コード例 #3
0
 private static boolean unknownService(String serviceID) {
   return !(settings.containsKey(serviceID));
 }