1 package org.jahia.services.webdav; 2 3 import org.jahia.utils.keygenerator.JahiaKeyGen; 4 5 import java.util.Map ; 6 import java.util.HashMap ; 7 8 15 public class LocalHTTPAuth { 16 17 private static LocalHTTPAuth instance; 18 19 private Map authTokens = new HashMap (); 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 createUserToken(String user) { 32 String newTok = JahiaKeyGen.getKey(10); 33 authTokens.put(newTok, user); 34 return newTok; 35 } 36 37 public boolean checkUserToken(String user, String token) { 38 return user.equals(authTokens.get(token)); 39 } 40 41 } 42 | Popular Tags |