Session getPasswordAuthentication Example

Session class getPasswordAuthentication example. This example shows you how to use getPasswordAuthentication method.


Session class getPasswordAuthentication example. public PasswordAuthentication getPasswordAuthentication(URLName url) Return any saved PasswordAuthentication for this (store or transport) URLName. Normally used only by store or transport implementations.

Here is the code
/*
 * @ # GetPasswordAuthentication.java
 * A class repersenting use to GetPasswordAuthentication method 
 * of Session class in javax.mail package
 * version 07 July 2008
 * author Rose India 
 */
package session;

import java.util.*;
import javax.mail.*;

public class GetPasswordAuthentication {

    public static void main(String args[]) throws Exception {

        Properties properties = System.getProperties();

        Session session = Session.getDefaultInstance(properties, null);

        URLName url = new URLName("pop3://test@192.168.10.205");
        
        session.setPasswordAuthentication(url, new PasswordAuthentication("test""test"));

        System.out.println("User Name : " + session.getPasswordAuthentication(url).getUserName());
        System.out.println("User password : " + session.getPasswordAuthentication(url).getPassword());
    }
}

Output
User Name : test
User password : test

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US