Package java.net

Examples of java.net.Authenticator


            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


        final String authTestUrl = "http://localhost:" + server.getPort()
                + Support_HttpServer.AUTHTEST;

        // Authentication test
        // set up a very simple authenticator
        Authenticator.setDefault(new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("test", "password"
                        .toCharArray());
            }
        });
View Full Code Here

                lock.wait();
            } catch (InterruptedException e) {
                // ignored
            }
        }
        Authenticator.setDefault(new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                synchronized (lock) {
                    result[0] = 1;
                }
                return null;
            }
        });
        Authenticator.setDefault(new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                synchronized (lock) {
                    result[0] = 2;
                }
                return null;
View Full Code Here

        }
    }

    public void testProxyAuthorization() throws Exception {
        // Set up test Authenticator
        Authenticator.setDefault(new Authenticator() {
            @Override
            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

            // 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 void install() {
        // We will try to use the original authenticator as backup authenticator.
        // Since there is no getter available, so try to use some reflection to
        // obtain it. If that doesn't work, assume there is no original authenticator
        Authenticator original = null;
       
        try {
            Field f = Authenticator.class.getDeclaredField("theAuthenticator");
            f.setAccessible(true);
            original = (Authenticator) f.get(null);
View Full Code Here

               .getPort());
         Proxy proxy = new Proxy(config.getType(), addr);

         final Optional<Credentials> creds = config.getCredentials();
         if (creds.isPresent()) {
            Authenticator authenticator = new Authenticator() {
               public PasswordAuthentication getPasswordAuthentication() {
                  return new PasswordAuthentication(creds.get().identity, creds.get().credential.toCharArray());
               }
            };
            Authenticator.setDefault(authenticator);
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

            // 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

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.