Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
<ph type="x-smartling-placeholder">
Beginnen wir mit den Grundlagen. Hier ist eine informelle Definition von Registry:
Aber:
Dennoch kann es hilfreich sein, diese Klasse zu verstehen, um
effizient mit Tink arbeiten.
Was passiert, wenn du getPrimitive() für einen Keyset-Handle aufrufst? Es leitet Ihre
Rufen Sie die Registry1 auf, die Objekte mit konkreten Methoden zum Erstellen
Schlüssel und Primitive, z. B. ein
AesGcm-Schlüssel oder eine ChunkedMac-Instanz. Die Aufgabe der Registry ist, den Aufruf weiterzuleiten.
zum richtigen Objekt hinzufügen. Dies funktioniert nur, wenn das Objekt registriert ist.
ist es wichtig, die zu verwendenden Primitive immer zu registrieren.
Aber was ist, wenn ich eine Bibliothek verwende, in der die benötigten Primitive bereits registriert sind?
Genau das ist das Problem. Und einer der Gründe, warum Registry entfernt wird.
In diesem Fall funktioniert Ihr Code nur so lange,
bis die Bibliotheksautoren sich dafür entscheiden,
können wir diese Primitive
nicht mehr registrieren. An dieser Stelle funktioniert der Code nicht mehr
nicht offensichtlich und verwirrend. Registrieren Sie also immer, was Sie
verwenden. Wenn Sie beispielsweise MAC in Ihrem Java-Code verwenden möchten, sollten Sie
in der Einrichtungsphase folgende Schritte ausführen:
MacConfig.register()
Dieser Code stellt sicher, dass alle erforderlichen Objekte im
für die Verwendung der MAC-Primitive erforderlich.
Es gibt eine weitere Seite zu diesem Problem. Einige Ihrer Abhängigkeiten werden möglicherweise registriert
Dinge, die Sie eigentlich nicht brauchen
und auf die Sie sich nicht verlassen möchten. Dies ist
einen weiteren Grund
für die Entfernung der globalen Registry.
zur globalen Singleton-Instanz der Klassen-Registry. Wir verwenden den Namen "Registry". die Klasse und den Singleton austauschbar. ↩
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-07-25 (UTC)."],[[["\u003cp\u003eThe Registry in Tink is a global entity responsible for generating new keys and primitives, but it is intended for internal use only and is slated for removal.\u003c/p\u003e\n"],["\u003cp\u003eThe Registry forwards calls from \u003ccode\u003egetPrimitive()\u003c/code\u003e to objects that create keys and primitives, and these objects must be registered for the process to work.\u003c/p\u003e\n"],["\u003cp\u003eIt's essential to explicitly register the primitives you intend to use (e.g., \u003ccode\u003eMacConfig.register()\u003c/code\u003e), to ensure your code works consistently and doesn't rely on the unpredictable behavior of other libraries.\u003c/p\u003e\n"],["\u003cp\u003eRelying on other libraries to register primitives can lead to unexpected code breakage if the library's registration practices change, making it crucial to self-manage registrations.\u003c/p\u003e\n"]]],["The Registry is a global entity in Tink for generating keys and primitives, but it's slated for removal and should not be directly accessed. `getPrimitive()` calls are forwarded to the Registry, which then creates the correct object, if registered. It is crucial to register the primitives one intends to use directly, using method like `MacConfig.register()`, because relying on library registration leads to code fragility and unwanted dependencies. The class is considered for removal.\n"],null,["# Registry\n\n| This page describes an area that undergoes a major redesign at the moment. The status depends on the programming language used.\n\nStarting with the basics, here is an informal definition of Registry:\n| **Key Term:** **Registry** is a global entity in Tink that knows how to generate new keys and primitives.\n\nBut:\n| **Warning:** This class is intended to be used only by internal interfaces. You should NOT call its methods directly, but instead access them through higher level APIs like KeysetHandle.\n| **Warning:** This class is going to be removed.\n\nThat being said, it may be useful to understand this class in order to work\nwith Tink efficiently for the time being.\n\nWhat happens when you call `getPrimitive()` on a keyset handle? It forwards your\ncall to the Registry^[1](#fn1)^, which contains objects with concrete methods to create\nkeys and [*primitives*](/tink/design/primitives_and_interfaces), such as an\nAesGcm key or a ChunkedMac instance. The Registry's task is to forward the call\nto the correct object. This only works if the object is registered, which is why\n**it's important to always register the primitives you are going to use**.\n\nBut what if I use a library that already registered the primitives I need?\n--------------------------------------------------------------------------\n\nThat's precisely the problem. And one of the reasons Registry is being removed.\nBecause in this case your code works only until the library authors decide to\nnot register that primitive anymore. At this point your code breaks, and the\nreason is non-obvious and confusing. So **always register what you\nuse**. For example, if you intend you use MAC in your Java code, you should do\nthe following in the setup phase: \n\n```java\nMacConfig.register()\n```\n\nThis code ensures that all the necessary objects are registered in the\nnecessary places for you to use the MAC primitive.\n\nThere is one more side to this problem. Some of your dependencies may register\nthings you actually don't need and would prefer to not depend on. This is\nanother reason to remove the global Registry. \n\n*** ** * ** ***\n\n1. to the global singleton instance of the class Registry, to be precise. We use the name \"Registry\" for both, the class and the singleton, interchangeably. [↩](#fnref1)"]]