# Overriding java methods in Igntion scripts

**URL:** <https://forum.inductiveautomation.com/t/overriding-java-methods-in-igntion-scripts/10457>\
**Category:** Ignition\
**Created:** [September 14, 2015, 2:15pm UTC](https://forum.inductiveautomation.com/t/overriding-java-methods-in-igntion-scripts/10457 "2015-09-14T14:15:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [September 14, 2015, 2:15pm UTC](https://forum.inductiveautomation.com/t/overriding-java-methods-in-igntion-scripts/10457/1 "2015-09-14T14:15:54Z")

</div>

I need to do a http get to download files on a server that is using authentication so I am trying to use the [setDefaultAuthenticator](http://docs.oracle.com/javase/7/docs/api/java/net/Authenticator.html#setDefault(java.net.Authenticator)) method of java.net.Authneticator. To do this I will need to override the [getPasswordAuthentication](http://docs.oracle.com/javase/7/docs/api/java/net/Authenticator.html#getPasswordAuthentication()) method of the Authenticator class.

My problem is that I have no idea of how to do that in script. Can anyone provide a simple example of overriding a method using scripting within Ignition?

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [September 14, 2015, 3:49pm UTC](https://forum.inductiveautomation.com/t/overriding-java-methods-in-igntion-scripts/10457/2 "2015-09-14T15:49:31Z")

</div>

This seems to have done the trick:

```auto
username = "someuser"
password = "apassword"

class MyAuthenticator(Authenticator):
    def getPasswordAuthentication():
        return PasswordAuthentication(username, password.toCharArray())

m = MyAuthenticator()
```

The way to override a method apparently is to subclass the existing class with the original method in it; add a method to your subclass with the name of the method that you want to override. And then of course instantiate an instance of your subclass.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 14, 2015, 3:50pm UTC](https://forum.inductiveautomation.com/t/overriding-java-methods-in-igntion-scripts/10457/3 "2015-09-14T15:50:32Z")

</div>

Yep, you’ve got it. ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")
