Package java.net

Examples of java.net.Authenticator


                }
                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


        if ("http".equalsIgnoreCase(protocol) || "https".equalsIgnoreCase(protocol)) {
            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

         throw new IllegalArgumentException("No negative connection timeout" + connTimeoutMillis);
      }

      if (System.getProperty("http.proxyUser") != null)
      {
         Authenticator.setDefault(new Authenticator()
         {

            protected PasswordAuthentication getPasswordAuthentication()
            {
               return (new PasswordAuthentication(System.getProperty("http.proxyUser"), System.getProperty("http.proxyPassword").toCharArray()));
View Full Code Here

      System.setProperty("http.proxyPort", Global.getProxyValue("port")) ;
      System.setProperty("https.proxyHost",Global.getProxyValue("url")) ;
      System.setProperty("https.proxyPort", Global.getProxyValue("port")) ;
      if (Global.getProxyValue("userid").equals("")) {
        Authenticator.setDefault(new Authenticator() {
          @Override
          protected PasswordAuthentication getPasswordAuthentication() {
            return new
            PasswordAuthentication(Global.getProxyValue("userid"),Global.getProxyValue("password").toCharArray());
            }
View Full Code Here

        System.setProperty("http.proxySet", "true");
        System.setProperty("http.proxyHost", host);
            System.setProperty("http.proxyPort", port);
            setStatus("MANUAL PROXY");
      }
      Authenticator.setDefault(new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
              return new PasswordAuthentication(username, password.toCharArray());
          }
      });
    }else{
View Full Code Here

        }
       
        if (userName != null) {
            final String user = userName;
            final String pass = password == null ? "" : password;
            Authenticator.setDefault(new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(user, pass.toCharArray());
                }
            });
        }
View Full Code Here

                final String userName = proxy.getUsername();
                if ( !StringUtils.isEmpty( userName ) )
                {
                    final String pwd = StringUtils.isEmpty( proxy.getPassword() ) ? "" : proxy.getPassword();
                    Authenticator.setDefault( new Authenticator()
                    {
                        /** {@inheritDoc} */
                        protected PasswordAuthentication getPasswordAuthentication()
                        {
                            return new PasswordAuthentication( userName, pwd.toCharArray() );
View Full Code Here

                }
            } catch (Exception e) {
                pauth = null;
            }
        }
        Authenticator cxfauth = auth.get();
        if (cxfauth == null) {
            try {
                Authenticator.setDefault(wrapped);
            } catch (Throwable t) {
                //ignore
View Full Code Here

    public CXFAuthenticator() {
    }

    public static synchronized void addAuthenticator() {
        if (!setup) {
            Authenticator wrapped = null;
            for (final Field f : Authenticator.class.getDeclaredFields()) {
                if (f.getType().equals(Authenticator.class)) {
                    ReflectionUtil.setAccessible(f);
                    try {
                        wrapped = (Authenticator)f.get(null);
                    } catch (Exception e) {
                        //ignore
                    }
                }
            }
           
            try {
                InputStream ins = ReferencingAuthenticator.class.getResourceAsStream("ReferencingAuthenticator.class");
                final byte b[] = IOUtils.readBytesFromStream(ins);
                ClassLoader loader = new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader());
                Method m = ClassLoader.class.getDeclaredMethod("defineClass", String.class,
                                                               byte[].class, Integer.TYPE, Integer.TYPE);
                ReflectionUtil.setAccessible(m).invoke(loader, ReferencingAuthenticator.class.getName(),
                                                       b, 0, b.length);
                Class<?> cls = loader.loadClass(ReferencingAuthenticator.class.getName());
                Authenticator auth = (Authenticator)cls.getConstructor(Authenticator.class, Authenticator.class)
                    .newInstance(INSTANCE, wrapped);
               
                Authenticator.setDefault(auth);
            } catch (Throwable t) {
                //ignore
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

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.