<commit_before>-   [Home](../../index.md)
-   [Documentation](../index.md)
-   Inject Bytes into a Custom Protocol

Inject Bytes into a Custom Protocol  ![This feature is available in KAAZING Gateway - Enterprise Edition](images/enterprise-feature.png)
===========================================================================

In this procedure, you will learn how to inject bytes into a custom protocol.

Before You Begin
----------------

Learn about protocol injection in [About Protocol Injection](c_aaa_inject.md). To complete the steps in this topic, you must be familiar with the bytes (and the necessary encoding) that your back-end server requires.

To Inject Bytes into a Custom Protocol
--------------------------------------

1.  Create a new login module.

    Note: We recommend that you create a separate LoginModule specifically for the purpose of protocol injection. The steps in this topic assume that you already have an existing login module (either one supplied from the Gateway or one that you've created) that establishes the identity associated with this connection and authenticates it.

    In the login module, determine the identity or any other information you want to send to the back-end server. For example, you may want to inspect the Principals from other login modules in the chain to discover the identity associated with the client connection.

2.  Instantiate a new object of type `org.kaazing.gateway.server.spi.ProtocolInjection` and override the `getName()` and `getInjectableBytes()` methods.

    -   The `getName()` method should specify the name of this Principal to avoid conflicting with other Principals of the same type.
    -   The `getInjectableBytes()` returns the bytes which will be injected into the connection to the back-end server. The bytes must conform to the protocol that the server is expecting. Using this method, incorporate the identity or other information determined in step 1.
<commit_msg>Update p_aaa_inject.md<commit_after>-   [Home](../../index.md)
-   [Documentation](../index.md)
-   Inject Bytes into a Custom Protocol

Inject Bytes into a Custom Protocol  ![This feature is available in KAAZING Gateway - Enterprise Edition](images/enterprise-feature.png)
===========================================================================

In this procedure, you will learn how to inject bytes into a custom protocol.

Before You Begin
----------------

Learn about protocol injection in [About Protocol Injection](c_aaa_inject.md). To complete the steps in this topic, you must be familiar with the bytes (and the necessary encoding) that your back-end server requires.

To Inject Bytes into a Custom Protocol
--------------------------------------

1.  Create a new login module.

    Note: We recommend that you create a separate LoginModule specifically for the purpose of protocol injection. The steps in this topic assume that you already have an existing login module (either one supplied from the Gateway or one that you've created) that establishes the identity associated with this connection and authenticates it.

    In the login module, determine the identity or any other information you want to send to the back-end server. For example, you may want to inspect the Principals from other login modules in the chain to discover the identity associated with the client connection.

2.  Instantiate a new object of type `org.kaazing.gateway.server.spi.ProtocolInjection` and override the `getName()` and `getInjectableBytes()` methods.

    -   The `getName()` method should specify the name of this Principal to avoid conflicting with other Principals of the same type.
    -   The `getInjectableBytes()` returns the bytes which will be injected into the connection to the back-end server. The bytes must conform to the protocol that the server is expecting. Using this method, incorporate the identity or other information determined in step 1.
   
    See the [Protocol Injection](../apidoc/server/gateway/server/spi/index.html) documentation for more information.

{'fraction_non_alphanumeric': 0.11327739387956565, 'fraction_numerical': 0.0014807502467917078, 'mean_word_length': 3.865546218487395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5774345', 'n_tokens_mistral': 943, 'n_tokens_neox': 892, 'n_words': 523}