KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > vfs > authentication > AbstractAuthenticationStore


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.vfs.authentication;
20
21 import java.net.URI JavaDoc;
22 import java.util.HashMap JavaDoc;
23
24 /**
25  * Abstract class which all authentication stores must extend.
26  *
27  * @author Matthew Large
28  * @version $Revision: 1.1 $
29  *
30  */

31 public abstract class AbstractAuthenticationStore {
32
33     /**
34      * Map of uri to {@link AuthInfo} objects.
35      */

36     protected HashMap JavaDoc m_auths = new HashMap JavaDoc();
37
38     public AbstractAuthenticationStore() {
39         super();
40     }
41     
42     /**
43      * Returns authentication information for a specified URI.
44      *
45      * @param uri URI for which to get authentication information
46      * @return The authentication information for the requested URI or null is none could be found
47      */

48     public AuthInfo getAuthentication(URI JavaDoc uri) {
49         return this.getAuthentication(uri.toString());
50     }
51     
52     /**
53      * Returns authentication information for a specified URI.
54      *
55      * @param URI for which to get authentication information
56      * @return The authentication information for the requested URI or null is none could be found
57      */

58     protected AuthInfo getAuthentication(String JavaDoc sURI) {
59         AuthInfo authInfo = null;
60         
61         if( this.m_auths.containsKey(sURI) ) {
62             authInfo = (AuthInfo)this.m_auths.get(sURI);
63         }
64         
65         return authInfo;
66     }
67     
68     /**
69      * Adds authentication information for a specific URI to the internal store.
70      *
71      * @param uri URI to store authentication information for
72      * @param authInfo Authentication information for the URI
73      */

74     public void addAuthentication(URI JavaDoc uri, AuthInfo authInfo) {
75         this.m_auths.put(uri.toString(), authInfo);
76     }
77
78 }
79
Popular Tags