Package org.apache.sling.serviceusermapping

## Interface ServiceUserMapper

    @ProviderType
    public interface ServiceUserMapper

The `ServiceUserMapper` service can be used to map a service provided by a bundle to the ID of a user account used to access the ResourceResolver used by the service to access its data.

The goal of this service is to allow services to be implemented accessing the storage with service-specific accounts which are tailored to allow the service appropriate access without requiring administrative level access to the storage.

In general a service is implement in a single bundle such as the JSP compiler bundle. Other services may be implemented in multiple bundles. In certain cases there may be sub-services requiring different access levels. For example a couple of bundles may implement a "mail" service where each bundle implements a part of the service such as the "smtp", "queuing", and "delivery" sub services. Such sub services are identified with the `subServiceName` parameter on the method calls.

In addition to allowing to phase out the use of `ResourceResolver.getAdministrativeResourceResolver` and `SlingRepository.loginAdministrative` it also allows to better account for changes to the storage by the different services.

This service is not intended to be used by the general user but by implementations of the `ResourceResolverFactory` and `SlingRepository` services.

This service is not intended to be implemented by clients.

See Also:
  Service Authentication

### Field Summary

Fields
`static String` `VALIDATOR_ID` Property to add as a unique id to a service registration.

### Method Summary

All Methods Instance Methods Abstract Methods Deprecated Methods
`List<Mapping>` `getActiveMappings()` Returns a list of all of the active mappings in the Service User Mapper.
`Iterable<String>` `getServicePrincipalNames​(org.osgi.framework.Bundle bundle, String subServiceName)` Returns the principal names to access the data store on behalf of the service.
`String` `getServiceUserID​(org.osgi.framework.Bundle bundle, String subServiceName)` Deprecated. Use `getServicePrincipalNames(Bundle, String)` instead.

### Field Detail

#### VALIDATOR_ID

    static final String VALIDATOR_ID

Property to add as a unique id to a service registration.

See Also:
  Constant Field Values

### Method Detail

#### getServiceUserID

    @Deprecated
    String getServiceUserID​(org.osgi.framework.Bundle bundle,
                            String subServiceName)

Deprecated.
Use `getServicePrincipalNames(Bundle, String)` instead.
Returns the ID of a user to access the data store on behalf of the service.

Parameters:
  `bundle` - The bundle implementing the service request access to resources.
  `subServiceName` - Name of the sub service. This parameter is optional and may be an empty string or `null`.
Returns:
  The ID of the user to use to provide access to the resources for the service. This may be `null` if no particular user can be derived for the service identified by the bundle and the optional `serviceInfo`.

#### getServicePrincipalNames

    Iterable<String> getServicePrincipalNames​(org.osgi.framework.Bundle bundle,
                                              String subServiceName)

Returns the principal names to access the data store on behalf of the service.

Parameters:
  `bundle` - The bundle implementing the service request access to resources.
  `subServiceName` - Name of the sub service. This parameter is optional and may be an empty string or `null`.
Returns:
  The principal names to use to provide access to the resources for the service. This may be `null` if no mapping has been defined for the service identified by the bundle and the optional `serviceInfo` or if no principal names have been specified with the mapping. In this case `getServiceUserID(Bundle, String)` should be used instead.

#### getActiveMappings

    List<Mapping> getActiveMappings()

Returns a list of all of the active mappings in the Service User Mapper.

Returns:
  A list of the currently active mapped Service users