Show TOC

User Management Functions for RolesLocate this document in the navigation structure

Prerequisites

  • You have referenced the user management development component tc/je/usermanagement/api in your project.

    More information: Defining Development Component Dependencies .

  • For any functions that require write access to attributes, you have configured the relevant data sources of the UME for read-write access.

  • For the purpose of the example class, you have created a user with the user ID demo_user.

Context

This section provides an example of how to add user management functions for roles. The functions provided here address primarily user management engine (UME) roles. You can use some functions to manage portal roles, such as the search and assignment functions.

This section demonstrates the following functions:

  • Creating roles

  • Assigning users to roles

  • Editing role attributes

  • Searching for roles

  • Displaying roles

  • Deleting roles

Procedure

  1. Import the required interfaces: com.sap.security.api.* .
  2. Get the required factories.

    Use the following table to determine the factories you need.

    Factory

    When Required

    Method to Get

    IGroupFactory

    To assign groups to roles

    getGroupFactory()

    IPrincipalFactory

    To access role attributes not directly available through the role factory or perform a simple search

    getPrincipalFactory()

    IRoleFactory

    Always

    getRoleFactory()

    IUserFactory

    To assign users to roles

    getUserFactory()

  3. Add methods for the required functions.

Example

This code example provides a framework for you to plug in the example code from the role tasks in the sections that follow. This class imports the required interfaces, sets up the role management methods, and gets the required factories of the UME API.

            package com.example;

  

public class RoleTest {
        
        public static void main() {
                init();
                createRole(
, 
);
                modifyRole_setAssignment(
, 
);
                modifyRole_additionalAttribute(
, 
, 
,
                 
);
                roleStandardSearch(
,  
, 
);
                roleSimpleSearch(
);
                showRole(
, 
, 
);
                // searchRoles();
                deleteRole(
);
                } 

        // TODO: Add the method for the role function you want to test.         
        
// ------------------------------------------------------------------------------------------
        
        /*
         * You need the user factory for role assignment.
         * You need the principal factory for reading and editing role attributes.
         */
        
        static IUserFactory userFactory;  
        static IRoleFactory roleFactory;
        static IPrincipalFactory principalFactory;      
                
        public static void init() {
                // Get the factories.
                

                

                
    
        }

}