Package org.apache.sling.jackrabbit.usermanager.impl.post

# 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

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static @interface`
`PrincipalNameGeneratorImpl.Config`

## Nested classes/interfaces inherited from interface org.apache.sling.jackrabbit.usermanager.PrincipalNameGenerator

`PrincipalNameGenerator.NameInfo`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`DEFAULT_MAX_NAME_LENGTH`

## Constructor Summary

Constructors
Constructor
Description
`PrincipalNameGeneratorImpl()`
`PrincipalNameGeneratorImpl(String[] parameterNames, int maxNameLength)`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`activate(PrincipalNameGeneratorImpl.Config config)`
`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
`protected String`
`getValueToUse(Map<String,?> parameters, String paramName)`
Determine the value to use for the specified parameter.
`protected @NotNull List<String>`
`valueToList(Object value)`
Convert the value to a list of strings

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_MAX_NAME_LENGTH

public static final int DEFAULT_MAX_NAME_LENGTH

See Also:
  - Constant Field Values

## 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