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: package org.apache.cocoon.auth;
18:
19: import java.util.Iterator;
20:
21: /**
22: * This object represents the current user. Each user must have a unique
23: * identifier (per {@link org.apache.cocoon.auth.SecurityHandler}).
24: * For session replication, the implementation should be {@link java.io.Serializable}.
25: *
26: * @version $Id: User.java 433543 2006-08-22 06:22:54Z crossley $
27: */
28: public interface User {
29:
30: /**
31: * Return the unique id of this user.
32: * @return The identifier.
33: */
34: String getId();
35:
36: /**
37: * Set an information about the user.
38: * For session replication the value of the attribute should
39: * be {@link java.io.Serializable}.
40: * @param key The key identifying the information.
41: * @param value The value of the information.
42: */
43: void setAttribute(String key, Object value);
44:
45: /**
46: * Remove an information about the user.
47: * @param key The key identifying the information.
48: */
49: void removeAttribute(String key);
50:
51: /**
52: * Get information about the user.
53: * @param key The key identifying the information.
54: * @return The value or null.
55: */
56: Object getAttribute(String key);
57:
58: /**
59: * Return all available names.
60: * @return An Iterator for the names (Strings).
61: */
62: Iterator getAttributeNames();
63:
64: /**
65: * Check if the user is in a given role.
66: * This method can't check for a role handled by the servlet engine,
67: * it only handles indendently specified roles.
68: * Therefore, it is advisable to not call this method directly, but
69: * use the provided methods from the {@link ApplicationUtil} instead.
70: *
71: * @param role The role to test.
72: * @return Returns true if the user has the role, otherwise false.
73: */
74: boolean isUserInRole(String role);
75: }
|