KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > atlassian > seraph > auth > AbstractAuthenticator


1 package com.atlassian.seraph.auth;
2
3 import com.atlassian.seraph.config.SecurityConfig;
4
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6 import javax.servlet.http.HttpServletResponse JavaDoc;
7 import java.io.Serializable JavaDoc;
8 import java.util.Map JavaDoc;
9 import java.security.Principal JavaDoc;
10
11 /**
12  * An abstract implementation of Authenticator that implements a lot of base methods
13  */

14 public abstract class AbstractAuthenticator implements Authenticator, Serializable JavaDoc
15 {
16     private Map JavaDoc params;
17     private SecurityConfig config;
18
19     public void init(Map JavaDoc params, SecurityConfig config)
20     {
21         this.params = params;
22         this.config = config;
23     }
24
25     public void destroy()
26     {
27     }
28
29     /** @deprecated Use {@link RoleMapper} directly */
30     public abstract boolean isUserInRole(HttpServletRequest JavaDoc request, String JavaDoc role);
31
32     public String JavaDoc getRemoteUser(HttpServletRequest JavaDoc request)
33     {
34         Principal JavaDoc user = getUser(request);
35
36         if (user == null)
37             return null;
38
39         return user.getName();
40     }
41
42     public Principal JavaDoc getUser(HttpServletRequest JavaDoc request)
43     {
44         return getUser(request, null);
45     }
46
47     public abstract Principal JavaDoc getUser(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response);
48
49     public boolean login(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, String JavaDoc username, String JavaDoc password) throws AuthenticatorException
50     {
51         return login(request, response, username, password, false);
52
53     }
54
55     public abstract boolean login(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, String JavaDoc username, String JavaDoc password, boolean cookie) throws AuthenticatorException;
56
57     public abstract boolean logout(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws AuthenticatorException;
58
59     protected SecurityConfig getConfig() {
60         return config;
61     }
62 }
63
Popular Tags