org.apache.felix.useradmin.impl
Class UserAdminServiceImpl

java.lang.Object
  extended by org.apache.felix.useradmin.impl.UserAdminServiceImpl
All Implemented Interfaces:
ServiceFactory, UserAdmin

public class UserAdminServiceImpl
extends Object
implements UserAdmin, ServiceFactory

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.

Version:
$Rev$ $Date$
See Also:
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)
           
 void destroy()
           This method is closing UserAdmin resources.
 CredentialAuthenticator getAuthenticator()
          This method returns CredentialAuthenticator instance.
 Authorization getAuthorization(User user)
           
 UserAdminEventDispatcher getEventAdminDispatcher()
          This method returns UserAdminEvent dispatcher.
 UserAdminRepositoryManager getRepositoryManager()
          This method returns repository manager instance.
 Role getRole(String name)
           
 Role[] getRoles(String filter)
           
 Object getService(Bundle bundle, ServiceRegistration reg)
           
 ServiceReference getServiceRef()
          This method returns ServiceReference for this service needed for UserAdminEvent.
 User getUser(String key, String value)
           
 UserAdminPermission getUserAdminPermission()
          This method returns UserAdminPermission with name admin.
 boolean isAlive()
          Checks if UserAdmin service is alive.
 boolean removeRole(String name)
           
 void setServiceRef(ServiceReference serviceRef)
          This method is used for setting ServiceReference of this service.
 void ungetService(Bundle bundle, ServiceRegistration reg, Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserAdminServiceImpl

public UserAdminServiceImpl(BundleContext bc,
                            UserAdminRepositoryManager repositoryManager,
                            Logger logger,
                            UserAdminEventDispatcher dispatcher)
This constructor is creating new UserAdmin service.

Parameters:
bc - BundleContext of a bundle which creating this service instance.
repositoryManager - repository manager.
logger - Logger instance.
dispatcher - UserAdmin event dispatcher instance.
Method Detail

createRole

public Role createRole(String name,
                       int type)
Specified by:
createRole in interface UserAdmin
See Also:
UserAdmin.createRole(String, int)

checkPermission

public void checkPermission(UserAdminPermission permission)
Checking permission with security manager. If the caller thread doesn't have permission it throwing SecurityException.

Parameters:
permission - UserAdminPermission for which check will e performed.
See Also:
SecurityManager.checkPermission(java.security.Permission)

getAuthorization

public Authorization getAuthorization(User user)
Specified by:
getAuthorization in interface UserAdmin
See Also:
UserAdmin.getAuthorization(User)

getRole

public Role getRole(String name)
Specified by:
getRole in interface UserAdmin
See Also:
UserAdmin.getRole(String)

getRoles

public Role[] getRoles(String filter)
                throws InvalidSyntaxException
Specified by:
getRoles in interface UserAdmin
Throws:
InvalidSyntaxException
See Also:
UserAdmin.getRoles(String), Filter

getUser

public User getUser(String key,
                    String value)
Specified by:
getUser in interface UserAdmin
See Also:
UserAdmin.getUser(String, String)

removeRole

public boolean removeRole(String name)
Specified by:
removeRole in interface UserAdmin
See Also:
UserAdmin.removeRole(String)

getService

public Object getService(Bundle bundle,
                         ServiceRegistration reg)
Specified by:
getService in interface ServiceFactory
See Also:
ServiceFactory.ungetService(Bundle, ServiceRegistration, Object)

ungetService

public void ungetService(Bundle bundle,
                         ServiceRegistration reg,
                         Object obj)
Specified by:
ungetService in interface ServiceFactory
See Also:
ServiceFactory.ungetService(Bundle, ServiceRegistration, Object)

destroy

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.


isAlive

public boolean isAlive()
Checks if UserAdmin service is alive.

Returns:
true if service is alive or false if not.

setServiceRef

public void setServiceRef(ServiceReference serviceRef)
This method is used for setting ServiceReference of this service.

Parameters:
serviceRef - ServiceReference of this service.

getServiceRef

public ServiceReference getServiceRef()
This method returns ServiceReference for this service needed for UserAdminEvent.

Returns:
ServiceReference for this service.

getUserAdminPermission

public UserAdminPermission getUserAdminPermission()
This method returns UserAdminPermission with name admin.

Returns:
UserAdmingPermission with name admin.

getEventAdminDispatcher

public UserAdminEventDispatcher getEventAdminDispatcher()
This method returns UserAdminEvent dispatcher.

Returns:
UserAdminEventDispatcher
See Also:
UserAdminEventDispatcher

getRepositoryManager

public UserAdminRepositoryManager getRepositoryManager()
This method returns repository manager instance.

Returns:
repository manager instance.

getAuthenticator

public CredentialAuthenticator getAuthenticator()
This method returns CredentialAuthenticator instance.

Returns:
CredentialAuthenticator instance.


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.