KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > webdav > LocalHTTPAuth


1 package org.jahia.services.webdav;
2
3 import org.jahia.utils.keygenerator.JahiaKeyGen;
4
5 import java.util.Map JavaDoc;
6 import java.util.HashMap JavaDoc;
7
8 /**
9  * Created by IntelliJ IDEA.
10  * User: toto
11  * Date: Jul 7, 2003
12  * Time: 11:43:43 AM
13  * To change this template use Options | File Templates.
14  */

15 public class LocalHTTPAuth {
16
17     private static LocalHTTPAuth instance;
18
19     private Map JavaDoc authTokens = new HashMap JavaDoc();
20
21     private LocalHTTPAuth() {
22     }
23
24     public static synchronized LocalHTTPAuth getInstance() {
25             if (instance == null) {
26                 instance = new LocalHTTPAuth();
27             }
28         return instance;
29     }
30
31     public String JavaDoc createUserToken(String JavaDoc user) {
32         String JavaDoc newTok = JahiaKeyGen.getKey(10);
33         authTokens.put(newTok, user);
34         return newTok;
35     }
36
37     public boolean checkUserToken(String JavaDoc user, String JavaDoc token) {
38         return user.equals(authTokens.get(token));
39     }
40
41 }
42
Popular Tags