KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > url > IvyAuthenticator


1 /*
2  * This file is subject to the license found in LICENCE.TXT in the root directory of the project.
3  *
4  * version 1.3.1
5  */

6 package fr.jayasoft.ivy.url;
7
8 import java.net.Authenticator JavaDoc;
9 import java.net.PasswordAuthentication JavaDoc;
10
11 import fr.jayasoft.ivy.util.Credentials;
12 import fr.jayasoft.ivy.util.Message;
13
14 /**
15  *
16  * @author Christian Riege
17  * @author Xavier Hanin
18  */

19 public final class IvyAuthenticator extends Authenticator JavaDoc {
20
21
22     /**
23      * The sole instance.
24      */

25     public final static IvyAuthenticator INSTANCE = new IvyAuthenticator();
26
27     /**
28      * Private c'tor to prevent instantiation. Also installs this as the default
29      * Authenticator to use by the JVM.
30      */

31     private IvyAuthenticator() {
32         // Install this as the default Authenticator object.
33
Authenticator.setDefault(this);
34     }
35
36     // API ******************************************************************
37

38     // Overriding Authenticator *********************************************
39

40     protected PasswordAuthentication JavaDoc getPasswordAuthentication() {
41         Credentials c = CredentialsStore.INSTANCE.getCredentials(getRequestingPrompt(), getRequestingHost());
42         Message.debug("authentication: k='"+Credentials.buildKey(getRequestingPrompt(), getRequestingHost())+"' c='" + c + "'");
43         return c != null ? new PasswordAuthentication JavaDoc(c.getUserName(), c.getPasswd().toCharArray()) : null;
44     }
45
46
47 }
48
Popular Tags