Package java.net

Examples of java.net.PasswordAuthentication


            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.getDeclaredMethod("getPasswordAuthentication");
                m.setAccessible(true);
                auth = (PasswordAuthentication)m.invoke(wrapped);
            } catch (Throwable t) {
                //ignore
            }
        }
        if (auth != null) {
            return auth;
        }
        Message m = PhaseInterceptorChain.getCurrentMessage();
        if (m != null) {
            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());
                    }
                }
            }
        }
        // else PhaseInterceptorChain.getCurrentMessage() is null,
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())) //$NON-NLS-1$
                .getBytes("ISO8859_1"); //$NON-NLS-1$
        String encoded = Base64.encode(bytes, "ISO8859_1"); //$NON-NLS-1$
        return scheme + " " + encoded; //$NON-NLS-1$
    }
View Full Code Here

                } catch(InterruptedException ie) { }
            }
            if (!result)
                return null;

            return new PasswordAuthentication(userID, password);
        }
    }
View Full Code Here

                    + getRequestingPrompt());
        }
        if (getRequestorType().equals(RequestorType.PROXY)
                && proxyCredentials != null) {
            log.debug("Proxy request detected, returning proxy credentials");
            return new PasswordAuthentication(proxyCredentials.getUsername(),
                    proxyCredentials.getPasword());
        }
        if ("mail.google.com".equals(getRequestingHost())) {
            log.debug("Gmail request detected, returning login credentials");
            return new PasswordAuthentication(credentials.getUsername(),
                    credentials.getPasword());
        }
        log.debug("Unknown authentication request, will return nothing");
        return null;
    }
View Full Code Here

    }

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

    /**
     * Does authentication with the uddi registry
     */
    protected void login()
    {
        PasswordAuthentication passwdAuth = new PasswordAuthentication(userid,
                passwd.toCharArray());
        Set creds = new HashSet();
        creds.add(passwdAuth);

        try
View Full Code Here

            con = factory.createConnection();
        } catch (JAXRException e)
        {
            e.printStackTrace();
        }
        PasswordAuthentication passwdAuth = new PasswordAuthentication("jbosscts",
                passwd.toCharArray());
        Set creds = new HashSet();
        creds.add(passwdAuth);

        try
View Full Code Here

        final String user=httpUser;
        final String pw=httpPassword;
        Authenticator.setDefault(
          new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication() {
              return new PasswordAuthentication(user, pw.toCharArray());
            }
          }
        );
      }
    }
View Full Code Here

            this.password = password;
        }

        @Override
        public PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(this.username, this.password.toCharArray());
        }
View Full Code Here

        Credentials c = CredentialsStore.INSTANCE.getCredentials(getRequestingPrompt(),
            getRequestingHost());
        Message.debug("authentication: k='"
                + Credentials.buildKey(getRequestingPrompt(), getRequestingHost()) + "' c='" + c
                + "'");
        return c != null ? new PasswordAuthentication(c.getUserName(), c.getPasswd().toCharArray())
                : null;
    }
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.