Custom Realm: read properties from customRealm.yml


(Jathin) #1

Basic difference between the CustomRealmPlugin in 2.x to CustomRealmExtension in 5.x is that now an instance needs to be provided instead of a class ref. previously realms were able to inject its own configurations by reading some yml file. but with 5.x restructuring i am unable to figure out how to read custom properties into a realm. These properties will be in a custom yml file in installed dir.

Also need to figure out whats the best way to get install dir so that i can load my properties via the realm.

any sample code would be of great help. i was reading https://github.com/elastic/shield-custom-realm-example, but it does not have that example.


(Jay Modi) #2

Each realm is provided a RealmConfig which provides the Enviornment. From the environment you can resolve the configDir and then read your file from there.


(Jathin) #3

And now i am getting this error.

java.security.AccessControlException: access denied ("java.io.FilePermission" ".\src\test\resources\abc.jks" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:884)


(Jathin) #4

I am just running my plugin via junits.. So i am not sure where to place my plugin-security.policy file or should it be a different file.


(Jathin) #5

I saw this thread.


it says about updating custom realm example to add some permissions, and updating documents as well.

Can you share where it is updated.


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.