New principal name transformer.

@param p the p
@return the principal name transformer
167410
public static PrincipalNameTransformer newPrincipalNameTransformer(final PrincipalTransformationProperties p) {
        val chain = new ChainingPrincipalNameTransformer();

        if (p.getGroovy().getLocation() != null) {
            val t = new GroovyPrincipalNameTransformer(p.getGroovy().getLocation());
            chain.addTransformer(t);
        }

        if (StringUtils.isNotBlank(p.getPattern())) {
            val t = new RegexPrincipalNameTransformer(p.getPattern());
            chain.addTransformer(t);
        }

        if (StringUtils.isNotBlank(p.getPrefix()) || StringUtils.isNotBlank(p.getSuffix())) {
            val t = new PrefixSuffixPrincipalNameTransformer();
            t.setPrefix(p.getPrefix());
            t.setSuffix(p.getSuffix());
            chain.addTransformer(t);
        } else {
            chain.addTransformer(new NoOpPrincipalNameTransformer());
        }

        if (p.getCaseConversion() == PrincipalTransformationProperties.CaseConversion.UPPERCASE) {
            val t = new ConvertCasePrincipalNameTransformer();
            t.setToUpperCase(true);
            chain.addTransformer(t);
        }

        if (p.getCaseConversion() == PrincipalTransformationProperties.CaseConversion.LOWERCASE) {
            val t = new ConvertCasePrincipalNameTransformer();
            t.setToUpperCase(false);
            chain.addTransformer(t);
        }

        return chain;
    }
1185658
public static Map<String, QueryParameter> getChildDependentParameters(List<QueryParameter> params, QueryParameter p) {
        Map<String, QueryParameter> result = new HashMap<String, QueryParameter>();
        for (QueryParameter param : params) {
            if (!param.equals(p)) {
                if (param.isDependent()) {
                    List<String> names = param.getDependentParameterNames();
                    if (names.contains(p.getName())) {
                        result.put(param.getName(), param);
                    }
                }
            }
        }
        return result;
    }
1216143
public static X500Name getX500Name(PrincipalIndentifier principal)
    {
        if (principal instanceof BcPrincipalIdentifier) {
            return ((BcPrincipalIdentifier) principal).getX500Name();
        } else {
            return new X500Name(principal.getName());
        }
    }
532561
@Override
    protected Principal getPrincipal(String username) {
        Principal principal;

        // force lookup of user info
        if (username.startsWith("*")) {
            principal = readPrincipal(username.substring(1));
            if (principal != null) {
                synchronized (principals) {
                    principals.put(username.substring(1), principal);
                }
            }
        }

        synchronized (principals) {
            principal = (Principal) principals.get(username);
        }
        if (principal == null) {
            principal = readPrincipal(username);
            if (principal != null) {
                synchronized (principals) {
                    principals.put(username, principal);
                }
            }
        }
        return principal;
    }
1082031
protected String createReadableName(CmsRelation relation) {

        return relation.getType().getName()
            + "[ "
            + relation.getSourcePath()
            + " -> "
            + relation.getTargetPath()
            + " ]";
    }
165612
public static Map<String, Object> buildEventAttributeMap(final Principal principal,
                                                             final Optional<RegisteredService> service,
                                                             final MultifactorAuthenticationProvider provider) {
        val map = new HashMap<String, Object>();
        map.put(Principal.class.getName(), principal);
        service.ifPresent(svc -> map.put(RegisteredService.class.getName(), svc));
        map.put(MultifactorAuthenticationProvider.class.getName(), provider);
        return map;
    }
594655
protected String getAcePrincipalName(CmsObject cms, CmsUUID principalId) {

        if (CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID.equals(principalId)) {
            return CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME;
        }
        if (CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID.equals(principalId)) {
            return CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME;
        }
        CmsRole role = CmsRole.valueOfId(principalId);
        if (role != null) {
            return role.getRoleName();
        }
        try {
            return CmsPrincipal.readPrincipalIncludingHistory(cms, principalId).getName();
        } catch (CmsException e) {
            return "" + principalId;
        }
    }
1059553
private static Principal getPrimaryPrincipal(final PrincipalElectionStrategy principalElectionStrategy,
                                                 final Set<Authentication> authentications,
                                                 final Map<String, List<Object>> principalAttributes) {
        return principalElectionStrategy.nominate(new LinkedHashSet<>(authentications), principalAttributes);
    }
