Beispiel #1
0
  static rinteger make_key(Env* env, Method* meth, KeyMap& keys) {
    KeyMap::iterator iter = keys.find(meth);

    if(iter == keys.end()) {
      rinteger key = env->integer_new(keys.size());
      keys[meth] = key;
      return key;
    }

    return iter->second;
  }
status_t Session::provideKeyResponse(const Vector<uint8_t>& response) {
    String8 responseString(
            reinterpret_cast<const char*>(response.array()), response.size());
    KeyMap keys;

    Mutex::Autolock lock(mMapLock);
    JsonWebKey parser;
    if (parser.extractKeysFromJsonWebKeySet(responseString, &keys)) {
        for (size_t i = 0; i < keys.size(); ++i) {
            const KeyMap::key_type& keyId = keys.keyAt(i);
            const KeyMap::value_type& key = keys.valueAt(i);
            mKeyMap.add(keyId, key);
        }
        return android::OK;
    } else {
        return android::ERROR_DRM_UNKNOWN;
    }
}