Examples of Authenticator


Examples of java.net.Authenticator

 
  public void
  installAuthenticator()
  {
    Authenticator.setDefault(
        new Authenticator()
        {
          protected AEMonitor  auth_mon = new AEMonitor( "SESecurityManager:auth");
         
          protected PasswordAuthentication
          getPasswordAuthentication()
View Full Code Here

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.toCharArray() );
View Full Code Here

Examples of java.net.Authenticator

    }
   
    public static synchronized void addAuthenticator() {
        if (instance == null) {
            instance = new CXFAuthenticator();
            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);
                        if (wrapped != null
                            && wrapped.getClass().getName().equals(ReferencingAuthenticator.class.getName())) {
                            Method m = wrapped.getClass().getMethod("check");
                            m.setAccessible(true);
                            m.invoke(wrapped);
                        }
                        wrapped = (Authenticator)f.get(null);
                    } catch (Exception e) {
                        //ignore
                    }
                }
            }
           
            try {
                ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                        public ClassLoader run() {
                            return new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader());
                        }
                    }, null);
               
               
                Method m = ClassLoader.class.getDeclaredMethod("defineClass", String.class,
                                                               byte[].class, Integer.TYPE, Integer.TYPE);
               
                InputStream ins = ReferencingAuthenticator.class
                        .getResourceAsStream("ReferencingAuthenticator.class");
                byte b[] = IOUtils.readBytesFromStream(ins);
               
                ReflectionUtil.setAccessible(m).invoke(loader, ReferencingAuthenticator.class.getName(),
                                                       b, 0, b.length);
                Class<?> cls = loader.loadClass(ReferencingAuthenticator.class.getName());
                final Authenticator auth = (Authenticator)cls.getConstructor(Authenticator.class, Authenticator.class)
                    .newInstance(instance, wrapped);
               
                if (System.getSecurityManager() == null) {
                    Authenticator.setDefault(auth);
                } else {
View Full Code Here

Examples of java.net.Authenticator

        this.socksPort = socksPort;

        if (StringUtils.hasText(user)) {
            final PasswordAuthentication auth = new PasswordAuthentication(user, pass.toCharArray());

            Authenticator.setDefault(new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return auth;
                }
            });
View Full Code Here

Examples of java.net.Authenticator

   * @return true if the Authenticator was set successfully.
   */
  public boolean setProxyAuthentication() {
    if (m_httpProxy != null && m_proxyUsername != null &&
        m_proxyPassword != null) {
      Authenticator.setDefault(new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
          return new
             PasswordAuthentication(m_proxyUsername,m_proxyPassword.toCharArray());
      }});
      return true;
View Full Code Here

Examples of javax.mail.Authenticator

          Properties mailProperties = System.getProperties();
          mailProperties.put("mail.smtp.host", smtp_host);
          if(smtp_port>0 && smtp_port!=25)
              mailProperties.put("mail.smtp.port", String.valueOf(smtp_port));
          mailProperties.put("mail.smtp.auth", "true"); //����smtp��֤���ܹؼ���һ��
          mailSession = Session.getDefaultInstance(mailProperties, new Authenticator(){
        protected PasswordAuthentication getPasswordAuthentication() {
              return new PasswordAuthentication(smtp_user, smtp_pass);
        }});
    }
    else{
View Full Code Here

Examples of javax.mail.Authenticator

    if (smtpHost != null)
    {
      props.put("mail.smtp.host", smtpHost);
    }

    Authenticator auth = null;
   
    if (this.getSmtpUsername() != null)
    {
      auth = new UsernamePasswordAuthenticator(
                    this.getSmtpUsername(),
View Full Code Here

Examples of javax.mail.Authenticator

    props.put("mail.smtp.host", host);
    if (mUser != null)
    {
      props.put("mail.smtp.auth", "true");
    }
    Authenticator auth = new MyAuthenticator();
    Session session = Session.getInstance(props, auth);
    try
    {
      /*
       * Creating the message
View Full Code Here

Examples of javax.mail.Authenticator

   protected void startService() throws Exception
   {
      // Setup password authentication
      final PasswordAuthentication pa = new PasswordAuthentication(getUser(), getPassword());
      Authenticator a = new Authenticator()
      {
         protected PasswordAuthentication getPasswordAuthentication()
         {
            return pa;
         }
View Full Code Here

Examples of javax.mail.Authenticator

   
    Properties properties = new Properties();// 创建Properties对象
    properties.setProperty("mail.transport.protocol", "smtp");// 设置传输协议
    properties.put("mail.smtp.host", "smtp.163.com");// 设置发信邮箱的smtp地址
    properties.setProperty("mail.smtp.auth", "true"); // 验证
    Authenticator auth = new AjavaAuthenticator(emailName,
        emailPassword); // 使用验证,创建一个Authenticator
    Session session = Session.getDefaultInstance(properties, auth);// 根据Properties,Authenticator创建Session
    Message message = new MimeMessage(session);// Message存储发送的电子邮件信息
    message.setFrom(new InternetAddress(fromEmail));
    message.setRecipient(Message.RecipientType.TO, new InternetAddress(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.