121320
public static PrincipalResolver newPersonDirectoryPrincipalResolver(
        final PrincipalFactory principalFactory, final IPersonAttributeDao attributeRepository,
        final PersonDirectoryPrincipalResolverProperties personDirectory) {

        return new PersonDirectoryPrincipalResolver(
            attributeRepository,
            principalFactory,
            personDirectory.isReturnNull(),
            personDirectory.getPrincipalAttribute(),
            personDirectory.isUseExistingPrincipalId(),
            personDirectory.isAttributeResolutionEnabled(),
            org.springframework.util.StringUtils.commaDelimitedListToSet(personDirectory.getActiveAttributeRepositoryIds())
        );
    }
1367415
@Override
    public Function<Principal, Principal> getPrincipalMapper() {
        return p -> {
            final ClassLoader old = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(UserLdapCallbackHandler.class);
            LdapConnectionHandler ldapConnectionHandler = createLdapConnectionHandler();
            try {
                try {
                    SearchResult<LdapEntry> searchResult = userSearcherInjector.getValue().search(ldapConnectionHandler, p.getName());

                    return p instanceof RealmUser ? new MappedPrincipal(((RealmUser) p).getRealm(), searchResult.getResult().getSimpleName(), p.getName())
                            : new MappedPrincipal(searchResult.getResult().getSimpleName(), p.getName());
                } catch (IllegalStateException | IOException | NamingException e) {
                    SECURITY_LOGGER.trace("Unable to map principal.", e);
                    return p;
                }
            } finally {
                safeClose(ldapConnectionHandler);
                WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
            }
        };
    }
759016
public static String makePropertyName(String name) {
    char[] buf = new char[name.length() + 3];
    int pos = 0;
    buf[pos++] = 's';
    buf[pos++] = 'e';
    buf[pos++] = 't';

    for (int ix = 0; ix < name.length(); ix++) {
      char ch = name.charAt(ix);
      if (ix == 0)
        ch = Character.toUpperCase(ch);
      else if (ch == '-') {
        ix++;
        if (ix == name.length())
          break;
        ch = Character.toUpperCase(name.charAt(ix));
      }

      buf[pos++] = ch;
    }

    return new String(buf, 0, pos);
  }
1349454
public I_CmsPrincipal lookupPrincipal(CmsRequestContext context, String principalName) {

        CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
        I_CmsPrincipal result = null;
        try {
            result = m_driverManager.lookupPrincipal(dbc, CmsOrganizationalUnit.removeLeadingSeparator(principalName));
        } finally {
            dbc.clear();
        }
        return result;
    }
890869
public String getPeerPublicHostName (String nodeName)
    {
        if (Objects.equal(_nodeName, nodeName)) {
            return _self.publicHostName;
        }
        PeerNode peer = _peers.get(nodeName);
        return (peer == null) ? null : peer.getPublicHostName();
    }
751887
private int insertName(final String pName) throws TTException {
        final String string = (pName == null ? "" : pName);
        final int nameKey = NamePageHash.generateHashForString(string);
        NodeMetaPageFactory.MetaKey key = new NodeMetaPageFactory.MetaKey(nameKey);
        NodeMetaPageFactory.MetaValue value = new NodeMetaPageFactory.MetaValue(string);
        getPageWtx().getMetaBucket().put(key, value);
        return nameKey;
    }
398897
public AuxiliaryTree copy(TsurgeonPattern p) {
    Map<String,Tree> newNamesToNodes = new HashMap<String,Tree>();
    Pair<Tree,Tree> result = copyHelper(tree,newNamesToNodes);
    //if(! result.first().dominates(result.second()))
      //System.err.println("Error -- aux tree copy doesn't dominate foot copy.");
    p.root.newNodeNames.putAll(newNamesToNodes);
    return new AuxiliaryTree(result.first(), result.second(), newNamesToNodes, originalTreeString);
  }
1269791
@Override
    public Set<Principal> getPrincipals(final HttpServletRequest request) {
        LOGGER.debug("Checking for principals using {}", HttpHeaderPrincipalProvider.class.getSimpleName());

        if (headerName == null || separator == null) {
            LOGGER.debug("headerName or separator not initialized");
            return emptySet();
        }

        LOGGER.debug("Trying to get principals from header: {}; separator: {}", headerName, separator);

        if (request == null) {
            LOGGER.debug("Servlet request from servletCredentials was null");
            return emptySet();
        }

        final String value = request.getHeader(headerName);

        if (value == null) {
            LOGGER.debug("Value for header {} is null", headerName);
            return emptySet();
        }

        final String[] names = value.split(separator);

        final Set<Principal> principals = new HashSet<>();

        for (final String name : names) {
            LOGGER.debug("Adding HTTP header-provided principal: {}", name.trim());
            principals.add(createPrincipal(name));
        }

        return principals;

    }
1119275
private static Method getNamedPCLAdder(Class beanClass) {
        try {
            return beanClass.getMethod("addPropertyChangeListener", NAMED_PCL_PARAMS);
        }
        catch (NoSuchMethodException e) {
            return null;
        }
    }