Package java.net

Examples of java.net.PasswordAuthentication


    username = user;
    password = pass;
  }

  protected PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication(username, password.toCharArray());
  }
View Full Code Here


        this.now = System.currentTimeMillis();

        if (p_user != null && p_pass != null)
            Authenticator.setDefault(new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication
                        (p_user, p_pass.toCharArray());
                } });
    }
View Full Code Here

          jd.dispose();
        }
      });
      jd.pack();
      jd.setVisible(true);
      return new PasswordAuthentication (username.getText(), password.getText().toCharArray());
    }
View Full Code Here

        System.getProperties().put("http.proxyPort", "3128");
        final String userName = JOptionPane.showInputDialog("Enter UserName");
        final String password = JOptionPane.showInputDialog("Enter Password");
        class MyAuthenticator extends Authenticator {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(
                        userName, password.toCharArray());
            }
        }
        Authenticator.setDefault(new MyAuthenticator());
    }
View Full Code Here

        System.getProperties().put("http.proxyPort", "3128");
        final String userName = JOptionPane.showInputDialog("Enter UserName");
        final String password = JOptionPane.showInputDialog("Enter Password");
        class MyAuthenticator extends Authenticator {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(
                        userName, password.toCharArray());
            }
View Full Code Here

            this.pass=""; // prevent NPE later
    }

    @Override
    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(user,pass.toCharArray());
    }
View Full Code Here

                prompt = challenge.substring(realm, end);
            }
        }
        // The following will use the user-defined authenticator to get
        // the password
        PasswordAuthentication pa = Authenticator.requestPasswordAuthentication(
                getHostAddress(), getHostPort(), url.getProtocol(), prompt, scheme);
        if (pa == null) {
            // could not retrieve the credentials
            return null;
        }
        // base64 encode the username and password
        byte[] bytes = (pa.getUserName() + ":" + new String(pa.getPassword()))
                .getBytes("ISO8859_1");
        String encoded = Base64.encode(bytes, "ISO8859_1");
        return scheme + " " + encoded;
    }
View Full Code Here

        this.username = user;
        this.password = password;
    }
   
    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(username, password);
    }
View Full Code Here

    this.password = password;
    String content = "";
    try {
      Authenticator.setDefault(new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication(getUsername(), getPassword().toCharArray());
        }
      });
      URLConnection urlCon = (new URL(url)).openConnection();
      BufferedReader in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()));
      String line;
View Full Code Here

            setup = true;
        }
    }
   
    protected PasswordAuthentication getPasswordAuthentication() {
        PasswordAuthentication auth = null;
        if (wrapped != null) {
            try {
                for (Field f : Authenticator.class.getDeclaredFields()) {
                    if (!Modifier.isStatic(f.getModifiers())) {
                        f.setAccessible(true);
                        f.set(wrapped, f.get(this));
                    }
                }
                Method m = Authenticator.class.getMethod("getPasswordAuthentication");
                m.setAccessible(true);
                auth = (PasswordAuthentication)m.invoke(wrapped);
            } catch (Throwable t) {
                //ignore
            }
        }
        if (auth == null) {
            Message m = PhaseInterceptorChain.getCurrentMessage();
            Exchange exchange = m.getExchange();
            Conduit conduit = exchange.getConduit(m);
            if (conduit instanceof HTTPConduit) {
                HTTPConduit httpConduit = (HTTPConduit)conduit;
                if (getRequestorType() == RequestorType.PROXY
                    && httpConduit.getProxyAuthorization() != null) {
                    String un = httpConduit.getProxyAuthorization().getUserName();
                    String pwd =  httpConduit.getProxyAuthorization().getPassword();
                    if (un != null && pwd != null) {
                        auth = new PasswordAuthentication(un, pwd.toCharArray());
                    }
                } else if (getRequestorType() == RequestorType.SERVER
                    && httpConduit.getAuthorization() != null) {
                    String un = httpConduit.getAuthorization().getUserName();
                    String pwd =  httpConduit.getAuthorization().getPassword();
                    if (un != null && pwd != null) {
                        auth = new PasswordAuthentication(un, pwd.toCharArray());
                    }
                }
            }
        }
        return auth;
View Full Code Here

TOP

Related Classes of java.net.PasswordAuthentication

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.