/* * $Header: /cvshome/build/org.osgi.service.useradmin/src/org/osgi/service/useradmin/User.java,v 1.8 2006/06/16 16:31:41 hargrave Exp $ * * Copyright (c) OSGi Alliance (2001, 2006). All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.osgi.service.useradmin; import java.util.Dictionary; /** * A User role managed by a User Admin service. * *

* In this context, the term "user" is not limited to just human * beings. Instead, it refers to any entity that may have any number of * credentials associated with it that it may use to authenticate itself. *

* In general, User objects are associated with a specific User Admin * service (namely the one that created them), and cannot be used with other * User Admin services. *

* A User object may have credentials (and properties, inherited from * the {@link Role}class) associated with it. Specific * {@link UserAdminPermission}objects are required to read or change a * User object's credentials. *

* Credentials are Dictionary objects and have semantics that are * similar to the properties in the Role class. * * @version $Revision: 1.8 $ */ public interface User extends Role { /** * Returns a Dictionary of the credentials of this User * object. Any changes to the returned Dictionary object will * change the credentials of this User object. This will cause a * UserAdminEvent object of type * {@link UserAdminEvent#ROLE_CHANGED}to be broadcast to any * UserAdminListeners objects. * *

* Only objects of type String may be used as credential keys, * and only objects of type String or of type byte[] * may be used as credential values. Any other types will cause an exception * of type IllegalArgumentException to be raised. * *

* In order to retrieve a credential from the returned Dictionary * object, a {@link UserAdminPermission}named after the credential name (or * a prefix of it) with action getCredential is required. *

* In order to add or remove a credential from the returned * Dictionary object, a {@link UserAdminPermission}named after * the credential name (or a prefix of it) with action * changeCredential is required. * * @return Dictionary object containing the credentials of this * User object. */ public Dictionary getCredentials(); /** * Checks to see if this User object has a credential with the * specified key set to the specified value. * *

* If the specified credential value is not of type * String or byte[], it is ignored, that is, * false is returned (as opposed to an * IllegalArgumentException being raised). * * @param key The credential key. * @param value The credential value. * * @return true if this user has the specified credential; * false otherwise. * * @throws SecurityException If a security manager exists and the caller * does not have the UserAdminPermission named after the * credential key (or a prefix of it) with action * getCredential. */ public boolean hasCredential(String key, Object value); }