Class Mapping

  • All Implemented Interfaces:
    java.lang.Comparable<Mapping>

    public class Mapping
    extends java.lang.Object
    implements java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String SERVICENAME
      The name of the osgi property holding the service name.
    • Constructor Summary

      Constructors 
      Constructor Description
      Mapping​(java.lang.String spec)
      Creates a mapping entry for the entry specification of the form:
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Mapping o)  
      static java.util.Set<java.lang.String> extractPrincipalNames​(java.lang.String s)  
      java.lang.String getServiceName()  
      java.lang.String getSubServiceName()  
      java.lang.String map​(java.lang.String serviceName, java.lang.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).
      java.lang.Iterable<java.lang.String> mapPrincipals​(java.lang.String serviceName, java.lang.String subServiceName)
      Returns the principal names if the serviceName and the serviceInfo match and principal names have been configured.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • SERVICENAME

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

      • Mapping

        public Mapping​(java.lang.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:
        java.lang.NullPointerException - if spec is null.
        java.lang.IllegalArgumentException - if spec does not match the expected pattern.
    • Method Detail

      • extractPrincipalNames

        public static java.util.Set<java.lang.String> extractPrincipalNames​(java.lang.String s)
      • map

        public java.lang.String map​(java.lang.String serviceName,
                                    java.lang.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 java.lang.Iterable<java.lang.String> mapPrincipals​(java.lang.String serviceName,
                                                                  java.lang.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.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getServiceName

        public java.lang.String getServiceName()
      • getSubServiceName

        public java.lang.String getSubServiceName()
      • compareTo

        public int compareTo​(Mapping o)
        Specified by:
        compareTo in interface java.lang.Comparable<Mapping>