User Admin Extension

The User Admin Extension bundle delivers functionality additional to User Admin Bundle, for management of groups and users.

Contents:


Bundle Information

Bundle JAR

The JAR file of the User Admin Extension bundle is usradmex.jar and is located in the bundles directory.

Import

Package Exporter Description
com.prosyst.util.io System Bundle/
ProSyst Util Full Bundle
Contains the I/O utilities of the ProSyst Util Bundle. The User Manager Bundle uses them for object serialization.
com.prosyst.util.pcommands ProSyst Util Bundle/
ProSyst Util Full Bundle
Contains utilities, allowing commands in the ua command group to be added to the Parser service.
com.prosyst.util.ref Holds the log utility exported by the ProSyst Util Bundle.
org.osgi.service.useradmin OSGi Library Bundle Contains the components of the OSGi User Admin Service API, which are exported by the OSGi Library Bundle and are implemented by the User Admin Bundle.

Export

The UserAdmin Extension bundle exports the com.prosyst.mbs.services.useradmin package, which holds interfaces providing functionality additional to the OSGi defined role based authorization system.


Overview

The User Admin Extension bundle provides functionality specific for the ProSyst implementation of the UserAdmin service defined by the OSGi specification. It registers two services - a Simple Login service and a Pluggable Commands service. The first provides methods for easier user authorization and the second allows user management through the framework console.

When the User Admin Extension bundle is started, it gets a reference to the User Admin service of the User Admin Bundle and generates an initial roles structure as follows:

The "administration" group holds roles with administrative rights. The admin user represents the default user role for this group. This user can create other users and assign to them the necessary rights. The password of admin is recorded as a credential, named password, with admin value. The creation of this initial administrator user is controlled by two system properties - mbs.useradmin.default.username, mbs.useradmin.default.password, described the "System Properties" section.

In case the User Admin service is not registered, a user can login as anonymous. This is possible only if the mbs.useradmin.anonymousConnect system property is true, and the user name is null or an empty String. In case the system property is set to false, on attempt to login, a java.lang.Exception is thrown.


Services

Simple Login

The Simple Login service supports user login to the ProSyst mBS framework and therefore, it is a simple mechanism for authentication to the framework's user management system. After a user successfully logs in, bundles can examine its authorization parameters. The Simple Login service is represented by the com.prosyst.mbs.services.useradmin.SimpleLogin interface. Authorization for this service is delivered by com.prosyst.mbs.services.useradmin.Authorization which extends the org.osgi.service.useradmin.Authorization. In addition to checking the roles of a requester, it allows user logout.

Note: To enable login of miscellaneous users, framework administrators should assign passwords to them as credentials.

Note: Developers can retrieve the format of the password credential from the SimpleLogin.PASSWORD field. The username property is accessible through SimpleLogin.USERNAME.

The code snippet that follows logs in the initial user admin and checks whether it owns the "administration" role.

                      . . .
  BundleContext bc;
  String userName = "admin";
  String password = "admin";
                      . . .
  ServiceReference sLoginRef = bc.getServiceReference(SimpleLogin.class.getName());
  SimpleLogin sLogin = (SimpleLogin) bc.getService(sLoginRef);
  Authorization autho = sLogin.login(userName, password);
  boolean okFlag = autho.hasRole("administration");  

  if(okFlag) {
    System.out.println("The user is an administrator!"); 
  }

  autho.logout();
Listing 1: Logging in the ProSyst mBS.

The Simple Login service also allows developers to pass authorization information to bundles that restrict the access to their resources. A carrier of such information can be a data stream or a thread. By using the service, you can attach an Authorization object to an intermediary object that will handle it from the User Admin Extension bundle to another application. The methods you can use for associating Authorization objects are getAuthorization and setAuthorization.

The functionality of the services and utilities above can be accessed partially over PMP. Remote PMP Services can refer to and invoke only the methods of the com.prosyst.mbs.services.useradmin.UserAdminRemote interface, implemented by the Simple Login service object.

Pluggable Commands

The User Admin Extension bundle registers a PluggableCommands service under the com.prosyst.util.pcommands.PluggableCommands interface, which adds the ua console command group. See below the description of the commands.


Console Commands

Command Shortcut Description

list [options] [<role>]

ls Lists all roles. If a specific role is given as a parameter, only the public information for this role will be listed.
-t, -T Tree view.
-u, -U Lists only users.
-g, -G Lists only groups.

put [options] <role> <name> [<value>]

