1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.services;
18
19
20 import org.apache.turbine.services.TurbineServices;
21
22
23 import org.apache.jetspeed.om.security.JetspeedUser;
24 import org.apache.jetspeed.services.security.PortalAuthentication;
25 import org.apache.jetspeed.services.security.LoginException;
26
27
28 /***
29 * Static accessor for the JetspeedAuthentication service
30 *
31 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
32 * @version $Id: JetspeedAuthentication.java,v 1.4 2004/02/23 04:00:57 jford Exp $
33 */
34 public abstract class JetspeedAuthentication
35 {
36 /***
37 * Given a public credential(username) and private credential(password),
38 * perform authentication. If authentication succeeds, a <code>JetspeedUser</code>
39 * is returned representing the authenticated subject.
40 *
41 * @param username a public credential of the subject to be authenticated.
42 * @param password a private credentialof the subject to be authenticated.
43 * @return a <code>JetspeedUser</code> object representing the authenticated subject.
44 * @exception LoginException when general security provider failure.
45 * @exception FailedLoginException when the authentication failed.
46 * @exception AccountExpiredException when the subject's account is expired.
47 * @exception CredentialExpiredException when the subject's credential is expired.
48 */
49 public static JetspeedUser login(String username, String password)
50 throws LoginException
51 {
52 return getService().login(username, password);
53 }
54
55 /***
56 * Automatically authenticates and retrieves the portal anonymous user.
57 *
58 * @return a <code>JetspeedUser</code> object representing the authenticated subject.
59 * @exception LoginException if the authentication fails.
60 */
61 public static JetspeedUser getAnonymousUser()
62 throws LoginException
63 {
64 return getService().getAnonymousUser();
65 }
66
67 /***
68 * Logout the <code>JetspeedUser</code>.
69 *
70 * The logout procedure my may include removing/destroying
71 * <code>Principal</code> and <code>Credential</code> information
72 * if relevant to the security provider.
73 *
74 * @exception LoginException if the logout fails.
75 */
76 public static void logout()
77 throws LoginException
78 {
79 getService().logout();
80 }
81
82
83
84
85
86
87
88 protected static PortalAuthentication getService()
89 {
90 return (PortalAuthentication)TurbineServices
91 .getInstance().getService(PortalAuthentication.SERVICE_NAME);
92 }
93
94
95 }
96
97