title: Java applet is not supporting the Authenticator.setDefault
body: <p>I want to do simple HTTP authentication in a Java applet, which I am trying this way:</p>
  
  <pre><code>static class MyAuthenticator extends Authenticator
          {
              public PasswordAuthentication getPasswordAuthentication()
                  {
              // I haven't checked getRequestingScheme() here, since for NTLM
              // and Negotiate, the usrname and password are all the same.
              System.err.println("Feeding username and password for " + getRequestingScheme());
              return (new PasswordAuthentication(kuser, kpass.toCharArray()));
              }
          }
      public void paint(Graphics g) {
          try
          {
          //  String authenticate=Authenticator.getPasswordAuthentication();
               Authenticator.setDefault(new MyAuthenticator());
               URL url = new URL("http://Ip_address/jpg/image.jpg");
               InputStream ins = url.openConnection().getInputStream();
               BufferedReader reader = new BufferedReader(new InputStreamReader(ins));
               String str;
                 while((str = reader.readLine()) != null)
                    System.out.println(str);
  
            //int s=2+2;
  
              g.drawString("hello world", 50, 60 );
          }
          catch (Exception e)
          {
              System.out.println("Exception : "+ e);
          }
      }
  </code></pre>
  
  <p>But I am getting error at this line</p>
  
  <pre><code>Authenticator.setDefault(new MyAuthenticator());
  </code></pre>
  
  <p>The exception is: </p>
  
  <pre><code>Exception : java.security.AccessControlException: access denied 
      (java.net.NetPermission setDefaultAuthenticator)
  </code></pre>
  
  <p>Can anyone tell me that what to do now, or how to authenticate a website inside from Java applet?</p>