- Puts/updates the value of a property/credential with the given name, for the specified role. If a new value is not specified, then an empty string or byte array will be added.
-c, -C Identifies that a credential is being set.
-b, -B The property/credential is of type byte array.
-d, -D The value is in DEC format. This option is used only for byte arrays: {byte {byte}}
If this property is not specified, the format is HEX: {XX {XX}}
-s, -S The value is a String format (only for byte-arrays). The specified String will be converted into byte-array

get [options] <role> [<name>]

- Gets the value of the property/credential with the given name, of the specified Role/User. If a name is not specified all properties/credentials will be listed.
-c, -C Get the credentials for the role.
-d, -D Print byte-arrays in DEC format.

remove [option] <role> <name>

rem Removes the Property/Credential with the given name, of the specified Role/User.
-c, -C Remove a credential.

create <option> <name>

new Creates a new User or Group. An option should be specified.
-u, -U Creates a new User.
-g, -G Creates a new Group.

destroy <role>

- Deletes the specified Role.

addmember [option] <group> <role>

addm Adds the specified Role to the specified Group.
-r, -R Adds the member as a required.

Tip: You may use the list -t command to check for cycles.

removemember <group> <role>

remm Removes the specified Role from the specified Group.

setuseradmin [<service ID>]

setua Lists all OSGi User Admin services and identifies the one currently subject to modification by the ua command group.
If a parameter specified - changes the OSGi User Admin service controlled by the ua command group to the one with the given service ID.

authorization <user>

autho Prints all roles currently implied by the specified User.


Configuration

Visual Administration

The User Admin Extension bundle provides a custom property editor for configuration of roles - groups and users, through mConsole application. The editor offers to administrators a user-friendly interface to create and remove new users and groups and modify their relationships.

To activate the property editor of the User Admin Extension bundle:

  1. Start the ProSyst mBS.
  2. Start mConsole and connect to the server.
  3. To load the property editor, locate the osgi/User Admin Extension node in the bundle tree, and unfold it to see the User Admin Configuration.

Initially, the "administration" group and the admin user are displayed because they are automatically created at bundle's startup.

The following topics are discussed in the current chapter:

Viewing Existing Roles

The property editor is separated into two main panels - a Roles panel to the left, where all roles are listed - in tree or list view, according to the current settings, and an Info panel to the right, where details about the currently selected role are displayed.

User Manager Service Options
Figure 1: The Custom Property Editor of the User Admin Extension Bundle - List View

Figure 2: Tree View

Roles Panel. There are two views of the property editor - as a tree and as a list, which are relevant to the left pane only. The view is controlled by the leftmost button at the bottom, which toggles its name according to the current view - to List View when the roles are displayed as a tree and Tree View otherwise. To refresh the user tree, mainly if some users are added by another server administrator or by a bundle in a program way, use the Refresh button.

The property editor allows creating loops of membership. For example: if the group java_programmers is a member of the group mBServer and also has this group as a member, then a membership loop is present. In tree view this case is presented as one of the groups is added as a leaf node and no members of it are displayed, because it is already present up in the tree, where all of its members are listed.


Figure 3: Membership Loop

Note: Though creating membership loops is allowed, it is strongly recommended loops of required members to be avoided. Users, that are members of groups that participate in a loop of required members, never have access when membership in one of this groups is required.

Info Panel. The right pane, which is also separated in two, displays details about the item selected in the left. The top panel shows details about its membership, and the lower - its properties.

Managing Roles

Role management is performed in the left, Roles panel. The way of management depends on the selected view. In both views you may use the provided buttons or the pop-up menu.

Tree View. Six buttons are available on the top of the Roles panel in tree view.

Icon Name Active Description
Create new user Always. Opens a dialog box, where the properties of the new user must be entered.
Add existing user Only when a group is selected. Opens a dialog box listing all existing users, thus allowing you to add the user as a member of the group, which was selected when the dialog was invoked.
Remove user Only when a user is selected. Terminates the membership of this user, in the group.
Create new group Always. Opens a dialog box, where properties of the new group must be added.
Add existing group Only when a group is selected. Opens a dialog box, where all existing groups are listed. Groups may be added as required or basic members of the currently selected one.
Remove group Only when a group is selected, which is a member of another group. The membership of the group in the one, represented by the parent node, is canceled.

These actions are available as commands in a pop-up menu, invoked on the subject node. The pop-up menu is identical for all nodes, only the activity of its items is different according to the selection.

