Class PrincipalNameGeneratorImpl

java.lang.Object
org.apache.sling.jackrabbit.usermanager.impl.post.PrincipalNameGeneratorImpl
All Implemented Interfaces:
PrincipalNameGenerator

public class PrincipalNameGeneratorImpl extends Object implements PrincipalNameGenerator
Default implementation that generates a principal name based on a set of well-known request parameters

The value is resolved by the locating the first request parameter that is a match of one of the choices in the following order:

  1. ":name" - value is the exact name to use
  2. ":name@ValueFrom" - value is the name of another submitted parameter whose value is the exact name to use
  3. ":nameHint" - value is filtered, trimmed and made unique
  4. ":nameHint@ValueFrom" - value is the name of another submitted parameter whose value is filtered, trimmed and made unique
  5. otherwise, try the value of any configured "principalNameHints" parameters to treat as a hint that is filtered, trimmed and made unique
  • Field Details

    • DEFAULT_MAX_NAME_LENGTH

      public static final int DEFAULT_MAX_NAME_LENGTH
      See Also:
  • Constructor Details

    • PrincipalNameGeneratorImpl

      public PrincipalNameGeneratorImpl()
    • PrincipalNameGeneratorImpl

      public PrincipalNameGeneratorImpl(String[] parameterNames, int maxNameLength)
  • Method Details

    • activate

      protected void activate(PrincipalNameGeneratorImpl.Config config)
    • valueToList

      @NotNull protected @NotNull List<String> valueToList(Object value)
      Convert the value to a list of strings
    • getValueToUse

      protected String getValueToUse(Map<String,?> parameters, String paramName)
      Determine the value to use for the specified parameter. This also considers the parameter with a SlingPostConstants.VALUE_FROM_SUFFIX
      Parameters:
      parameters - the map of request parameters
      paramName - the parameter to get the value for
      Returns:
      the value to use for the parameter or null if it could not be determined
    • getPrincipalName

      public PrincipalNameGenerator.NameInfo getPrincipalName(Map<String,?> parameters, org.apache.jackrabbit.oak.spi.security.user.AuthorizableType type, PrincipalNameFilter principalNameFilter, PrincipalNameGenerator defaultPrincipalNameGenerator)
      Get a "nice" principal name, if possible, based on given request
      Specified by:
      getPrincipalName in interface PrincipalNameGenerator
      Parameters:
      parameters - the properties to consider when generating a name
      type - the type of principal
      principalNameFilter - the filter to make a value work as a principal name
      defaultPrincipalNameGenerator - the default principal name generator
      Returns:
      the principal name to be created or null if other PrincipalNameGenerators should be consulted