1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.services;
1819// Turbine20import org.apache.turbine.services.TurbineServices;
2122// Jetspeed23import org.apache.jetspeed.om.security.JetspeedUser;
24import org.apache.jetspeed.services.security.PortalAuthentication;
25import org.apache.jetspeed.services.security.LoginException;
262728/***29 * Static accessor for the JetspeedAuthentication service30 *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 */34publicabstractclassJetspeedAuthentication35 {
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 */49publicstaticJetspeedUser login(String username, String password)
50 throws LoginException51 {
52return getService().login(username, password);
53 }
5455/***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 */61publicstaticJetspeedUser getAnonymousUser()
62 throws LoginException63 {
64return getService().getAnonymousUser();
65 }
6667/***68 * Logout the <code>JetspeedUser</code>.69 *70 * The logout procedure my may include removing/destroying71 * <code>Principal</code> and <code>Credential</code> information72 * if relevant to the security provider.73 *74 * @exception LoginException if the logout fails.75 */76publicstaticvoid logout()
77 throws LoginException78 {
79 getService().logout();
80 }
8182/*83 * Utility method for accessing the service84 * implementation85 *86 * @return a UniqueIdService implementation instance87 */88protectedstaticPortalAuthentication getService()
89 {
90return (PortalAuthentication)TurbineServices
91 .getInstance().getService(PortalAuthentication.SERVICE_NAME);
92 }
939495 }
9697