Pop-up Menu Icon Name Active Analogous Button Description
Create User Always. Create new user Creates a new user.
Create Group Always. Create new group Creates a new group.
Add User Group is selected. Add existing user Adds a user as a member to the selected group.
Add Group Group is selected. Add existing group Adds a group as a member of the selected one.
Remove When a role (user or group), member of another role, is selected. Remove user/
Remove group
Removes the selected role from the membership list of the role, represented by the parent node.
- Destroy Always. - After applying this command to a role, the role will no longer exist.
- Change Password User is selected. - Issues a dialog for changing the user password.

List view. In list view user and group management is separated, the way their visual representation is. The buttons above the upper panel and the panel's pop-up menu control the users list. The bottom panel and the buttons above it, manage the groups. Both lists react to double click on a particular item, which action brings up a membership dialog.

Users:

Pop-up Menu Icon Name Description
Add New User Creates a new user. Also available as a button.
- Edit User Membership Opens a dialog box, in which the list of groups, where the user is a member, may be edited. Available at double click on the user entry.
Destroy User Deletes the user from the user list. Available as a button.
- Change Password Changes the user password.

Groups:

Pop-up Menu Icon Name Description
Add New Group Creates a new group. Also available as a button.
- Edit Members Allows adding/removing users/groups as members of this group. Available at double click on the group entry.
Destroy Group Deletes the group from the group list. Available as a button.

Management Tasks

Create User. A user may be created in several ways:

The following dialog box appears when a new user is being created:

Figure 5: Create a New User

The Create user dialog consists of two tabs. Only the User Name and password fields from the first tab are compulsory to be filled in.

Create Group. A new group may be created in the following ways:

When a new group is created, the following dialog must be filled in:


Figure 6: Creating a New Group

Enter the new Group Name and then optionally select which of the existing users should participate in the new group and to which of the groups the new one will be a basic and/or required member.

Add an Existing User to a Group. You can attach a user to many groups, as each group suggests a different level of authorization. In this way, the user obtains more roles for access to certain resources. To add an existing user as a member to an existing group, you may do the following:

Add Existing Group as a Member. To add group1 as a member of group2:

Cancel User Membership. To remove a user from the members list of a group you may:

Cancel Group Membership. To remove group1 from the members list of another group2, do one of the following:

Destroy a User. When you destroy a user, it is deleted from the users database.

Destroy a Group. To delete a group:

System Properties

System Property Default Value Description
mbs.sm true

Turns on/off the Security Manager, implemented by the User Admin Extension bundle. Can be used only if the mbs.xuseradmin.sm system property is true.

When setting the mbs.useradmin.automatic system property to true under JDK 1.1, this property must be set to false.

mbs.useradmin.anonymousConnect false Turns on/off connecting to the framework with user-defined user name and password. When set to true, it switches off basic authentication. It should be enabled when the UserAdmin service of the UserAdmin Bundle is NOT available in the Framework. Then a user will always be able to log into a system requiring user authentication.
mbs.useradmin.automatic false Defines whether the authorization object received during login, will be associated with the current thread.
mbs.useradmin.default.username admin Determines the name of the default administrator user.
mbs.useradmin.default.password admin

Determines the password of the default administrator user.

Note: The value of this system property must be the SHA1 hash code of the password. For example: the SHA1 hash code of the "admin" password is D033E22AE348AEB5660FC2140AEC35850C4DA997. The code must be 40 characters long, each byte represented by two hexadecimal characters.

mbs.useradmin.createAnonymous false Indicates if to create a universal user account with name "anonymous" and empty password on registering the UserAdmin service in the Framework.
mbs.xuseradmin.sm false Turns on/off the Security Manager, implemented by the User Admin Extension bundle, which allows passing authorization information through threads.
mbs.xuseradmin.debug.onconsole false Turns on/off printing log information in the framework's text console. To enable generation of debug logs, set the mbs.util.ref.log.debug system property to true prior to starting the framework.

To use successfully the above system properties, you have to set them:


Troubleshooting

The User Admin Extension does not depend on the UserAdmin Bundle, but it uses the User Admin service. If the UserAdmin Bundle is not running in the framework, thus preventing the registration of the User Admin service, you can only log-in if the mbs.useradmin.anonymousConnect system property is set to true.

If you uninstall the User Admin Extension while in eager update mode, the PMP bundle also stops. Then, when you install the User Admin Extension again, you must start the PMP bundle manually. If you do not start it, you will not be able to log through remote applications, like mConsole.


References


OSGi Bundles