Package java.net

Examples of java.net.Authenticator


            // create the HostnameVerifier to check that Hostname verification
            // is done
            TestHostnameVerifier hnv = new TestHostnameVerifier();
            HttpsURLConnection.setDefaultHostnameVerifier(hnv);

            Authenticator.setDefault(new Authenticator() {

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


            // create the HostnameVerifier to check that Hostname verification
            // is done
            TestHostnameVerifier hnv = new TestHostnameVerifier();
            HttpsURLConnection.setDefaultHostnameVerifier(hnv);

            Authenticator.setDefault(new Authenticator() {

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

            }
        };
    }

    public static Authenticator getAuthenticator() {
        return new Authenticator() {

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

            System.getProperties().put( "proxyHost", proxyHost );
            System.getProperties().put( "proxyPort", proxyPort );

            if ( proxyUserName != null )
            {
                Authenticator.setDefault( new Authenticator()
                {
                    protected PasswordAuthentication getPasswordAuthentication()
                    {
                        return new PasswordAuthentication( proxyUserName, proxyPassword == null ? new char[0]
                                                                                               : proxyPassword
View Full Code Here

    private void connect(Map<String, String> sessionParameters) {
        this.sessionParameters = sessionParameters;

        // set a new dummy authenticator
        // don't send previous credentials to another server
        Authenticator.setDefault(new Authenticator() {
        });

        if (Boolean.parseBoolean(sessionParameters.get(ACCEPT_SELF_SIGNED_CERTIFICATES))) {
            acceptSelfSignedCertificates();
        }
View Full Code Here

                }
                if (!StringUtils.isEmpty(proxy.getUsername())
                    && !StringUtils.isEmpty(proxy.getPassword())) {
                    final String authUser = proxy.getUsername();
                    final String authPassword = proxy.getPassword();
                    Authenticator.setDefault(new Authenticator() {
                        public PasswordAuthentication getPasswordAuthentication() {
                            return new PasswordAuthentication(authUser, authPassword.toCharArray());
                        }
                    });
View Full Code Here

    // -Dhttp.nonProxyHosts=*.domain.com|host.internal.net
   
    if (null != proxyUser && null != proxyPass) {
      LOG.info("Proxy authentication enabled");
     
      Authenticator.setDefault(new Authenticator() {
        @Override
        protected PasswordAuthentication getPasswordAuthentication() {
          return new PasswordAuthentication(proxyUser, proxyPass.toCharArray());
        }
      });
View Full Code Here

         ArrayList<Proxy> result = new ArrayList<Proxy>();
         result.add(new Proxy(Type.HTTP, new InetSocketAddress(proxySettings.getProxyHost(),
                  proxySettings.getProxyPort())));
         if (proxySettings.isAuthenticationSupported())
         {
            Authenticator.setDefault(new Authenticator()
            {
               protected PasswordAuthentication getPasswordAuthentication()
               {
                  return new PasswordAuthentication(proxySettings.getProxyUserName(),
                           proxySettings.getProxyPassword().toCharArray());
View Full Code Here

  }

  @Override
  public void open() throws IOException {
    // set username and pw used for fetching the url.
    Authenticator.setDefault(new Authenticator() {
      public PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(username, password.toCharArray());
      }
    });
    URL u = new URL(url);
View Full Code Here

                    }
                }
            }

            try {
                Authenticator.setDefault(new Authenticator() {
                    public PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication("test", "password"
                                .toCharArray());
                    }
                });
View Full Code Here

TOP

Related Classes of java.net.Authenticator

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.