|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.useradmin.impl.UserAdminServiceImpl
public class UserAdminServiceImpl
This UserAdminServiceImpl class implementing a contract UserAdmin. It represents UserAdmin service is exposed as a OSGi service in the ServiceRegistry.
Its used to manage a database of named Role objects, which can be used for authentication and authorization purposes. This version of the User Admin service defines two types of Role objects: User and Group. Each type of role is represented by an int constant and an interface. The range of positive integers is reserved for new types of roles that may be added in the future. When defining proprietary role types, negative constant values must be used. Every role has a name and a type. A User object can be configured with credentials (e.g., a password) and properties (e.g., a street address, phone number, etc.). A Group object represents an aggregation of User and Group objects. In other words, the members of a Group object are roles themselves. Every User Admin service manages and maintains its own namespace of Role objects, in which each Role object has a unique name.
UserAdmin
,
ServiceFactory
,
UserAdminRepositoryManager
,
UserAdminEventDispatcher
Constructor Summary | |
---|---|
UserAdminServiceImpl(BundleContext bc,
UserAdminRepositoryManager repositoryManager,
Logger logger,
UserAdminEventDispatcher dispatcher)
This constructor is creating new UserAdmin service. |
Method Summary | |
---|---|
void |
checkPermission(UserAdminPermission permission)
Checking permission with security manager. |
Role |
createRole(String name,
int type)
Creates a Role object with the given name and of the given
type. |
void |
destroy()
This method is closing UserAdmin resources. |
CredentialAuthenticator |
getAuthenticator()
This method returns CredentialAuthenticator instance. |
Authorization |
getAuthorization(User user)
Creates an Authorization object that encapsulates the
specified User object and the Role objects it
possesses. |
UserAdminEventDispatcher |
getEventAdminDispatcher()
This method returns UserAdminEvent dispatcher. |
UserAdminRepositoryManager |
getRepositoryManager()
This method returns repository manager instance. |
Role |
getRole(String name)
Gets the Role object with the given name from this
User Admin service. |
Role[] |
getRoles(String filter)
Gets the Role objects managed by this User Admin service that
have properties matching the specified LDAP filter criteria. |
Object |
getService(Bundle bundle,
ServiceRegistration reg)
Creates a new service object. |
ServiceReference |
getServiceRef()
This method returns ServiceReference for this service needed for UserAdminEvent. |
User |
getUser(String key,
String value)
Gets the user with the given property key -value
pair from the User Admin service database. |
UserAdminPermission |
getUserAdminPermission()
This method returns UserAdminPermission with name admin. |
boolean |
isAlive()
Checks if UserAdmin service is alive. |
boolean |
removeRole(String name)
Removes the Role object with the given name from this User
Admin service and all groups it is a member of. |
void |
setServiceRef(ServiceReference serviceRef)
This method is used for setting ServiceReference of this service. |
void |
ungetService(Bundle bundle,
ServiceRegistration reg,
Object obj)
Releases a service object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UserAdminServiceImpl(BundleContext bc, UserAdminRepositoryManager repositoryManager, Logger logger, UserAdminEventDispatcher dispatcher)
bc
- BundleContext of a bundle which creating this service instance.repositoryManager
- repository manager.logger
- Logger instance.dispatcher
- UserAdmin event dispatcher instance.Method Detail |
---|
public Role createRole(String name, int type)
UserAdmin
Role
object with the given name and of the given
type.
If a Role
object was created, a UserAdminEvent
object of type UserAdminEvent.ROLE_CREATED
is broadcast to any
UserAdminListener
object.
createRole
in interface UserAdmin
name
- The name
of the Role
object to create.type
- The type of the Role
object to create. Must be
either a Role.USER
type or Role.GROUP
type.
Role
object, or null
if a
role with the given name already exists.UserAdmin.createRole(String, int)
public void checkPermission(UserAdminPermission permission)
permission
- UserAdminPermission for which check will e performed.SecurityManager.checkPermission(java.security.Permission)
public Authorization getAuthorization(User user)
UserAdmin
Authorization
object that encapsulates the
specified User
object and the Role
objects it
possesses. The null
user is interpreted as the anonymous user.
The anonymous user represents a user that has not been authenticated. An
Authorization
object for an anonymous user will be unnamed,
and will only imply groups that user.anyone implies.
getAuthorization
in interface UserAdmin
user
- The User
object to create an
Authorization
object for, or null
for the
anonymous user.
Authorization
object for the specified
User
object.UserAdmin.getAuthorization(User)
public Role getRole(String name)
UserAdmin
Role
object with the given name
from this
User Admin service.
getRole
in interface UserAdmin
name
- The name of the Role
object to get.
Role
object, or null
if this
User Admin service does not have a Role
object with
the given name
.UserAdmin.getRole(String)
public Role[] getRoles(String filter) throws InvalidSyntaxException
UserAdmin
Role
objects managed by this User Admin service that
have properties matching the specified LDAP filter criteria. See
org.osgi.framework.Filter
for a description of the filter
syntax. If a null
filter is specified, all Role objects
managed by this User Admin service are returned.
getRoles
in interface UserAdmin
filter
- The filter criteria to match.
Role
objects managed by this User Admin service
whose properties match the specified filter criteria, or all
Role
objects if a null
filter is specified.
If no roles match the filter, null
will be returned.
InvalidSyntaxException
- If the filter is not well formed.UserAdmin.getRoles(String)
,
Filter
public User getUser(String key, String value)
UserAdmin
key
-value
pair from the User Admin service database. This is a convenience method
for retrieving a User
object based on a property for which
every User
object is supposed to have a unique value (within
the scope of this User Admin service), such as for example a X.500
distinguished name.
getUser
in interface UserAdmin
key
- The property key to look for.value
- The property value to compare with.
null
is
returned.UserAdmin.getUser(String, String)
public boolean removeRole(String name)
UserAdmin
Role
object with the given name from this User
Admin service and all groups it is a member of.
If the Role
object was removed, a UserAdminEvent
object of type UserAdminEvent.ROLE_REMOVED
is broadcast to any
UserAdminListener
object.
removeRole
in interface UserAdmin
name
- The name of the Role
object to remove.
true
If a Role
object with the given name
is present in this User Admin service and could be removed,
otherwise false
.UserAdmin.removeRole(String)
public Object getService(Bundle bundle, ServiceRegistration reg)
ServiceFactory
The Framework invokes this method the first time the specified
bundle
requests a service object using the
BundleContext.getService(ServiceReference)
method. The
service factory can then return a specific service object for each
bundle.
The Framework caches the value returned (unless it is null
),
and will return the same service object on any future call to
BundleContext.getService
for the same bundle. This means the
Framework must not allow this method to be concurrently called for the
same bundle.
The Framework will check if the returned service object is an instance of
all the classes named when the service was registered. If not, then
null
is returned to the bundle.
getService
in interface ServiceFactory
bundle
- The bundle using the service.reg
- The ServiceRegistration
object for the
service.
ServiceFactory.ungetService(Bundle, ServiceRegistration, Object)
public void ungetService(Bundle bundle, ServiceRegistration reg, Object obj)
ServiceFactory
The Framework invokes this method when a service has been released by a bundle. The service object may then be destroyed.
ungetService
in interface ServiceFactory
bundle
- The bundle releasing the service.reg
- The ServiceRegistration
object for the
service.obj
- The service object returned by a previous call to the
ServiceFactory.getService
method.ServiceFactory.ungetService(Bundle, ServiceRegistration, Object)
public void destroy()
This method is closing UserAdmin resources. Should be used when UserAdmin service is unregistred. Alive flag is set to true, eventDispacther is closed and ServiceReference is set to null.
public boolean isAlive()
public void setServiceRef(ServiceReference serviceRef)
serviceRef
- ServiceReference of this service.public ServiceReference getServiceRef()
public UserAdminPermission getUserAdminPermission()
public UserAdminEventDispatcher getEventAdminDispatcher()
UserAdminEventDispatcher
public UserAdminRepositoryManager getRepositoryManager()
public CredentialAuthenticator getAuthenticator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |