Class Mapping

  • All Implemented Interfaces:
    Comparable<Mapping>

    public class Mapping
    extends Object
    implements Comparable<Mapping>
    The Mapping class defines the mapping of a service's name and optional service information to a user name and optionally to a set of principal names.
    • Field Detail

      • SERVICENAME

        public static String SERVICENAME
        The name of the osgi property holding the service name.
    • Constructor Detail

      • Mapping

        public Mapping​(String spec)
        Creates a mapping entry for the entry specification of the form:
         spec = serviceName [ ":" subServiceName ] "=" userName | "[" principalNames "]"
         principalNames = principalName ["," principalNames]
         
        Parameters:
        spec - The mapping specification.
        Throws:
        NullPointerException - if spec is null.
        IllegalArgumentException - if spec does not match the expected pattern.
    • Method Detail

      • extractPrincipalNames

        public static Set<String> extractPrincipalNames​(String s)
      • map

        public String map​(String serviceName,
                          String subServiceName)
        Returns the user name if the serviceName and the serviceInfo match and a single user name is configured (in contrast to a set of principal names). Otherwise null is returned.
        Parameters:
        serviceName - The name of the service to match. If this is null this mapping will not match.
        subServiceName - The Subservice Name to match. This may be null.
        Returns:
        The user name if this mapping matches and the configuration doesn't specify a set of principal names; null otherwise.
      • mapPrincipals

        public Iterable<String> mapPrincipals​(String serviceName,
                                              String subServiceName)
        Returns the principal names if the serviceName and the serviceInfo match and principal names have been configured. Otherwise null is returned. If no principal names are configured map(String, String) needs to be used instead.
        Parameters:
        serviceName - The name of the service to match. If this is null this mapping will not match.
        subServiceName - The Subservice Name to match. This may be null.
        Returns:
        An iterable of principals names this mapping matches and the configuration does specify a set of principal names (intstead of a single user name); null otherwise.
      • getServiceName

        public String getServiceName()
      • getSubServiceName

        public String getSubServiceName()