Hello,
I’m writing a new implemation of AuthProvider. I’m adding it as a jar file in the /lib of my Openfire.
I need to access to properties which are set inside the database (in ofproperty).
I’ve checked how Openfire instantiates new AuthProvider and I found the following code:
private static void initProvider(final Class clazz) {
// Check if we need to reset the auth provider class
if (authProvider == null || !clazz.equals(authProvider.getClass())) {
try {
authProvider = (AuthProvider)clazz.newInstance();
}
catch (Exception e) {
Log.error("Error loading auth provider: " + clazz.getName(), e);
authProvider = new DefaultAuthProvider();
}
}
}
So in the constructor of my new class, I added some calls to JiveGlobals.getProperty(“x.y.z”):
String myParam= JiveGlobals.getProperty(x.y.z);
if (myParam==null)
throw new Exception("property x.y.z not available");
But at Openfire startup, the exception is thrown, the property is not available:
2019.07.04 17:52:40 INFO [main]: org.jivesoftware.openfire.XMPPServer - Accessing SystemProperty field org.jivesoftware.openfire.auth.AuthFactory#PASSWORD_KEY
2019.07.04 17:52:40 ERROR [main]: com.my.example - MyNewAuthProviderImpl() No MyParam available, Impossible to use this authentication method.
2019.07.04 17:52:40 ERROR [main]: org.jivesoftware.openfire.auth.AuthFactory - Error loading auth provider: com.my.example
java.lang.Exception: Missing or incorrect parameter: x.y.z
at com.my.example.<init>(MyNewAuthProviderImpl.java:62) ~[InternalChatAuthLib-1.0-shaded.jar:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_191]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_191]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_191]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_191]
at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_191]
at org.jivesoftware.openfire.auth.AuthFactory.initProvider(AuthFactory.java:79) [xmppserver-4.4.0-SNAPSHOT.jar:4.4.0-SNAPSHOT]
at org.jivesoftware.openfire.auth.AuthFactory.<clinit>(AuthFactory.java:71) [xmppserver-4.4.0-SNAPSHOT.jar:4.4.0-SNAPSHOT]
at sun.misc.Unsafe.ensureClassInitialized(Native Method) ~[?:1.8.0_191]
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43) [?:1.8.0_191]
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156) [?:1.8.0_191]
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088) [?:1.8.0_191]
at java.lang.reflect.Field.getFieldAccessor(Field.java:1069) [?:1.8.0_191]
at java.lang.reflect.Field.get(Field.java:393) [?:1.8.0_191]
at org.jivesoftware.openfire.XMPPServer.scanForSystemPropertyClasses(XMPPServer.java:739) [xmppserver-4.4.0-SNAPSHOT.jar:4.4.0-SNAPSHOT]
at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:708) [xmppserver-4.4.0-SNAPSHOT.jar:4.4.0-SNAPSHOT]
at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:263) [xmppserver-4.4.0-SNAPSHOT.jar:4.4.0-SNAPSHOT]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_191]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [?:1.8.0_191]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [?:1.8.0_191]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [?:1.8.0_191]
at java.lang.Class.newInstance(Class.java:442) [?:1.8.0_191]
at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:92) [startup.jar:4.4.0-SNAPSHOT]
at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) [startup.jar:4.4.0-SNAPSHOT]
What am I missing there ?