01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.pageflow.handler;
20:
21: import javax.security.auth.login.LoginException;
22: import java.security.Principal;
23:
24: /**
25: * Handler for login/logout/roles.
26: */
27: public interface LoginHandler extends Handler {
28: /**
29: * Log in the given user.
30: *
31: * @param username the user to log in.
32: * @param password the user's password.
33: * @throws LoginException if the login fails.
34: */
35: public void login(FlowControllerHandlerContext context,
36: String username, String password) throws LoginException;
37:
38: /**
39: * Log out the current user.
40: *
41: * @param invalidateSessions if <code>true</code>, current sessions associated with the current
42: * logged-in user will be invalidated.
43: */
44: public void logout(FlowControllerHandlerContext context,
45: boolean invalidateSessions);
46:
47: /**
48: * Tell whether the current user is in a given role.
49: *
50: * @param roleName the role to check.
51: * @return <code>true</code> if there is a current logged-in user who is in the given role.
52: */
53: public boolean isUserInRole(FlowControllerHandlerContext context,
54: String roleName);
55:
56: /**
57: * Get the current user.
58: *
59: * @return a {@link Principal} that represents the current logged-in user, or <code>null</code> if there is no
60: * logged-in user.
61: */
62: public Principal getUserPrincipal(
63: FlowControllerHandlerContext context);
64: }
|