# Custom Realm: read properties from customRealm.yml

**URL:** <https://discuss.elastic.co/t/custom-realm-read-properties-from-customrealm-yml/88325>\
**Category:** Elasticsearch\
**Created:** [June 5, 2017, 7:41pm UTC](https://discuss.elastic.co/t/custom-realm-read-properties-from-customrealm-yml/88325 "2017-06-05T19:41:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jathin](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@Jathin](https://discuss.elastic.co/u/Jathin)\
**Post date:** [June 5, 2017, 7:41pm UTC](https://discuss.elastic.co/t/custom-realm-read-properties-from-customrealm-yml/88325/1 "2017-06-05T19:41:32Z")

</div>

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](https://github.com/elastic/shield-custom-realm-example), but it does not have that example.

---

<div class="post-metadata">

**Author:** ![jaymode](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaymode/32/50103_2.png) [@jaymode](https://discuss.elastic.co/u/jaymode)\
**Post date:** [June 5, 2017, 8:22pm UTC](https://discuss.elastic.co/t/custom-realm-read-properties-from-customrealm-yml/88325/2 "2017-06-05T20:22:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jathin](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@Jathin](https://discuss.elastic.co/u/Jathin)\
**Post date:** [June 5, 2017, 10:39pm UTC](https://discuss.elastic.co/t/custom-realm-read-properties-from-customrealm-yml/88325/3 "2017-06-05T22:39:47Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Jathin](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@Jathin](https://discuss.elastic.co/u/Jathin)\
**Post date:** [June 5, 2017, 10:41pm UTC](https://discuss.elastic.co/t/custom-realm-read-properties-from-customrealm-yml/88325/4 "2017-06-05T22:41:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jathin](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@Jathin](https://discuss.elastic.co/u/Jathin)\
**Post date:** [June 7, 2017, 10:02pm UTC](https://discuss.elastic.co/t/custom-realm-read-properties-from-customrealm-yml/88325/5 "2017-06-07T22:02:41Z")

</div>

I saw this thread.

> [@How to customize plugin-security.policy for custom realm](https://discuss.elastic.co/t/how-to-customize-plugin-security-policy-for-custom-realm/71570):
>
> I have a custom realm that uses OkHttpClient. When it is instantiated, it calls ProxySelector.getDefault() which requires 'permission java.net.NetPermission "getProxySelector"'. This is not granted to x-pack, so it breaks the realm. I tried editing the plugin policy for x-pack after the fact and it sort of works. Is that the best approach? When I try to do this using a customized Elasticsearch docker image, it fails (I have a Dockerfile that installs the x-pack, the realm, and then updates the x…

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

Can you share where it is updated.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:02pm UTC](https://discuss.elastic.co/t/custom-realm-read-properties-from-customrealm-yml/88325/6 "2017-07-05T22:02:51Z")

</div>

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