How to check Secret password in DeviceExtensionPoint

Ignition 8.3

I try to check a password parameter has the minimal lenght in a DeviceExtensionPoint

But at gateway startup I have a NPE on opcua module, on line Secret.create(deviceContext.getGatewayContext() because the deviceContext is NULL.

How can we retrieve the GatewayContext in validate method ?

or is there another way th chceck the password length ?

```
public class MyDevice3ExtensionPoint extends DeviceExtensionPoint {

@Override
protected Device createDevice(
        DeviceContext context, DeviceProfileConfig profileConfig, DeviceDriverSNMPV3SettingsResource deviceConfig) {
        
    deviceContext = context;
    deviceDriver = new DeviceDriverSNMPV3(context,deviceConfig);

    return deviceDriver;
}

...

@Override
protected void validate(DeviceDriverSNMPV3SettingsResource config, Builder errors) {
    try {

        errors.checkField
                (Secret.create(deviceContext.getGatewayContext(), config.PrivPassphrase()).getPlaintext().getAsString().length()>=8,
                "Privacy.PrivProtocol",
                "PrivProtocol requires to have a minimum length of 8 bytes."
        );
    } catch (SecretException e) {
        throw new RuntimeException(e);
    }
}

```


Try passing a GatewayContext into your DeviceExtensionPoint when you create it. I think AbstractDeviceModuleHook::getGatewayHook will be non-null by the time getExtensionPoints() is called.

Otherwise you'll have to do what many modules do and store a globally available reference to the GatewayContext that you can retrieve from parts of your module. You are given a GatewayContext in GatewayModuleHook::setup.