KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > vfs > utils > DAVCredentialsCache


1 package com.sslexplorer.vfs.utils;
2
3 import java.util.HashMap JavaDoc;
4 import java.util.Map JavaDoc;
5
6 import com.sslexplorer.security.PasswordCredentials;
7
8 /**
9  * <p>
10  * A class to hold a stores authentication credentials.
11  *
12  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
13  *
14  */

15 public class DAVCredentialsCache {
16
17     Map JavaDoc cache;
18
19     /**
20      * Constructor
21      */

22     public DAVCredentialsCache() {
23         this.cache = new HashMap JavaDoc();
24     }
25
26     /**
27      * <p>
28      * Add a set of credentials for the named mount.
29      *
30      * @param store The store name.
31      * @param name The moujnt name
32      * @param credentials The credentials to be cashed.
33      */

34     public void addCredentials(String JavaDoc store, String JavaDoc name, PasswordCredentials credentials) {
35         if (cache.containsKey(store)) {
36             Map JavaDoc storeMap = (Map JavaDoc) cache.get(store);
37             storeMap.put(name, credentials);
38         } else {
39             cache.put(store, new HashMap JavaDoc());
40             this.addCredentials(store, name, credentials);
41         }
42     }
43
44     /**
45      * <p>
46      * Get the names DAVCredentials.
47      *
48      * @param store The store name.
49      * @param name The moujnt name
50      * @return The requested DAVCredentials.
51      */

52     public PasswordCredentials getDAVCredentials(String JavaDoc store, String JavaDoc name) {
53         Map JavaDoc storeMap = (Map JavaDoc) cache.get(store);
54         if (storeMap != null)
55             return (PasswordCredentials) storeMap.get(name);
56         else
57             return null;
58     }
59
60 }
61
Popular Tags